[18.0][ADD] contract_invoice_offset - #1498
anthonissen-a wants to merge 10 commits into
Conversation
|
Hi @sbejaoui, @florian-dacosta, |
8b3c45f to
a31d219
Compare
a31d219 to
6027d4e
Compare
| @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 | ||
|
|
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.
There was a problem hiding this comment.
Hi @sbejaoui, could you please have a look at this question?
There was a problem hiding this comment.
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
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.
…_invoice_date method.
6027d4e to
24e923d
Compare
|
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. |
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: