contract icon indicating copy to clipboard operation
contract copied to clipboard

Create contract not generating recurring_next_date

Open BartvandenHout opened this issue 2 years ago • 1 comments

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:

  1. create contract with contract line at start date in the past
  2. run cron
  3. 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")})
                ]
            }
        )

BartvandenHout avatar Sep 14 '23 06:09 BartvandenHout

Hi @BartvandenHout , any chance to have a PR as you propose a piece of code ?

flotho avatar Jan 26 '24 09:01 flotho

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.

github-actions[bot] avatar Jul 28 '24 12:07 github-actions[bot]