From aecb0e9f5c38c6ce436f814548e99b31f577f63d Mon Sep 17 00:00:00 2001 From: houssine Date: Fri, 9 Oct 2020 13:16:45 +0200 Subject: [PATCH] [IMP] create views for loan interest lines [IMP] add field payment date for loan payment reception [IMP] if state is not ongoing we can't add new loan. [IMP] add fields to the views --- easy_my_coop_loan/__manifest__.py | 6 +- easy_my_coop_loan/models/interest_line.py | 26 ++++- easy_my_coop_loan/models/loan_issue_line.py | 7 +- .../views/loan_interest_lines_view.xml | 94 +++++++++++++++++++ easy_my_coop_loan/views/loan_line_view.xml | 1 + easy_my_coop_loan/views/loan_view.xml | 2 +- 6 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 easy_my_coop_loan/views/loan_interest_lines_view.xml diff --git a/easy_my_coop_loan/__manifest__.py b/easy_my_coop_loan/__manifest__.py index f59bd67..433f7ed 100644 --- a/easy_my_coop_loan/__manifest__.py +++ b/easy_my_coop_loan/__manifest__.py @@ -4,11 +4,11 @@ { "name": "Easy My Coop Bond and Subordinated Loan Issues", - "version": "12.0.1.0.1", + "version": "12.0.2.0.1", "depends": ["easy_my_coop"], "author": "Coop IT Easy SCRLfs", "category": "Cooperative management", - "website": "http://www.coopiteasy.be", + "website": "https://www.coopiteasy.be", "license": "AGPL-3", "summary": """ This module allows to manage the bonds and @@ -17,6 +17,8 @@ "data": [ "security/ir.model.access.csv", "views/loan_view.xml", + "views/loan_line_view.xml", + "views/loan_interest_lines_view.xml", "views/partner_view.xml", "views/menus.xml", "data/mail_template_data.xml", diff --git a/easy_my_coop_loan/models/interest_line.py b/easy_my_coop_loan/models/interest_line.py index 98a7927..17915bf 100644 --- a/easy_my_coop_loan/models/interest_line.py +++ b/easy_my_coop_loan/models/interest_line.py @@ -9,12 +9,23 @@ class LoanInterestLine(models.Model): _name = "loan.interest.line" _description = "Loan Interest Line" - name = fields.Integer(string="Year", required=True) + name = fields.Integer( + string="Year", + required=True + ) + loan_issue_id = fields.Many2one( + related="issue_line.loan_issue_id", + store=True, + readlonly=True) issue_line = fields.Many2one( - "loan.issue.line", string="Subscribed loan", required=True + "loan.issue.line", + string="Subscribed loan", + required=True ) partner_id = fields.Many2one( - related="issue_line.partner_id", store=True, readlonly=True + related="issue_line.partner_id", + store=True, + readlonly=True ) amount = fields.Monetary( related="issue_line.amount", @@ -32,7 +43,10 @@ class LoanInterestLine(models.Model): currency_field="company_currency_id", readonly=True, ) - taxes_rate = fields.Float(string="Taxes on interest", required=True) + taxes_rate = fields.Float( + string="Taxes on interest", + required=True + ) taxes_amount = fields.Monetary( string="Taxes amount", currency_field="company_currency_id", @@ -58,6 +72,10 @@ class LoanInterestLine(models.Model): currency_field="company_currency_id", readonly=True, ) + due_amount = fields.Monetary( + string="Due amount", + currency_field="company_currency_id" + ) due_date = fields.Date(string="Due date") company_currency_id = fields.Many2one( "res.currency", diff --git a/easy_my_coop_loan/models/loan_issue_line.py b/easy_my_coop_loan/models/loan_issue_line.py index f8cafcf..46faefa 100644 --- a/easy_my_coop_loan/models/loan_issue_line.py +++ b/easy_my_coop_loan/models/loan_issue_line.py @@ -40,6 +40,8 @@ class LoanIssueLine(models.Model): default=lambda self: datetime.strftime(datetime.now(), "%Y-%m-%d"), required=True, ) + payment_date = fields.Date( + string="Payment date") amount = fields.Monetary( string="Subscribed amount", currency_field="company_currency_id", @@ -127,4 +129,7 @@ class LoanIssueLine(models.Model): loan_email_template = self.get_confirm_paid_email_template() loan_email_template.sudo().send_mail(line.id, force_send=False) - line.write({"state": "paid"}) + vals = {"state": "paid"} + if not line.payment_date: + vals["payement_date"] = fields.Date.today() + line.write(vals) diff --git a/easy_my_coop_loan/views/loan_interest_lines_view.xml b/easy_my_coop_loan/views/loan_interest_lines_view.xml new file mode 100644 index 0000000..e0d5e26 --- /dev/null +++ b/easy_my_coop_loan/views/loan_interest_lines_view.xml @@ -0,0 +1,94 @@ + + + Loan interest lines + loan.interest.line + form + tree,form + + + + loan.interest.line.view.tree + loan.interest.line + + + + + + + + + + + + + + + + + + + loan.interest.line.form + loan.interest.line + +
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+
+
+ + + Loans interest lines Search + loan.interest.line + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/easy_my_coop_loan/views/loan_line_view.xml b/easy_my_coop_loan/views/loan_line_view.xml index f69e39d..ec24885 100644 --- a/easy_my_coop_loan/views/loan_line_view.xml +++ b/easy_my_coop_loan/views/loan_line_view.xml @@ -66,6 +66,7 @@ + diff --git a/easy_my_coop_loan/views/loan_view.xml b/easy_my_coop_loan/views/loan_view.xml index bf787c4..a8ede52 100644 --- a/easy_my_coop_loan/views/loan_view.xml +++ b/easy_my_coop_loan/views/loan_view.xml @@ -110,7 +110,7 @@ - +