Browse Source

[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
pull/134/head
houssine 4 years ago
parent
commit
aecb0e9f5c
  1. 6
      easy_my_coop_loan/__manifest__.py
  2. 26
      easy_my_coop_loan/models/interest_line.py
  3. 7
      easy_my_coop_loan/models/loan_issue_line.py
  4. 94
      easy_my_coop_loan/views/loan_interest_lines_view.xml
  5. 1
      easy_my_coop_loan/views/loan_line_view.xml
  6. 2
      easy_my_coop_loan/views/loan_view.xml

6
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",

26
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",

7
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)

94
easy_my_coop_loan/views/loan_interest_lines_view.xml

@ -0,0 +1,94 @@
<odoo>
<record id="action_loan_interest_lines" model="ir.actions.act_window">
<field name="name">Loan interest lines</field>
<field name="res_model">loan.interest.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record id="loan_interest_line_view_tree" model="ir.ui.view">
<field name="name">loan.interest.line.view.tree</field>
<field name="model">loan.interest.line</field>
<field name="arch" type="xml">
<tree string="Loan interest lines">
<field name="issue_line" invisible="True"/>
<field name="name"/>
<field name="amount"/>
<field name="accrued_amount"/>
<field name="interest"/>
<field name="accrued_interest"/>
<field name="net_interest"/>
<field name="taxes_amount"/>
<field name="due_amount"/>
<field name="due_date"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="view_loan_interest_line_form" model="ir.ui.view">
<field name="name">loan.interest.line.form</field>
<field name="model">loan.interest.line</field>
<field name="arch" type="xml">
<form string="Loan interest line">
<header>
<field name="state" widget="statusbar"/>
</header>
<sheet>
<group>
<group>
<field name="issue_line"/>
<field name="name"/>
<field name="amount"/>
<field name="accrued_amount"/>
<field name="due_amount"/>
<field name="due_date"/>
</group>
<group>
<field name="interest"/>
<field name="net_interest"/>
<field name="taxes_amount"/>
<field name="accrued_interest"/>
<field name="accrued_net_interest"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="view_loan_interest_line_filter" model="ir.ui.view">
<field name="name">Loans interest lines Search</field>
<field name="model">loan.interest.line</field>
<field name="arch" type="xml">
<search string="Search Loan interest lines">
<field name="name"/>
<field name="partner_id"/>
<field name="loan_issue_id"/>
<separator/>
<filter string="Draft" name="state_draft"
domain="[('state','=','draft')]"/>
<filter string="Due" name="state_due"
domain="[('state','=','due')]"/>
<filter string="Requested" name="state_requested"
domain="[('state','=','requested')]"/>
<filter string="Donation" name="state_donation"
domain="[('state','=','donation')]"/>
<filter string="Paid" name="state_paid"
domain="[('state','=','paid')]"/>
<group expand="0" name="group_by" string="Group By">
<filter name="loan_issue_id" string="Loan issue"
context="{'group_by' : 'loan_issue_id'}"/>
<filter name="partner_id" string="Loaner"
context="{'group_by' : 'partner_id'}"/>
<filter name="issue_line" string="Loans"
context="{'group_by' : 'issue_line'}"/>
<filter name="due_date" string="Due Date"
context="{'group_by': 'due_date'}"/>
<filter name="state" string="State"
context="{'group_by': 'state'}"/>
</group>
</search>
</field>
</record>
</odoo>

1
easy_my_coop_loan/views/loan_line_view.xml

@ -66,6 +66,7 @@
<field name="amount"/>
<field name="accrued_amount"/>
<field name="interest"/>
<field name="accrued_interest"/>
<field name="net_interest"/>
<field name="taxes_amount"/>
<field name="due_amount"/>

2
easy_my_coop_loan/views/loan_view.xml

@ -110,7 +110,7 @@
</group>
<notebook>
<page name="lines" string="Lines">
<field name="loan_issue_lines" context="{'default_loan_issue_id': id}">
<field name="loan_issue_lines" context="{'default_loan_issue_id': id}" attrs="{'readonly':[('state', '!=', 'ongoing')]}">
<tree delete="false">
<field name="name"/>
<field name="partner_id"/>

Loading…
Cancel
Save