diff --git a/models/hr_employee_loans.py b/models/hr_employee_loans.py index e10f1c66ffb42c1798366748f665ee5df3fe357d..d3b04a2214ec911cfe51e84dbe139034a63f38a0 100644 --- a/models/hr_employee_loans.py +++ b/models/hr_employee_loans.py @@ -31,7 +31,6 @@ class HREmployeeLoans(models.Model): readonly=True, states={'draft': [('readonly', False)]}) balance_loan = fields.Monetary('Loan Balance', compute='_balance_loan', currency_field='currency_id', store=True, readonly=True) - dues_month = fields.Date() state = fields.Selection([ ('draft', 'Draft'), ('approve', 'Approve'), @@ -135,10 +134,23 @@ class HREmployeeLoans(models.Model): return self.write({'state': 'approve'}) return self.write({'state': 'in_progress'}) + @api.multi + def _update_lines(self): + # print("HEEEEEEEEELLLLLLLLOOOOOOOOOOOOO", self) + for loan in self.env["hr.employee.loans"].search([]): + date_from = loan.start_month + for line in loan.employee_loan_ids: + if not line.dues_month: + line.write({ + 'dues_month': date_from, + }) + date_from += relativedelta(months=1) + return + @api.multi def set_paused(self): return self.write({'state': 'paused'}) - + @api.multi def manager_approve(self): return self.write({'state': 'in_progress'}) diff --git a/views/hr_employee_loans_view.xml b/views/hr_employee_loans_view.xml index c743b377fa9ec9da54c6d2c4a689688513cdf978..4449e8bb93db0a019341093acef2a1a0c44c3c29 100644 --- a/views/hr_employee_loans_view.xml +++ b/views/hr_employee_loans_view.xml @@ -35,7 +35,6 @@ <sheet> <group> <group> - <field name="dues_month" invisible="True"/> <field name="employee_id"/> <field name="loan_reason"/> <field name="loan_date"/>