[18.0][ADD] contract_invoice_offset - #1498
Draft
anthonissen-a wants to merge 10 commits into
Draft
Conversation
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.
Contributor
|
Hi @sbejaoui, @florian-dacosta, |
anthonissen-a
force-pushed
the
18.0-contract_invoice_offset-aan
branch
2 times, most recently
from
August 17, 2026 13:15
8b3c45f to
a31d219
Compare
…_invoice_date method.
anthonissen-a
force-pushed
the
18.0-contract_invoice_offset-aan
branch
from
August 20, 2026 14:00
a31d219 to
6027d4e
Compare
anthonissen-a
commented
Aug 21, 2026
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 | ||
|
|
Contributor
Author
There was a problem hiding this comment.
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.
Contributor
There was a problem hiding this comment.
Hi @sbejaoui, could you please have a look at this question?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: