-
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: create a module,invoice cron, doc upload wizard, i…
…nvoice - Add setting section for installment - Add wizard for Add EMI - Add Button for document module redirect - Implemented the invoice schedule when exceed the delay process day - Add the Document Upload request smart button - Add wizard for document request for sales order
- Loading branch information
Showing
21 changed files
with
696 additions
and
5 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
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 |
---|---|---|
|
@@ -29,3 +29,6 @@ def button_action_sold(self): | |
} | ||
self.env["account.move"].sudo().create(invoice_vals) | ||
return result | ||
|
||
|
||
|
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,19 @@ | ||
{ | ||
"name": "installment", | ||
"version": "0.1", | ||
"license": "LGPL-3", | ||
"depends": ["base", "sale_subscription", "documents"], | ||
"description": "Installment Application", | ||
"installable": True, | ||
"application": True, | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/installment_setting_view.xml", | ||
"wizard/add_emi_view.xml", | ||
"wizard/documents_request_view.xml", | ||
"views/installment_menu.xml", | ||
"views/sales_order_view.xml", | ||
"data/product_data.xml", | ||
"data/corn.xml", | ||
], | ||
} |
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,14 @@ | ||
<odoo> | ||
<data> | ||
<record model="ir.cron" id="installemnt_invoice_corn"> | ||
<field name="name">installemnt.invoice.corn</field> | ||
<field name="model_id" ref="model_account_move"/> | ||
<field name="state">code</field> | ||
<field name="code">model.cron_recurring_create_invoice()</field> | ||
<field name="interval_number">1</field> | ||
<field name="interval_type">days</field> | ||
<field name="numbercall">-1</field> | ||
|
||
</record> | ||
</data> | ||
</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,20 @@ | ||
<odoo> | ||
<data> | ||
<record id="product_product_installment" model="product.product"> | ||
<field name="name">Installment</field> | ||
<field name="recurring_invoice">True</field> | ||
</record> | ||
|
||
<record id="product_product_down_payment" model="product.product"> | ||
<field name="name">Down Payment</field> | ||
|
||
</record> | ||
|
||
<record id="product_product_penalty" model="product.product"> | ||
<field name="name">Penalty</field> | ||
|
||
</record> | ||
|
||
|
||
</data> | ||
</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,3 @@ | ||
from . import installment_installemnt | ||
from . import sale_order | ||
from . import account_move |
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,84 @@ | ||
from datetime import timedelta | ||
from odoo import Command, models, fields, api | ||
|
||
|
||
class accountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
applied_penalty = fields.Boolean(string="Applied Penalty", default=False) | ||
|
||
@api.model | ||
def cron_recurring_create_invoice(self): | ||
|
||
today = fields.Date.today() | ||
delay_penalty_process = float( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("installment.delay_penalty_process") | ||
) | ||
|
||
invoices = self.env["account.move"].search( | ||
[ | ||
("state", "=", "posted"), | ||
("payment_state", "=", "not_paid"), | ||
("move_type", "=", "out_invoice"), | ||
("applied_penalty", "=", False), | ||
] | ||
) | ||
for invoice in invoices: | ||
|
||
for line in invoice.line_ids: | ||
if ( | ||
line.product_id.id | ||
== self.env.ref("installment.product_product_installment").id | ||
): | ||
due_date = invoice.invoice_date_due | ||
|
||
penalty_start_date = due_date + timedelta( | ||
days=delay_penalty_process | ||
) | ||
|
||
if today >= penalty_start_date: | ||
penalty_amount = self.calculate_penalty_amount(invoice) | ||
|
||
invoice_vals = { | ||
"partner_id": invoice.partner_id.id, | ||
"move_type": "out_invoice", | ||
"line_ids": [ | ||
Command.create( | ||
{ | ||
"product_id": self.env.ref( | ||
"installment.product_product_installment" | ||
).id, | ||
"name": "Installment", | ||
"price_unit": invoice.amount_total, | ||
"tax_ids": None, | ||
} | ||
), | ||
Command.create( | ||
{ | ||
"product_id": self.env.ref( | ||
"installment.product_product_penalty" | ||
).id, | ||
"name": "Penalty Charge", | ||
"price_unit": penalty_amount, | ||
"tax_ids": None, | ||
} | ||
), | ||
], | ||
} | ||
new_invoice = ( | ||
self.env["account.move"].sudo().create(invoice_vals) | ||
) | ||
new_invoice.action_post() | ||
invoice.write({"applied_penalty": True}) | ||
|
||
def calculate_penalty_amount(self, invoice): | ||
|
||
down_penalty_percentage = float( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("installment.down_penalty_percentage") | ||
) | ||
penalty_amount = (invoice.amount_total * down_penalty_percentage) / 100 | ||
return penalty_amount |
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,39 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class installment(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
name = fields.Char() | ||
max_duration = fields.Float(config_parameter="installment.max_duration") | ||
annual_percentage_rate = fields.Float( | ||
config_parameter="installment.annual_percentage_rate" | ||
) | ||
down_payment_percentage = fields.Float( | ||
config_parameter="installment.down_payment_percentage" | ||
) | ||
administrative_expenses_percentage = fields.Float( | ||
config_parameter="installment.administrative_expenses_percentage" | ||
) | ||
down_penalty_percentage = fields.Float( | ||
config_parameter="installment.down_penalty_percentage" | ||
) | ||
delay_penalty_process = fields.Integer( | ||
config_parameter="installment.delay_penalty_process" | ||
) | ||
nid = fields.Boolean(config_parameter="installment.nid", default=False) | ||
salary_components = fields.Boolean( | ||
config_parameter="installment.salary_components", default=False | ||
) | ||
bank_statement = fields.Boolean( | ||
config_parameter="installment.bank_statement", default=False | ||
) | ||
bank_rate_letter = fields.Boolean( | ||
config_parameter="installment.bank_rate_letter", default=False | ||
) | ||
rental_contract = fields.Boolean( | ||
config_parameter="installment.rental_contract", default=False | ||
) | ||
owership_contract = fields.Boolean( | ||
config_parameter="installment.owership_contract", default=False | ||
) |
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,5 @@ | ||
from odoo import models | ||
|
||
|
||
class sale_order(models.Model): | ||
_inherit = "sale.order" |
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,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
installment.access_add_emi,access_add_emi,installment.model_add_emi,base.group_user,1,1,1,1 | ||
installment.access_documents_request,access_documents_request,installment.model_documents_request,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,9 @@ | ||
<odoo> | ||
<menuitem id="installment_root" name="Installment app"> | ||
<menuitem id="installment_configration_level_menu" name="Configration"> | ||
<menuitem id="installment_configuration_menu_action" | ||
action="action_sale_config_settings" /> | ||
</menuitem> | ||
|
||
</menuitem> | ||
</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,98 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="res_installment_configuration_settings_view_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.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//form" position="inside"> | ||
<app string="Installment" data-string="Installment" name="installment"> | ||
<block title="Installment Process" name="installment_setting_container"> | ||
<setting string="Max Duration" help=" Define Max Duration"> | ||
|
||
<field name="max_duration" /> | ||
<span>Years</span> | ||
</setting> | ||
<setting string="Annual Percentage Rate" | ||
help=" Define Annual Percentage Rate"> | ||
|
||
<field name="annual_percentage_rate" /> | ||
<span>% Per Years</span> | ||
</setting> | ||
<setting string="Down Payment Percentage" | ||
help=" Define Down Payment Percentage"> | ||
|
||
<field name="down_payment_percentage" /> | ||
<span>% From Product Price</span> | ||
</setting> | ||
<setting string="Administrative Expenses Percentage" | ||
help=" Define Administrative Expenses Percentage"> | ||
|
||
<field name="administrative_expenses_percentage" /> | ||
<span>% From Amount After D.Payment</span> | ||
</setting> | ||
<setting string="Down Penalty Percentage" | ||
help=" Define Down Penalty Percentage "> | ||
|
||
<field name="down_penalty_percentage" /> | ||
<span>% From Monthly Amount</span> | ||
</setting> | ||
<setting string="Delay Penalty Process" | ||
help=" Define Delay Penalty Process "> | ||
|
||
<field name="delay_penalty_process" /> | ||
<span | ||
help="Delay Penalty percentage will be applied after exceed the delay process period"> | ||
Days</span> | ||
<div class="text-muted"> | ||
Delay Penalty percentage will be applied after exceed the delay | ||
process period | ||
</div> | ||
</setting> | ||
</block> | ||
|
||
<block title="Needed Documents" name="needed_documents_setting_container"> | ||
<setting string="Nid"> | ||
|
||
<field name="nid" /> | ||
</setting> | ||
<setting string="Salary Components"> | ||
|
||
<field name="salary_components" /> | ||
</setting> | ||
<setting string="Bank Statement"> | ||
|
||
<field name="bank_statement" /> | ||
</setting> | ||
<setting string="Bank Rate Letter"> | ||
|
||
<field name="bank_rate_letter" /> | ||
</setting> | ||
<setting string="Rental Contract"> | ||
|
||
<field name="rental_contract" /> | ||
</setting> | ||
<setting string="Owership Contract"> | ||
|
||
<field name="owership_contract" /> | ||
|
||
</setting> | ||
|
||
</block> | ||
</app> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="action_sale_config_settings" model="ir.actions.act_window"> | ||
<field name="name">Settings</field> | ||
<field name="res_model">res.config.settings</field> | ||
<field name="view_id" ref="res_installment_configuration_settings_view_form" /> | ||
<field name="view_mode">form</field> | ||
<!-- <field name="target">inline</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,19 @@ | ||
<odoo> | ||
<record id="view_sales_order_form" model="ir.ui.view"> | ||
<field name="name">sale.order.form</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']/button" position="before"> | ||
<button name="%(installment.add_emi_action)s" type="action" string="Add EMI" /> | ||
</xpath> | ||
|
||
<xpath expr="//div[hasclass('oe_button_box')]" position="inside"> | ||
<button name="%(action_upload_documents)s" type="action" string="Add Documents" | ||
class="oe_stat_button" | ||
icon="fa-file-pdf-o" /> | ||
</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,2 @@ | ||
from . import add_emi | ||
from . import document_request |
Oops, something went wrong.