From 15b275a7fa71a4e6635c9e2ed5fe592d73ec923e Mon Sep 17 00:00:00 2001 From: houssine Date: Tue, 29 Oct 2019 12:55:40 +0100 Subject: [PATCH] [CHG] replace many2one field term by float loan term --- easy_my_coop_loan/__manifest__.py | 1 - easy_my_coop_loan/models/loan.py | 19 +++---------- easy_my_coop_loan/views/loan_view.xml | 4 +-- easy_my_coop_loan/views/menus.xml | 1 - easy_my_coop_loan/views/term_view.xml | 39 --------------------------- 5 files changed, 6 insertions(+), 58 deletions(-) delete mode 100644 easy_my_coop_loan/views/term_view.xml diff --git a/easy_my_coop_loan/__manifest__.py b/easy_my_coop_loan/__manifest__.py index 92dc59e..60b4386 100644 --- a/easy_my_coop_loan/__manifest__.py +++ b/easy_my_coop_loan/__manifest__.py @@ -18,7 +18,6 @@ """, 'data': [ 'security/ir.model.access.csv', - 'views/term_view.xml', 'views/loan_view.xml', 'views/partner_view.xml', 'views/menus.xml', diff --git a/easy_my_coop_loan/models/loan.py b/easy_my_coop_loan/models/loan.py index 74789ec..f4dc675 100644 --- a/easy_my_coop_loan/models/loan.py +++ b/easy_my_coop_loan/models/loan.py @@ -5,16 +5,6 @@ from odoo import api, fields, models _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): _name = 'loan.issue' _description = 'Loan Issue' @@ -38,6 +28,7 @@ class LoanIssue(models.Model): user_id = fields.Many2one('res.users', string="Responsible") term_date = fields.Date(string="Term date") + loan_term = fields.Float(string="term of the loan") rate = fields.Float(string="Interest rate") face_value = fields.Monetary(string="Facial value", currency_field='company_currency_id', @@ -55,8 +46,6 @@ class LoanIssue(models.Model): interest_payment = fields.Selection([('end', 'End'), ('yearly', 'Yearly')], string="Interest payment") - term = fields.Many2one('loan.term', - string="term of the loan") loan_issue_lines = fields.One2many('loan.issue.line', 'loan_issue_id', string="Loan issue lines") @@ -148,7 +137,7 @@ class LoanIssue(models.Model): accrued_interest = 0 accrued_net_interest = 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) accrued_amount += interest taxes_amount = interest * (self.taxes_rate / 100) @@ -183,7 +172,7 @@ class LoanIssue(models.Model): } 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 _logger.info("todo") diff --git a/easy_my_coop_loan/views/loan_view.xml b/easy_my_coop_loan/views/loan_view.xml index 0dd8860..d90f499 100644 --- a/easy_my_coop_loan/views/loan_view.xml +++ b/easy_my_coop_loan/views/loan_view.xml @@ -9,7 +9,7 @@ - + @@ -73,7 +73,7 @@ - + diff --git a/easy_my_coop_loan/views/menus.xml b/easy_my_coop_loan/views/menus.xml index 91d6dc3..393af17 100644 --- a/easy_my_coop_loan/views/menus.xml +++ b/easy_my_coop_loan/views/menus.xml @@ -10,5 +10,4 @@ - diff --git a/easy_my_coop_loan/views/term_view.xml b/easy_my_coop_loan/views/term_view.xml deleted file mode 100644 index 2352fd4..0000000 --- a/easy_my_coop_loan/views/term_view.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - loan.term.tree - loan.term - - - - - - - - - - loan.term.form - loan.term - -
- - - - - - - - -
-
-
- - - Loan term - ir.actions.act_window - loan.term - form - tree,form - - -