From 74d7f4202fc84c953bf9a505bdf42fb6f5ea8e4e Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Fri, 20 Dec 2019 14:14:20 +0100 Subject: [PATCH] [IMP] - improve code: unify methods argument _renew_create_line and _renew_extend_line --- contract/models/contract_line.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index 502b9321..8104b65e 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -1156,17 +1156,18 @@ class ContractLine(models.Model): } @api.multi - def _get_renewal_dates(self): + def _get_renewal_new_date_end(self): self.ensure_one() date_start = self.date_end + relativedelta(days=1) date_end = self._get_first_date_end( date_start, self.auto_renew_rule_type, self.auto_renew_interval ) - return date_start, date_end + return date_end @api.multi - def _renew_create_line(self, date_start, date_end): + def _renew_create_line(self, date_end): self.ensure_one() + date_start = self.date_end + relativedelta(days=1) is_auto_renew = self.is_auto_renew self.stop(self.date_end, post_message=False) new_line = self.plan_successor( @@ -1186,9 +1187,10 @@ class ContractLine(models.Model): res = self.env['contract.line'] for rec in self: company = rec.contract_id.company_id - date_start, date_end = rec._get_renewal_dates() + date_end = rec._get_renewal_new_date_end() + date_start = rec.date_end + relativedelta(days=1) if company.create_new_line_at_contract_line_renew: - new_line = rec._renew_create_line(date_start, date_end) + new_line = rec._renew_create_line(date_end) else: new_line = rec._renew_extend_line(date_end) res |= new_line