Skip to content

[19.0][ADD] contract_invoice_offset - #1366

Open
bosd wants to merge 5 commits into
OCA:19.0from
bosd:19.0-add-contract_invoice_offset
Open

[19.0][ADD] contract_invoice_offset#1366
bosd wants to merge 5 commits into
OCA:19.0from
bosd:19.0-add-contract_invoice_offset

Conversation

@bosd

@bosd bosd commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

depends on #1372 and #1365

(#1312 and #1364 are merged.)

@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from 4dc2053 to 00d86c8 Compare December 29, 2025 21:45
@bosd
bosd marked this pull request as ready for review December 30, 2025 09:31
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from 8b9a854 to 8c8b9c7 Compare December 30, 2025 11:18
@bosd bosd changed the title [19.0] add contract_invoice_offset [19.0][ADD] contract_invoice_offset Dec 30, 2025
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch 7 times, most recently from e6f8429 to 65eeb15 Compare December 30, 2025 17:39
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from a9fc61a to 731c908 Compare January 23, 2026 21:20
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch 5 times, most recently from ab08faa to 6348343 Compare February 13, 2026 17:02
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch 5 times, most recently from 778a5bd to 114f847 Compare February 21, 2026 13:31
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from 114f847 to 0fa76e3 Compare May 12, 2026 20:54
@OCA-git-bot OCA-git-bot added series:19.0 mod:contract_invoice_offset Module contract_invoice_offset labels May 12, 2026
bosd added 2 commits June 11, 2026 08: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 ...`.
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from 0fa76e3 to 3fb11cc Compare June 11, 2026 06:47

@anthonissen-a anthonissen-a left a comment

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.

Very useful module! My main concern is compatibility with other modules, given the number of overwrites.

Comment thread contract_invoice_offset/models/contract_recurring_mixin.py
Comment thread contract_invoice_offset/models/contract.py Outdated
"license": "AGPL-3",
"depends": [
"contract",
"contract_invoice_align_start",

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.

IMO this dependency should be removed to be more generic.

@bosd bosd Sep 4, 2026

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.

Done — contract_invoice_align_start is off the depends list, and the align_billing_cycle plumbing (the _get_offset_kwargs() entry and the api.depends on it) is gone with it. _get_offset_kwargs() stays as the extension point, so a glue module can add the alignment back for installations that want both.

Side effect: this was the last unmerged dependency in the chain (it pulled in contract_variable_qty_prorated too), so the [DO NOT MERGE] commit with the test-requirements.txt pins is dropped and the PR only needs contract now.

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.

Reopening this one — I tried it and had to back it out.

Dropping contract_invoice_align_start from depends is not just a manifest change: align_billing_cycle is that module the offset chain currently rides on. Without it installed, the contract falls back to min(line.recurring_next_date) and the line-level pre-paid/post-paid values win over the contract-level ones, so test_postpaid_delayed_one_month and test_days_fallback both shift by a full period. The offset behaviour is deliberately crafted here, so I would rather not change it as a side effect of a dependency cleanup.

Happy to make it generic, but it needs to be its own piece of work: the alignment kwarg has to move out of _get_offset_kwargs() and into a glue module with tests covering both the with- and without-alignment cases. Do you want that as a follow-up PR, or folded into the refactor you are doing in #1498?

@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from 3fb11cc to 6caf79f Compare August 4, 2026 14:53
- 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.
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from 6caf79f to b1c6fc1 Compare August 4, 2026 15:46
@anthonissen-a

Copy link
Copy Markdown
Contributor

Hey @bosd, I suggest some improvements in #1498. Do you agree with my commits ?

@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch 4 times, most recently from cda53eb to b1c6fc1 Compare September 4, 2026 11:02
bosd added 2 commits September 4, 2026 13:30
`contract` leaves `line_recurrence` False by default, which makes a line
take its recurrence settings from the contract header. The tests relied on
that default to check that a header level offset reaches the lines.

`contract_line_successor`, split out of `contract` and merged since,
redefines the field with `default=True`. Installed alongside, it flips the
default, the lines keep their own pre-paid settings and
`test_postpaid_delayed_one_month` and `test_days_fallback` shift by a full
period.

Set `line_recurrence` explicitly in the fixture so the tests state the
configuration they exercise instead of depending on which sibling modules
happen to be installed. No behaviour change in the module itself.
@bosd
bosd force-pushed the 19.0-add-contract_invoice_offset branch from b1c6fc1 to 4035deb Compare September 4, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:contract_invoice_offset Module contract_invoice_offset series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants