Create contract not generating recurring_next_date
Module
contract
Describe the bug
On initial creation the contracts recurring_next_date is not computed resulting no invoices on cron
To Reproduce
Affected versions: 14.0
Steps to reproduce the behavior:
- create contract with contract line at start date in the past
- run cron
- no invoice
Expected behavior Invoices should be created
Additional context Possible solution: add record._compute_recurring_next_date() to _set_start_contract_modification() /models/contract.py (line 170+)
@api.model
def _set_start_contract_modification(self):
subtype_id = self.env.ref("contract.mail_message_subtype_contract_modification")
for record in self:
if record.contract_line_ids:
date_start = min(record.contract_line_ids.mapped("date_start"))
else:
date_start = record.create_date
record._compute_recurring_next_date()
record.message_subscribe(
partner_ids=[record.partner_id.id], subtype_ids=[subtype_id.id]
)
record.with_context(skip_modification_mail=True).write(
{
"modification_ids": [
(0, 0, {"date": date_start, "description": _("Contract start")})
]
}
)
Hi @BartvandenHout , any chance to have a PR as you propose a piece of code ?
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.