Skip to content

T3284 - remove recurring invoicer object#2110

Open
danpa32 wants to merge 4 commits into
18.0from
T3284-Remove-recurring-invoicer-object
Open

T3284 - remove recurring invoicer object#2110
danpa32 wants to merge 4 commits into
18.0from
T3284-Remove-recurring-invoicer-object

Conversation

@danpa32

@danpa32 danpa32 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The invoice generation code is complex. We historically use a recurring.invoicer model that keeps the history of generated invoices but this has no real benefit to our users and can be safely removed. It will also simplify the code and the database inprint.

See other PR related to it

Module 1 — recurring_contract (compassion-accounting)

The invoicer wizard and its menu were replaced by a server action. Verification:

  • Accounting → Contracts → Launch invoices generation (menu item): opens and runs without error — this now calls generate_from_cron() directly instead of the old wizard
  • Contract Group form → "Generate invoices" stat button: triggers job and generates invoices correctly
  • Confirm there is no "Generated invoices" menu anymore (the old invoicer list view was removed)

Module 2 — sponsorship_compassion (compassion-modules)

The invoicer was removed from _generate_invoices and _generate_gifts. Test from a Sponsorships → Sponsorships (S, SC, or SWP contract):

Contract Group form → "Generate invoices" button: invoices generate correctly AND birthday/Christmas gift invoices are still generated alongside regular invoices

Module 3 — sponsorship_switzerland (compassion-switzerland)

  • _build_invoice_gen_data override no longer receives the invoicer param. This is called during invoice line construction for Swiss-specific data. Test on a Swiss sponsorship contract:
  • Contract Group form → "Generate invoices" button: verify the generated invoices have correct Swiss-specific data (payment reference, bank details, etc.)

danpa32 and others added 3 commits July 1, 2026 13:47
Remove menu item, ACL row, PO translations, and code that passed the
invoicer object through _generate_gifts and generate_gift_wizard.
The invoicer parameter is no longer needed now that recurring.invoicer
is removed from compassion-accounting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…wizard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@danpa32 danpa32 requested review from NoeBerdoz and ecino July 2, 2026 10:58

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request simplifies the gift generation process by removing the recurring.invoicer model and its associated parameters, views, security rules, and translations across the codebase. Feedback on these changes highlights two main improvements: first, the overridden _generate_invoices method in contract_group.py should return the result of the super() call to prevent returning None implicitly; second, the final log message in contracts.py should use gift_type.name instead of gift_type to avoid printing the raw Odoo recordset representation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +36 to 48
def _generate_invoices(self):
# Exclude gifts from regular generation
invoicer = super(
super(
ContractGroup, self.with_context(open_invoices_sponsorship_only=True)
)._generate_invoices(invoicer_id)
)._generate_invoices()
contracts = self.active_contract_ids
if contracts:
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_birthday")
self.env.ref("sponsorship_compassion.gift_type_birthday")
)
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_christmas")
self.env.ref("sponsorship_compassion.gift_type_christmas")
)

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.

high

The _generate_invoices method overrides the parent method but does not return its result. If other modules or callers expect a return value (such as the generated invoices or a boolean), this implicit None return could cause issues. It is safer to capture and return the result of the super() call.

Suggested change
def _generate_invoices(self):
# Exclude gifts from regular generation
invoicer = super(
super(
ContractGroup, self.with_context(open_invoices_sponsorship_only=True)
)._generate_invoices(invoicer_id)
)._generate_invoices()
contracts = self.active_contract_ids
if contracts:
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_birthday")
self.env.ref("sponsorship_compassion.gift_type_birthday")
)
contracts._generate_gifts(
invoicer, self.env.ref("sponsorship_compassion.gift_type_christmas")
self.env.ref("sponsorship_compassion.gift_type_christmas")
)
def _generate_invoices(self):
# Exclude gifts from regular generation
res = super(
ContractGroup, self.with_context(open_invoices_sponsorship_only=True)
)._generate_invoices()
contracts = self.active_contract_ids
if contracts:
contracts._generate_gifts(
self.env.ref("sponsorship_compassion.gift_type_birthday")
)
contracts._generate_gifts(
self.env.ref("sponsorship_compassion.gift_type_christmas")
)
return res

