Skip to content

[REF] contract - pass self instead of relying on @api.model - #1497

Open
anthonissen-a wants to merge 1 commit into
OCA:18.0from
acsone:18.0-ref-contract_remove_static_args-aan
Open

anthonissen-a wants to merge 1 commit into
OCA:18.0from
acsone:18.0-ref-contract_remove_static_args-aan

Conversation

@anthonissen-a

Copy link
Copy Markdown
Contributor

Replaces @api.model methods with instance methods across contract methods to improve extensibility and allow overrides to access record data in self.

Method parameters are now optional to ensure full backward compatibility.

@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_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-ref-contract_remove_static_args-aan branch 2 times, most recently from 6b89846 to 73138e4 Compare August 12, 2026 11:57
@anthonissen-a
anthonissen-a marked this pull request as ready for review August 12, 2026 12:04

@qgroulard qgroulard 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.

Great changes 👍

This is backward compatible and it highly improves the extensibility of get_next_invoice_date and get_next_period_date_end for other OCA modules and custom code.

@anthonissen-a
anthonissen-a force-pushed the 18.0-ref-contract_remove_static_args-aan branch from 73138e4 to 527685d Compare September 8, 2026 07:48

@tobiaszehntner tobiaszehntner 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.

LGTM

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@sbejaoui sbejaoui 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.

let see what @pedrobaeza thinks obout this

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think it's a good idea, as this is mixing both approaches: if you use self, then you should use it for all, but if there's going to be options for still passing arguments, then keep it @api.model, and you will get a predictive behavior, as having some arguments that if omitted, are taken from self implies some kind of "black magic".

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_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.

6 participants