Browse Source

[IMP] add sequence for loan issue line and call sequence on validation

pull/134/head
houssine 4 years ago
parent
commit
68c04248a7
  1. 1
      easy_my_coop_loan/__manifest__.py
  2. 12
      easy_my_coop_loan/data/loan_data.xml
  3. 12
      easy_my_coop_loan/models/loan_issue_line.py
  4. 2
      easy_my_coop_loan/views/loan_line_view.xml

1
easy_my_coop_loan/__manifest__.py

@ -24,6 +24,7 @@
"report/loan_issue_line_report.xml",
"report/loan_report.xml",
"data/mail_template_data.xml",
"data/loan_data.xml"
],
"demo": [
"demo/coop.xml"

12
easy_my_coop_loan/data/loan_data.xml

@ -0,0 +1,12 @@
<odoo noupdate="1">
<record id="sequence_loan_issue_line" model="ir.sequence">
<field name="name">Loan issue line</field>
<field name="code">loan.issue.line.sequence</field>
<field name="prefix">LOAN/%(year)s/</field>
<field eval="1" name="number_next"/>
<field eval="1" name="number_increment"/>
<field eval="True" name="use_date_range"/>
<field eval="False" name="company_id"/>
<field name="padding">4</field>
</record>
</odoo>

12
easy_my_coop_loan/models/loan_issue_line.py

@ -21,7 +21,8 @@ class LoanIssueLine(models.Model):
line.amount = line.face_value * line.quantity
name = fields.Char(
String="Name"
String="Name",
readonly=True,
)
reference = fields.Char(
string="Reference",
@ -112,8 +113,13 @@ class LoanIssueLine(models.Model):
@api.multi
def action_validate(self):
sequence_id = self.env.ref(
"easy_my_coop_loan.sequence_loan_issue_line",
False
)
for line in self:
line.write({"state": "subscribed"})
loan_line_num = sequence_id.next_by_id()
line.write({"name": loan_line_num, "state": "subscribed"})
@api.multi
def action_request_payment(self):
@ -202,7 +208,7 @@ class LoanIssueLine(models.Model):
days = self.get_number_of_days(line.payment_date.year)
interim_amount = line.amount * rate * (diff_days / days)
due_date = start_date + relativedelta(years=+loan_term)
due_date = start_date + relativedelta(years=loan_term)
for year in range(1, loan_term + 1):
interest = accrued_amount * rate

2
easy_my_coop_loan/views/loan_line_view.xml

@ -11,6 +11,7 @@
<field name="model">loan.issue.line</field>
<field name="arch" type="xml">
<tree string="Loans">
<field name="name"/>
<field name="partner_id"/>
<field name="loan_issue_id"/>
<field name="quantity"/>
@ -48,6 +49,7 @@
<sheet>
<group>
<group>
<field name="name"/>
<field name="partner_id"/>
<field name="loan_issue_id"/>
<field name="quantity"/>

Loading…
Cancel
Save