mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX+IMP] contract: Several things
- Don't update recurring_next_date as computed - Compute recurring_next_date for False values too + simplify compute as False values are already taken into account In get_next_invoice_date, False values are already taken into account, so, simplifying compute_recurring_next_date function. - Add comment to remind updating method in next version
This commit is contained in:
committed by
Christopher Rogos
parent
09be01e5f8
commit
88ddff2ebc
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Recurring - Contracts Management",
|
"name": "Recurring - Contracts Management",
|
||||||
"version": "15.0.1.1.1",
|
"version": "15.0.1.2.0",
|
||||||
"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)",
|
||||||
|
|||||||
@@ -605,19 +605,12 @@ class ContractLine(models.Model):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
def _update_recurring_next_date(self):
|
def _update_recurring_next_date(self):
|
||||||
|
# FIXME: Change method name according to real updated field
|
||||||
|
# e.g.: _update_last_date_invoiced()
|
||||||
for rec in self:
|
for rec in self:
|
||||||
last_date_invoiced = rec.next_period_date_end
|
last_date_invoiced = rec.next_period_date_end
|
||||||
recurring_next_date = rec.get_next_invoice_date(
|
|
||||||
last_date_invoiced + relativedelta(days=1),
|
|
||||||
rec.recurring_invoicing_type,
|
|
||||||
rec.recurring_invoicing_offset,
|
|
||||||
rec.recurring_rule_type,
|
|
||||||
rec.recurring_interval,
|
|
||||||
max_date_end=rec.date_end,
|
|
||||||
)
|
|
||||||
rec.write(
|
rec.write(
|
||||||
{
|
{
|
||||||
"recurring_next_date": recurring_next_date,
|
|
||||||
"last_date_invoiced": last_date_invoiced,
|
"last_date_invoiced": last_date_invoiced,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -689,16 +682,19 @@ class ContractLine(models.Model):
|
|||||||
rec._prepare_value_for_stop(date_end, manual_renew_needed)
|
rec._prepare_value_for_stop(date_end, manual_renew_needed)
|
||||||
)
|
)
|
||||||
if post_message:
|
if post_message:
|
||||||
msg = _(
|
msg = (
|
||||||
"""Contract line for <strong>%(product)s</strong>
|
_(
|
||||||
|
"""Contract line for <strong>%(product)s</strong>
|
||||||
stopped: <br/>
|
stopped: <br/>
|
||||||
- <strong>End</strong>: %(old_end)s -- %(new_end)s
|
- <strong>End</strong>: %(old_end)s -- %(new_end)s
|
||||||
"""
|
"""
|
||||||
) % {
|
)
|
||||||
"product": rec.name,
|
% {
|
||||||
"old_end": old_date_end,
|
"product": rec.name,
|
||||||
"new_end": rec.date_end,
|
"old_end": old_date_end,
|
||||||
}
|
"new_end": rec.date_end,
|
||||||
|
}
|
||||||
|
)
|
||||||
rec.contract_id.message_post(body=msg)
|
rec.contract_id.message_post(body=msg)
|
||||||
else:
|
else:
|
||||||
rec.write(
|
rec.write(
|
||||||
@@ -763,18 +759,21 @@ class ContractLine(models.Model):
|
|||||||
rec.successor_contract_line_id = new_line
|
rec.successor_contract_line_id = new_line
|
||||||
contract_line |= new_line
|
contract_line |= new_line
|
||||||
if post_message:
|
if post_message:
|
||||||
msg = _(
|
msg = (
|
||||||
"""Contract line for <strong>%(product)s</strong>
|
_(
|
||||||
|
"""Contract line for <strong>%(product)s</strong>
|
||||||
planned a successor: <br/>
|
planned a successor: <br/>
|
||||||
- <strong>Start</strong>: %(new_date_start)s
|
- <strong>Start</strong>: %(new_date_start)s
|
||||||
<br/>
|
<br/>
|
||||||
- <strong>End</strong>: %(new_date_end)s
|
- <strong>End</strong>: %(new_date_end)s
|
||||||
"""
|
"""
|
||||||
) % {
|
)
|
||||||
"product": rec.name,
|
% {
|
||||||
"new_date_start": new_line.date_start,
|
"product": rec.name,
|
||||||
"new_date_end": new_line.date_end,
|
"new_date_start": new_line.date_start,
|
||||||
}
|
"new_date_end": new_line.date_end,
|
||||||
|
}
|
||||||
|
)
|
||||||
rec.contract_id.message_post(body=msg)
|
rec.contract_id.message_post(body=msg)
|
||||||
return contract_line
|
return contract_line
|
||||||
|
|
||||||
@@ -866,18 +865,21 @@ class ContractLine(models.Model):
|
|||||||
is_auto_renew,
|
is_auto_renew,
|
||||||
post_message=False,
|
post_message=False,
|
||||||
)
|
)
|
||||||
msg = _(
|
msg = (
|
||||||
"""Contract line for <strong>%(product)s</strong>
|
_(
|
||||||
|
"""Contract line for <strong>%(product)s</strong>
|
||||||
suspended: <br/>
|
suspended: <br/>
|
||||||
- <strong>Suspension Start</strong>: %(new_date_start)s
|
- <strong>Suspension Start</strong>: %(new_date_start)s
|
||||||
<br/>
|
<br/>
|
||||||
- <strong>Suspension End</strong>: %(new_date_end)s
|
- <strong>Suspension End</strong>: %(new_date_end)s
|
||||||
"""
|
"""
|
||||||
) % {
|
)
|
||||||
"product": rec.name,
|
% {
|
||||||
"new_date_start": date_start,
|
"product": rec.name,
|
||||||
"new_date_end": date_end,
|
"new_date_start": date_start,
|
||||||
}
|
"new_date_end": date_end,
|
||||||
|
}
|
||||||
|
)
|
||||||
rec.contract_id.message_post(body=msg)
|
rec.contract_id.message_post(body=msg)
|
||||||
return contract_line
|
return contract_line
|
||||||
|
|
||||||
@@ -1035,18 +1037,21 @@ class ContractLine(models.Model):
|
|||||||
else:
|
else:
|
||||||
new_line = rec._renew_extend_line(date_end)
|
new_line = rec._renew_extend_line(date_end)
|
||||||
res |= new_line
|
res |= new_line
|
||||||
msg = _(
|
msg = (
|
||||||
"""Contract line for <strong>%(product)s</strong>
|
_(
|
||||||
|
"""Contract line for <strong>%(product)s</strong>
|
||||||
renewed: <br/>
|
renewed: <br/>
|
||||||
- <strong>Start</strong>: %(new_date_start)s
|
- <strong>Start</strong>: %(new_date_start)s
|
||||||
<br/>
|
<br/>
|
||||||
- <strong>End</strong>: %(new_date_end)s
|
- <strong>End</strong>: %(new_date_end)s
|
||||||
"""
|
"""
|
||||||
) % {
|
)
|
||||||
"product": rec.name,
|
% {
|
||||||
"new_date_start": date_start,
|
"product": rec.name,
|
||||||
"new_date_end": date_end,
|
"new_date_start": date_start,
|
||||||
}
|
"new_date_end": date_end,
|
||||||
|
}
|
||||||
|
)
|
||||||
rec.contract_id.message_post(body=msg)
|
rec.contract_id.message_post(body=msg)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class ContractRecurrencyMixin(models.AbstractModel):
|
|||||||
|
|
||||||
@api.depends("next_period_date_start")
|
@api.depends("next_period_date_start")
|
||||||
def _compute_recurring_next_date(self):
|
def _compute_recurring_next_date(self):
|
||||||
for rec in self.filtered("next_period_date_start"):
|
for rec in self:
|
||||||
rec.recurring_next_date = self.get_next_invoice_date(
|
rec.recurring_next_date = self.get_next_invoice_date(
|
||||||
rec.next_period_date_start,
|
rec.next_period_date_start,
|
||||||
rec.recurring_invoicing_type,
|
rec.recurring_invoicing_type,
|
||||||
|
|||||||
Reference in New Issue
Block a user