Browse Source

[CHG] replace many2one field term by float loan term

pull/32/head
houssine 5 years ago
parent
commit
15b275a7fa
  1. 1
      easy_my_coop_loan/__manifest__.py
  2. 19
      easy_my_coop_loan/models/loan.py
  3. 4
      easy_my_coop_loan/views/loan_view.xml
  4. 1
      easy_my_coop_loan/views/menus.xml
  5. 39
      easy_my_coop_loan/views/term_view.xml

1
easy_my_coop_loan/__manifest__.py

@ -18,7 +18,6 @@
""", """,
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/term_view.xml',
'views/loan_view.xml', 'views/loan_view.xml',
'views/partner_view.xml', 'views/partner_view.xml',
'views/menus.xml', 'views/menus.xml',

19
easy_my_coop_loan/models/loan.py

@ -5,16 +5,6 @@ from odoo import api, fields, models
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class LoanTerm(models.Model):
_name = 'loan.term'
_description = 'Loan Term'
name = fields.Char(string="Name",
required=True)
term = fields.Float(string="Term",
required=True)
class LoanIssue(models.Model): class LoanIssue(models.Model):
_name = 'loan.issue' _name = 'loan.issue'
_description = 'Loan Issue' _description = 'Loan Issue'
@ -38,6 +28,7 @@ class LoanIssue(models.Model):
user_id = fields.Many2one('res.users', user_id = fields.Many2one('res.users',
string="Responsible") string="Responsible")
term_date = fields.Date(string="Term date") term_date = fields.Date(string="Term date")
loan_term = fields.Float(string="term of the loan")
rate = fields.Float(string="Interest rate") rate = fields.Float(string="Interest rate")
face_value = fields.Monetary(string="Facial value", face_value = fields.Monetary(string="Facial value",
currency_field='company_currency_id', currency_field='company_currency_id',
@ -55,8 +46,6 @@ class LoanIssue(models.Model):
interest_payment = fields.Selection([('end', 'End'), interest_payment = fields.Selection([('end', 'End'),
('yearly', 'Yearly')], ('yearly', 'Yearly')],
string="Interest payment") string="Interest payment")
term = fields.Many2one('loan.term',
string="term of the loan")
loan_issue_lines = fields.One2many('loan.issue.line', loan_issue_lines = fields.One2many('loan.issue.line',
'loan_issue_id', 'loan_issue_id',
string="Loan issue lines") string="Loan issue lines")
@ -148,7 +137,7 @@ class LoanIssue(models.Model):
accrued_interest = 0 accrued_interest = 0
accrued_net_interest = 0 accrued_net_interest = 0
accrued_taxes = 0 accrued_taxes = 0
for year in range(1, int(self.term.term) + 1):
for year in range(1, int(self.loan_term) + 1):
interest = accrued_amount * (line.loan_issue_id.rate / 100) interest = accrued_amount * (line.loan_issue_id.rate / 100)
accrued_amount += interest accrued_amount += interest
taxes_amount = interest * (self.taxes_rate / 100) taxes_amount = interest * (self.taxes_rate / 100)
@ -183,7 +172,7 @@ class LoanIssue(models.Model):
} }
self.get_interest_vals(line, vals) self.get_interest_vals(line, vals)
rounded_term = int(self.term.term)
if self.term.term - rounded_term > 0:
rounded_term = int(self.loan_term)
if self.loan_term - rounded_term > 0:
# TODO Handle this case # TODO Handle this case
_logger.info("todo") _logger.info("todo")

4
easy_my_coop_loan/views/loan_view.xml

@ -9,7 +9,7 @@
<field name="subscription_start_date" /> <field name="subscription_start_date" />
<field name="subscription_end_date" /> <field name="subscription_end_date" />
<field name="term_date" /> <field name="term_date" />
<field name="term" />
<field name="loan_term" />
<field name="rate" /> <field name="rate" />
<field name="minimum_amount" /> <field name="minimum_amount" />
<field name="maximum_amount" /> <field name="maximum_amount" />
@ -73,7 +73,7 @@
<field name="subscription_start_date" /> <field name="subscription_start_date" />
<field name="subscription_end_date" /> <field name="subscription_end_date" />
<field name="term_date" /> <field name="term_date" />
<field name="term" widget="selection"/>
<field name="loan_term" />
<field name="interest_payment" widget="selection" /> <field name="interest_payment" widget="selection" />
</group> </group>
</group> </group>

1
easy_my_coop_loan/views/menus.xml

@ -10,5 +10,4 @@
<menuitem name="Loaners" id="loaners_menu" action="action_loaners" parent="easy_my_coop.menu_easy_my_coop_main_coop" sequence="215" /> <menuitem name="Loaners" id="loaners_menu" action="action_loaners" parent="easy_my_coop.menu_easy_my_coop_main_coop" sequence="215" />
<menuitem name="Loan Term" id="loan_term_menu" action="action_loan_term" parent="easy_my_coop.menu_easy_my_coop_config" sequence="420"/>
</odoo> </odoo>

39
easy_my_coop_loan/views/term_view.xml

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_loan_term_tree" model="ir.ui.view">
<field name="name">loan.term.tree</field>
<field name="model">loan.term</field>
<field name="arch" type="xml">
<tree string="Loan terms">
<field name="name" />
<field name="term" />
</tree>
</field>
</record>
<record id="view_loan_term_form" model="ir.ui.view">
<field name="name">loan.term.form</field>
<field name="model">loan.term</field>
<field name="arch" type="xml">
<form string="Loan terms">
<group>
<group>
<field name="name" />
</group>
<group>
<field name="term" />
</group>
</group>
</form>
</field>
</record>
<record id="action_loan_term" model="ir.actions.act_window">
<field name="name">Loan term</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">loan.term</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>
Loading…
Cancel
Save