gift_wizard.generate_invoice(due_date=due_dates[contract])
count += 1

logger.debug(f"Automatic {gift_type} Generation Finished !!")

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.

medium

The log message uses {gift_type} directly, which will print the Odoo recordset representation (e.g., sponsorship.gift.type(1,)) instead of its name. Use {gift_type.name} to be consistent with the start log message on line 1044.

Suggested change
logger.debug(f"Automatic {gift_type} Generation Finished !!")
logger.debug(f"Automatic {gift_type.name} Generation Finished !!")

@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge with minimal risk.

The changes are scoped to removing the obsolete invoicer object from call signatures, context passing, menus, access rules, and translations. The reviewed invoice and gift generation paths remain consistent with the updated direct generation flow. No functional or security issues were identified.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • Compared the base and head code paths to confirm changes in invoicer handling and the _generate_gifts signature, and noted that regular_invoice_count remains 1 while gift_generation_call_count remains 2.
  • Examined the generated invoices menu before and after the change and observed that the Recurring Invoicer form entry disappeared, with the after-state showing only Contracts and Launch invoices generation under Accounting receivables and the flags Generated invoices present: False and Launch invoices generation present: True.
  • Compared invoice data before and after the change and saw the shift from sponsorship_gift_type_id to gift_type_id, with _build_invoice_gen_data receiving gift_wizard without invoicer in the after-state yet still producing the same invoice data.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
gift_compassion/wizards/generate_gift_wizard.py Updates direct gift creation to populate the current sponsorship.gift.gift_type_id field; no issues found.
sponsorship_compassion/models/contract_group.py Adapts invoice generation to call the superclass without a recurring invoicer and then generate birthday and Christmas gifts; no issues found.
sponsorship_compassion/models/contracts.py Removes the recurring invoicer dependency from automatic gift generation and keeps gift invoice creation delegated to the wizard; no issues found.
sponsorship_compassion/wizards/generate_gift_wizard.py Removes recurring invoicer context usage from manual gift invoice generation and builds invoice data with the updated contract-group API; no issues found.
sponsorship_compassion/views/sponsorship_contract_view.xml Removes the generated invoices menu item while keeping the invoice generation server action menu; no issues found.
sponsorship_compassion/security/ir.model.access.csv Drops access rights for the removed recurring.invoicer model; no issues found.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant UserOrCron as User/Cron
participant Group as recurring.contract.group
participant Sponsorship as sponsorship.contract
participant GiftWizard as generate.gift.wizard
participant Invoice as account.move

UserOrCron->>Group: Launch invoice generation
Group->>Group: super()._generate_invoices()
Group->>Sponsorship: _generate_gifts(birthday type)
Sponsorship->>GiftWizard: create/write wizard per eligible contract
GiftWizard->>Group: _build_invoice_gen_data(invoicing_date, gift_wizard)
GiftWizard->>Invoice: create() and action_post()
Group->>Sponsorship: _generate_gifts(christmas type)
Sponsorship->>GiftWizard: create/write wizard per eligible contract
GiftWizard->>Invoice: create() and action_post()
Group-->>UserOrCron: return regular generation result
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant UserOrCron as User/Cron
participant Group as recurring.contract.group
participant Sponsorship as sponsorship.contract
participant GiftWizard as generate.gift.wizard
participant Invoice as account.move

UserOrCron->>Group: Launch invoice generation
Group->>Group: super()._generate_invoices()
Group->>Sponsorship: _generate_gifts(birthday type)
Sponsorship->>GiftWizard: create/write wizard per eligible contract
GiftWizard->>Group: _build_invoice_gen_data(invoicing_date, gift_wizard)
GiftWizard->>Invoice: create() and action_post()
Group->>Sponsorship: _generate_gifts(christmas type)
Sponsorship->>GiftWizard: create/write wizard per eligible contract
GiftWizard->>Invoice: create() and action_post()
Group-->>UserOrCron: return regular generation result
Loading

Reviews (2): Last reviewed commit: "FIX address greptile/pylint review comme..." | Re-trigger Greptile

- Return super() result in _generate_invoices override
- Use gift_type.name in log messages instead of recordset repr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant