[FW][FIX] l10n_mx: add missing decorator on create method #156082
Closed
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.
Currently, if you install the Mexican localization, you are no longer able to create a new account in the chart of accounts.
Steps to reproduce
l10n_mx
You should be met with a traceback:
TypeError: AccountAccount.create() missing 1 required positional argument: 'vals_list'
Cause
The
@api.model
and@api.model_create_multi
decorators in indicate that a method is intended to operate at the model level rather than on specific record instances. Without these decorators, the system defaults to treating methods as if they are meant to be executed on the record level. This distinction significantly impacts how methods are invoked through RPC.In RPC scenarios, Odoo's default expectation for record-level methods is that the RPC call will include the IDs of the records to which the method applies, alongside any actual method arguments necessary for the operation.
Here,
create()
is called through RPC, as a model-level method (i.e, without record IDs). This makes sense becausecreate()
is always a model-level method.However, in our case, create is a record-level method, so the system expects the RPC call to contain record IDs. This mismatch produces a traceback.
Issue introduced by 858bf9e
opw-3772520
opw-3772469
opw-3772287
opw-3771854
opw-3771361
Forward-Port-Of: #155848