Skip to content

[18.0][ADD] contract_invoice_offset - #1498

Draft
anthonissen-a wants to merge 10 commits into
OCA:18.0from
acsone:18.0-contract_invoice_offset-aan
Draft

anthonissen-a wants to merge 10 commits into
OCA:18.0from
acsone:18.0-contract_invoice_offset-aan

Conversation

@anthonissen-a

@anthonissen-a anthonissen-a commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This PR proposes an improvement to #1366 by @bosd, building on top of the refactor #1497 (which updated contract.recurring.mixin date methods to use self).

Key Changes:

  • Replace overwrites with standard overrides: Utilizing self in mixin methods allows proper method overriding, improving modularity and maintainability for downstream modules.
  • Remove contract_invoice_align_start dependency: Decoupled this dependency from the core module. It should instead be handled via a glue module.
  • Layout improvements: Updated views to follow standard layout patterns used in other contract modules.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @sbejaoui, @florian-dacosta,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:18.0 mod:contract Module contract mod:contract_line_successor Module contract_line_successor mod:contract_refund_on_stop Module contract_refund_on_stop mod:contract_invoice_offset Module contract_invoice_offset mod:contract_forecast Module contract_forecast mod:contract_invoice_start_end_dates Module contract_invoice_start_end_dates mod:contract_sale_generation Module contract_sale_generation labels Aug 12, 2026
@anthonissen-a
anthonissen-a force-pushed the 18.0-contract_invoice_offset-aan branch 2 times, most recently from 8b3c45f to a31d219 Compare August 17, 2026 13:15
@anthonissen-a
anthonissen-a force-pushed the 18.0-contract_invoice_offset-aan branch from a31d219 to 6027d4e Compare August 20, 2026 14:00
Comment on lines -256 to -261
@api.depends("contract_id.line_recurrence")
def _compute_recurring_next_date(self):
res = super()._compute_recurring_next_date()
self._set_recurrence_field("recurring_next_date")
return res

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the parent contract's recurring_next_date is driven by the minimum recurring_next_date across its child lines. Why do individual contract lines need to pull or sync this value from the parent contract via _set_recurrence_field? What specific edge case or behavior does this pattern handle? I tested removing it, and no existing tests failed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sbejaoui, could you please have a look at this question?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed when setting the contract.line_recurrence field to override recurring_next_date on all lines according to the contract, nothing happens when setting it to False

Maybe there is no test covering this case, which would explain why the tests didn't fail

anthonissen-a and others added 10 commits September 8, 2026 09:47
Fix _get_period_to_invoice returning (date, False, date) instead of
(False, False, False) when get_next_period_date_end returns False for
ended contracts. The guard `if last_date_invoiced and ...` short-circuited
on False; changed to `if not last_date_invoiced or ...`.
- Name the offset units after the recurrence rule types already used in
  `contract` (daily/weekly/monthly/yearly), so the offset can be turned
  into a `relativedelta` with the existing `get_relative_delta` helper
  instead of a hand written if/elif chain.
- `get_next_invoice_date` and `get_next_period_date_end` now call
  `super()` and only apply (respectively reverse) the flexible offset,
  instead of reimplementing the base logic. This drops the duplicated
  billing cycle alignment branch, which `contract_invoice_align_start`
  already implements in its own override of the same method.
- Collect the extra keyword arguments in `_get_offset_kwargs()`, an
  extension point for modules adding their own arguments to the
  recurrence helpers.
- Say "overwrite" where the base method is replaced rather than extended.
- Cover the remaining branches with tests: header level offset, weekly
  and yearly units, next period end, empty period, line level offset
  precedence and the missing next invoice date.
@anthonissen-a
anthonissen-a force-pushed the 18.0-contract_invoice_offset-aan branch from 6027d4e to 24e923d Compare September 8, 2026 08:05
@anthonissen-a

Copy link
Copy Markdown
Contributor Author

Hi @bosd, if you are at the OCA days, we are at the contract table and would like to discuss this PR with you to try to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:contract_forecast Module contract_forecast mod:contract_invoice_offset Module contract_invoice_offset mod:contract_invoice_start_end_dates Module contract_invoice_start_end_dates mod:contract_line_successor Module contract_line_successor mod:contract_refund_on_stop Module contract_refund_on_stop mod:contract_sale_generation Module contract_sale_generation mod:contract Module contract series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants