OCA / contract

GNU Affero General Public License v3.0
170 stars 522 forks source link

Create contract not generating recurring_next_date #988

Closed BartvandenHout closed 1 month ago

BartvandenHout commented 1 year ago

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")})
                ]
            }
        )
flotho commented 8 months ago

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

github-actions[bot] commented 2 months ago

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.