-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] installment: added installment app
After this commit: - implemented installment module - added wizard button in subscription module - implemented business logic
- Loading branch information
Showing
12 changed files
with
169 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
'name': 'Installment Management', | ||
'version': '1.0', | ||
'category': 'Sales', | ||
'author': 'odoo', | ||
'depends': ['base', 'sale_subscription'], | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'wizard/action_open_emi_wizard_view.xml', | ||
'view/res_config_setting_view.xml', | ||
'view/installments_view.xml' | ||
], | ||
'installable': True, | ||
'application': True, | ||
'license': 'LGPL-3' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from odoo import models, fields | ||
|
||
|
||
class InstallmentSettings(models.TransientModel): | ||
_inherit = 'res.config.settings' | ||
|
||
max_duration = fields.Float('Max Duration', config_parameter="installments.max_duration") | ||
annual_rate = fields.Float('Annual Rate', config_parameter="installments.annual_rate") | ||
down_payment_perc = fields.Float('Down Payment', config_parameter="installments.down_payment_perc") | ||
admin_exp_perc = fields.Float('Administrative Expenses', config_parameter="installments.admin_exp_perc") | ||
delay_penalty_perc = fields.Float('Delay Penalty', config_parameter="installments.delay_penalty_perc") | ||
delay_penalty_process = fields.Integer('Delay Penalty Process', config_parameter="installments.delay_penalty_process") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink | ||
access_installments_settings_base_user,access_installments_settings_base_user,model_action_open_emi_wizard,base.group_user,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="view_order_form_inherited" model="ir.ui.view"> | ||
<field name="name">sale.order.form.inherited</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@name='so_button_below_order_lines']" position="before"> | ||
<button string="Add EMI" | ||
name="%(installments.action_open_emi_wizard)d" | ||
type="action" | ||
class="btn btn-primary"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="res_config_settings_view_form" model="ir.ui.view"> | ||
<field name="name">res.config.setting.view.form.inherit.installment</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="base.res_config_settings_view_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//block[@name='companies_setting_container']" position="after"> | ||
<block title="Installment Process" id="installment_general_settings"> | ||
<setting id="max_duration_setting" help="Define your Max duration"> | ||
<field name="max_duration"/> | ||
<a>Years</a> | ||
</setting> | ||
<setting id="annual_rate_percentage_setting" help="Define the Annual Rate Percentage"> | ||
<field name="annual_rate"/> | ||
<a>%Per Year</a> | ||
</setting> | ||
<setting id="down_payment_percentage_setting" help="Define the Down Payment Percentage"> | ||
<field name="down_payment_perc"/> | ||
<a>%From Product Price</a> | ||
</setting> | ||
<setting id="administrative_expense_percentage_setting" help="Define the Administrative Expense Percentage"> | ||
<field name="admin_exp_perc"/> | ||
<a>%From Amount After D.Payment</a> | ||
</setting> | ||
<setting id="delay_penalty_percentage_setting" help="Define the Delay Penalty Percentage"> | ||
<field name="delay_penalty_perc"/> | ||
<a>%From Monthly Amount</a> | ||
</setting> | ||
<setting id="delay_penalty_process_setting" help="Define the Delay Penalty Process"> | ||
<field name="delay_penalty_process"/> | ||
<a>Days</a> | ||
<br> | ||
<help> | ||
help="Define the Delay Penalty Process" | ||
</help> | ||
</br> | ||
</setting> | ||
</block> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import action_open_emi_wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from odoo import models, fields, api | ||
|
||
|
||
class ActionOpenEmiWizard(models.TransientModel): | ||
_name = 'action.open.emi.wizard' | ||
_description = 'Installment Settings' | ||
|
||
total_so_amount = fields.Float(string="Total SO Amount") | ||
down_payment = fields.Float(string="Down Payment", compute="_compute_values") | ||
remaining_amount = fields.Float(string="Remaining Amount", compute="_compute_values") | ||
remaining_amount2 = fields.Float(string="Remaining Amount", compute="_compute_values") | ||
interest = fields.Float(string="Interest", compute="_compute_values") | ||
admin_expence = fields.Float(string="Administrative Expense", compute="_compute_values") | ||
num_installments = fields.Integer(string="Number of Monthly Installments", compute="_compute_values") | ||
installment_amount = fields.Float(string="Installment Amount", compute="_compute_values") | ||
|
||
def default_get(self, fields_list): | ||
defaults = super().default_get(fields_list) | ||
defaults['total_so_amount'] = self.env['sale.order'].browse(self.env.context.get('active_id')).amount_total | ||
return defaults | ||
|
||
@api.depends("total_so_amount") | ||
def _compute_values(self): | ||
for rec in self: | ||
down_payment_percent = self.env['ir.config_parameter'].get_param('installments.down_payment_perc') | ||
x = float(rec.total_so_amount) * float(down_payment_percent) | ||
rec.down_payment = x / 100 | ||
rec.remaining_amount = rec.total_so_amount - rec.down_payment | ||
administrative_expense_percent = self.env['ir.config_parameter'].get_param('installments.admin_exp_perc') | ||
y = float(rec.remaining_amount) * float(administrative_expense_percent) | ||
rec.admin_expence = y / 100 | ||
rec.remaining_amount2 = rec.remaining_amount + rec.admin_expence | ||
annual_rate_percent = self.env['ir.config_parameter'].get_param('installments.annual_rate') | ||
z = float(rec.remaining_amount2) * float(annual_rate_percent) | ||
rec.interest = z / 100 | ||
nof_install = float(self.env['ir.config_parameter'].get_param('installments.max_duration')) | ||
rec.num_installments = nof_install * 12 | ||
final_amount = rec.remaining_amount2 + rec.interest | ||
rec.installment_amount = final_amount / rec.num_installments | ||
|
||
def add_installment(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<odoo> | ||
<record id="open_emi_wizard_form" model="ir.ui.view"> | ||
<field name="name">action.open.emi.form</field> | ||
<field name="model">action.open.emi.wizard</field> | ||
<field name="arch" type="xml"> | ||
<form string="EMI"> | ||
<group> | ||
<field name="total_so_amount"/> | ||
<field name="down_payment"/> | ||
<field name="remaining_amount"/> | ||
<field name="interest"/> | ||
<field name="num_installments"/> | ||
<field name="installment_amount"/> | ||
</group> | ||
<footer> | ||
<button string="Add EMI Installment" type="object" name="add_installment" class="btn-primary"/> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
<odoo> | ||
<!-- Action to open the wizard --> | ||
<record id="action_open_emi_wizard" model="ir.actions.act_window"> | ||
<field name="name">Add EMI</field> | ||
<field name="res_model">action.open.emi.wizard</field> | ||
<field name="view_mode">form</field> | ||
<field name="view_id" ref="open_emi_wizard_form"/> | ||
<field name="target">new</field> | ||
</record> | ||
</odoo> | ||
|
||
</odoo> |