Compare commits

...

1 Commits

Author SHA1 Message Date
Vincent Van Rossem 8e36729a2b [12.0][ADD] emc_loan: field paid_amount 4 years ago
  1. 2
      easy_my_coop_loan/__manifest__.py
  2. 24
      easy_my_coop_loan/models/loan.py
  3. 2
      easy_my_coop_loan/views/loan_view.xml

2
easy_my_coop_loan/__manifest__.py

@ -4,7 +4,7 @@
{ {
"name": "Easy My Coop Bond and Subordinated Loan Issues", "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"], "depends": ["easy_my_coop"],
"author": "Coop IT Easy SCRLfs", "author": "Coop IT Easy SCRLfs",
"category": "Cooperative management", "category": "Cooperative management",

24
easy_my_coop_loan/models/loan.py

@ -14,14 +14,17 @@ class LoanIssue(models.Model):
_description = "Loan Issue" _description = "Loan Issue"
@api.multi @api.multi
def _compute_subscribed_amount(self):
def _compute_amounts(self):
for issue in 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) name = fields.Char(string="Name", translate=True)
default_issue = fields.Boolean(string="Default issue") default_issue = fields.Boolean(string="Default issue")
@ -63,7 +66,12 @@ class LoanIssue(models.Model):
) )
subscribed_amount = fields.Monetary( subscribed_amount = fields.Monetary(
string="Subscribed amount", 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", currency_field="company_currency_id",
) )
interest_payment = fields.Selection( interest_payment = fields.Selection(

2
easy_my_coop_loan/views/loan_view.xml

@ -15,6 +15,7 @@
<field name="minimum_amount"/> <field name="minimum_amount"/>
<field name="maximum_amount"/> <field name="maximum_amount"/>
<field name="subscribed_amount"/> <field name="subscribed_amount"/>
<field name="paid_amount"/>
<field name="user_id"/> <field name="user_id"/>
<field name="state"/> <field name="state"/>
</tree> </tree>
@ -73,6 +74,7 @@
<field name="minimum_amount"/> <field name="minimum_amount"/>
<field name="maximum_amount"/> <field name="maximum_amount"/>
<field name="subscribed_amount"/> <field name="subscribed_amount"/>
<field name="paid_amount"/>
<field name="by_individual"/> <field name="by_individual"/>
<field name="min_amount_person" <field name="min_amount_person"
attrs="{'invisible':[('by_individual','=',False)]}"/> attrs="{'invisible':[('by_individual','=',False)]}"/>

Loading…
Cancel
Save