[FIX] contract: Don't change period start date having line recurrence

Fine-tuning of cd086ddbb4. We shouldn't do
this adjustment if the line recurrence is set, as if so, there's no
possibility of adding post-paid lines with proper dates on a running
contract.
This commit is contained in:
Pedro M. Baeza
2021-05-18 20:55:47 +02:00
parent a383764aea
commit 2ab1037a19
2 changed files with 6 additions and 4 deletions

View File

@@ -11,7 +11,7 @@
{
"name": "Recurring - Contracts Management",
"version": "14.0.1.0.0",
"version": "14.0.1.0.1",
"category": "Contract Management",
"license": "AGPL-3",
"author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)",

View File

@@ -117,9 +117,10 @@ class ContractLine(models.Model):
)
def _compute_next_period_date_start(self):
"""Rectify next period date start if another line in the contract has been
already invoiced previously.
already invoiced previously when the recurrence is by contract.
"""
for rec in self:
rest = self.filtered(lambda x: x.contract_id.line_recurrence)
for rec in self - rest:
lines = rec.contract_id.contract_line_ids
if not rec.last_date_invoiced and any(lines.mapped("last_date_invoiced")):
next_period_date_start = max(
@@ -129,7 +130,8 @@ class ContractLine(models.Model):
next_period_date_start = False
rec.next_period_date_start = next_period_date_start
else:
super(ContractLine, rec)._compute_next_period_date_start()
rest |= rec
super(ContractLine, rest)._compute_next_period_date_start()
@api.depends("contract_id.date_end", "contract_id.line_recurrence")
def _compute_date_end(self):