From 296c4e683be0b02625732312eadbcd3fe3446179 Mon Sep 17 00:00:00 2001 From: houssine Date: Fri, 18 Dec 2020 21:48:18 +0100 Subject: [PATCH] [IMP] add field and do a write on the recordset instead of the loop --- .../models/interest_line.py | 3 +-- .../wizard/end_of_year_operation.py | 16 +++++++++++++++- .../wizard/end_of_year_operation.xml | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/easy_my_coop_loan_account/models/interest_line.py b/easy_my_coop_loan_account/models/interest_line.py index 2b2227e..25ee1eb 100644 --- a/easy_my_coop_loan_account/models/interest_line.py +++ b/easy_my_coop_loan_account/models/interest_line.py @@ -87,8 +87,7 @@ class LoanInterestLine(models.Model): self.env["account.move.line"].create(vals_list) - line.write({"loan_reimbursment_move": move.id, - "state": "scheduled"}) + line.write({"loan_reimbursment_move": move.id}) @api.multi def generate_interest_move_lines_fy(self, date, next_fy): diff --git a/easy_my_coop_loan_account/wizard/end_of_year_operation.py b/easy_my_coop_loan_account/wizard/end_of_year_operation.py index 23b2ea5..4b542bb 100644 --- a/easy_my_coop_loan_account/wizard/end_of_year_operation.py +++ b/easy_my_coop_loan_account/wizard/end_of_year_operation.py @@ -19,6 +19,9 @@ class LoanEndOfYearOperation(models.TransientModel): string="Ongoing fiscal year", required=True ) + due_date = fields.Date( + string="Due date" + ) @api.multi def run(self): @@ -55,9 +58,20 @@ class LoanEndOfYearOperation(models.TransientModel): interest_lines.generate_interest_move_lines_fy(last_fy_day, next_fy) +# interest_lines.write({"state": "scheduled"}) +# interest_lines_loan.write({"state": "scheduled"}) + (interest_lines + interest_lines_loan).write({"state": + "scheduled"}) if not interest_lines_loan and not interest_lines: raise UserError("There is no end of year account move" " lines to generate for the selected loan" " issue") elif self.ongoing_fy_id == "loan_due": - print("lol") + interest_lines = interest_line_obj.search([ + ("due_date", ">=", next_fy.date_from), + ("due_date", "<=", next_fy.date_to), + ("interest", ">", 0), + ("loan_issue_id", "in", loan_issues.ids), + ("interest_closing_fy", "=", False), + ("interest_opening_fy", "=", False) + ]) diff --git a/easy_my_coop_loan_account/wizard/end_of_year_operation.xml b/easy_my_coop_loan_account/wizard/end_of_year_operation.xml index d64dda1..f705071 100644 --- a/easy_my_coop_loan_account/wizard/end_of_year_operation.xml +++ b/easy_my_coop_loan_account/wizard/end_of_year_operation.xml @@ -10,6 +10,7 @@

+