From 8e36729a2b0de541291e207d4824031057c4ef35 Mon Sep 17 00:00:00 2001 From: Vincent Van Rossem Date: Mon, 21 Dec 2020 14:24:03 +0100 Subject: [PATCH] [12.0][ADD] emc_loan: field paid_amount - renamed `_compute_subscribed_amount` into `_compute_amounts` to compute both subscribed and paid amount. - added field paid_amount both in form and tree view. - bumped manifest --- easy_my_coop_loan/__manifest__.py | 2 +- easy_my_coop_loan/models/loan.py | 24 ++++++++++++++++-------- easy_my_coop_loan/views/loan_view.xml | 2 ++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/easy_my_coop_loan/__manifest__.py b/easy_my_coop_loan/__manifest__.py index 97d24b7..33acd38 100644 --- a/easy_my_coop_loan/__manifest__.py +++ b/easy_my_coop_loan/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Easy My Coop Bond and Subordinated Loan Issues", - "version": "12.0.1.0.1", + "version": "12.0.1.0.2", "depends": ["easy_my_coop"], "author": "Coop IT Easy SCRLfs", "category": "Cooperative management", diff --git a/easy_my_coop_loan/models/loan.py b/easy_my_coop_loan/models/loan.py index 0e686c5..789ac29 100644 --- a/easy_my_coop_loan/models/loan.py +++ b/easy_my_coop_loan/models/loan.py @@ -14,14 +14,17 @@ class LoanIssue(models.Model): _description = "Loan Issue" @api.multi - def _compute_subscribed_amount(self): + def _compute_amounts(self): for issue in self: - susbscribed_amount = 0.0 - for line in issue.loan_issue_lines.filtered( - lambda record: record.state != "cancelled" - ): - susbscribed_amount += line.amount - issue.subscribed_amount = susbscribed_amount + subscription_lines = issue.loan_issue_lines.filtered( + lambda line: line.state != "cancelled" + ) + issue.subscribed_amount = sum(subscription_lines.mapped("amount")) + + paid_lines = issue.loan_issue_lines.filtered( + lambda line: line.state == "paid" + ) + issue.paid_amount = sum(paid_lines.mapped("amount")) name = fields.Char(string="Name", translate=True) default_issue = fields.Boolean(string="Default issue") @@ -63,7 +66,12 @@ class LoanIssue(models.Model): ) subscribed_amount = fields.Monetary( string="Subscribed amount", - compute="_compute_subscribed_amount", + compute="_compute_amounts", + currency_field="company_currency_id", + ) + paid_amount = fields.Monetary( + string="Paid amount", + compute="_compute_amounts", currency_field="company_currency_id", ) interest_payment = fields.Selection( diff --git a/easy_my_coop_loan/views/loan_view.xml b/easy_my_coop_loan/views/loan_view.xml index a262cad..b2c3872 100644 --- a/easy_my_coop_loan/views/loan_view.xml +++ b/easy_my_coop_loan/views/loan_view.xml @@ -15,6 +15,7 @@ + @@ -73,6 +74,7 @@ +