mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[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:
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Recurring - Contracts Management",
|
"name": "Recurring - Contracts Management",
|
||||||
"version": "14.0.1.0.0",
|
"version": "14.0.1.0.1",
|
||||||
"category": "Contract Management",
|
"category": "Contract Management",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)",
|
"author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)",
|
||||||
|
|||||||
@@ -117,9 +117,10 @@ class ContractLine(models.Model):
|
|||||||
)
|
)
|
||||||
def _compute_next_period_date_start(self):
|
def _compute_next_period_date_start(self):
|
||||||
"""Rectify next period date start if another line in the contract has been
|
"""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
|
lines = rec.contract_id.contract_line_ids
|
||||||
if not rec.last_date_invoiced and any(lines.mapped("last_date_invoiced")):
|
if not rec.last_date_invoiced and any(lines.mapped("last_date_invoiced")):
|
||||||
next_period_date_start = max(
|
next_period_date_start = max(
|
||||||
@@ -129,7 +130,8 @@ class ContractLine(models.Model):
|
|||||||
next_period_date_start = False
|
next_period_date_start = False
|
||||||
rec.next_period_date_start = next_period_date_start
|
rec.next_period_date_start = next_period_date_start
|
||||||
else:
|
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")
|
@api.depends("contract_id.date_end", "contract_id.line_recurrence")
|
||||||
def _compute_date_end(self):
|
def _compute_date_end(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user