-
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
168 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 wizard | ||
from . import models |
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,18 @@ | ||
{ | ||
'name': 'installment', | ||
'version': '1.0', | ||
'description': 'A module for installment', | ||
'category': 'sales', | ||
'author': 'YASP', | ||
'sequence': 1, | ||
'depends': ['base', 'sale_subscription'], | ||
'license': 'LGPL-3', | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'wizard/wizard_view.xml', | ||
'views/res_config_settings_view.xml', | ||
'views/add_emi_view.xml' | ||
], | ||
'installable': True, | ||
'application': True, | ||
} |
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 ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
max_duration = fields.Integer(string="Max Duration", config_parameter="installment.max_duration") | ||
annual_rate_percentage = fields.Integer(string="Annual Rate Percentage", config_parameter="installment.annual_rate_percentage") | ||
down_payment_percentage = fields.Integer(string="Down Payment Percentage", config_parameter="installment.down_payment_percentage") | ||
administrative_expense_percentage = fields.Integer(string="Administrative Expense Percentage", config_parameter="installment.administrative_expense_percentage") | ||
delay_penalty_percentage = fields.Integer(string="Delay Penalty Percentage", config_parameter="installment.delay_penalty_percentage") | ||
delay_penalty_process = fields.Integer(string="Delay Penalty Process", config_parameter="installment.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_installment_add_emi_wizard,access_installment_add_emi_wizard,model_installment_add_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,15 @@ | ||
<odoo> | ||
<record id="add_emi_view" model="ir.ui.view"> | ||
<field name="name">add.emi.view</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="%(installment.action_add_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_installment_form" model="ir.ui.view"> | ||
<field name="name">res.config.settings.view.form.inherit.installment</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//block[@name='integration']" 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_percentage"/> | ||
<a>%Per Year</a> | ||
</setting> | ||
<setting id="down_payment_percentage_setting" help="Define the Down Payment Percentage"> | ||
<field name="down_payment_percentage"/> | ||
<a>%From Product Price</a> | ||
</setting> | ||
<setting id="administrative_expense_percentage_setting" help="Define the Administrative Expense Percentage"> | ||
<field name="administrative_expense_percentage"/> | ||
<a>%From Amount After D.Payment</a> | ||
</setting> | ||
<setting id="delay_penalty_percentage_setting" help="Define the Delay Penalty Percentage"> | ||
<field name="delay_penalty_percentage"/> | ||
<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 add_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 AddEmiWizard(models.TransientModel): | ||
_name = 'installment.add.emi.wizard' | ||
_description = 'Add Emi Wizard' | ||
|
||
totalso_amount = fields.Float(string="Total Amount", readonly=True) | ||
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 Amount2", compute="_compute_values") | ||
interest = fields.Float(string="Interest", compute="_compute_values") | ||
administrative_expense = fields.Float(string="Administrative Expense", compute="_compute_values") | ||
nof_installment = fields.Integer(string="No. of Monthly Installment", 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['totalso_amount'] = self.env['sale.order'].browse(self.env.context.get('active_id')).amount_total | ||
return defaults | ||
|
||
@api.depends("totalso_amount") | ||
def _compute_values(self): | ||
for rec in self: | ||
down_payment_percent = self.env['ir.config_parameter'].get_param('installment.down_payment_percentage') | ||
x = float(rec.totalso_amount) * float(down_payment_percent) | ||
rec.down_payment = x / 100 | ||
rec.remaining_amount = rec.totalso_amount - rec.down_payment | ||
administrative_expense_percent = self.env['ir.config_parameter'].get_param('installment.administrative_expense_percentage') | ||
y = float(rec.remaining_amount) * float(administrative_expense_percent) | ||
rec.administrative_expense = y / 100 | ||
rec.remaining_amount2 = rec.remaining_amount + rec.administrative_expense | ||
annual_rate_percent = self.env['ir.config_parameter'].get_param('installment.annual_rate_percentage') | ||
z = float(rec.remaining_amount2) * float(annual_rate_percent) | ||
rec.interest = z / 100 | ||
nof_install = float(self.env['ir.config_parameter'].get_param('installment.max_duration')) | ||
rec.nof_installment = nof_install * 12 | ||
final_amount = rec.remaining_amount2 + rec.interest | ||
rec.installment_amount = final_amount / rec.nof_installment | ||
|
||
def action_add_emi(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,30 @@ | ||
<odoo> | ||
<record id="installment_add_emi_wizard_form" model="ir.ui.view"> | ||
<field name="name">installment.add.emi.wizard.form</field> | ||
<field name="model">installment.add.emi.wizard</field> | ||
<field name="arch" type="xml"> | ||
<form string="Add EMI"> | ||
<group> | ||
<field name="totalso_amount" /> | ||
<field name="down_payment" /> | ||
<field name="remaining_amount" /> | ||
<field name="interest" /> | ||
<field name="nof_installment" /> | ||
<field name="installment_amount" /> | ||
</group> | ||
<footer> | ||
<button string="Add Installment" type="object" name="action_add_emi" | ||
class="btn-primary" /> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_add_emi_wizard" model="ir.actions.act_window"> | ||
<field name="name">ADD EMI</field> | ||
<field name="res_model">installment.add.emi.wizard</field> | ||
<field name="view_mode">form</field> | ||
<field name="view_id" ref="installment_add_emi_wizard_form" /> | ||
<field name="target">new</field> | ||
</record> | ||
</odoo> |