Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] l10n_mx: add missing decorator on create method #156082

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Mar 1, 2024

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

  • install l10n_mx
  • attempt to create a new account in the chart of accounts

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 because create() 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

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
------------------
* install `l10n_mx`
* attempt to create a new account in the chart of accounts

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 because `create()` 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

X-original-commit: 59a49bd
@robodoo
Copy link
Contributor

robodoo commented Mar 1, 2024

@fw-bot
Copy link
Contributor Author

fw-bot commented Mar 1, 2024

This PR targets saas-16.1 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Mar 1, 2024
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Mar 1, 2024
robodoo pushed a commit that referenced this pull request Mar 1, 2024
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
------------------
* install `l10n_mx`
* attempt to create a new account in the chart of accounts

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 because `create()` 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

closes #156082

X-original-commit: 59a49bd
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
@robodoo robodoo closed this Mar 1, 2024
@fw-bot fw-bot deleted the saas-16.1-16.0-opw-3772520-missing_create_decorator-sesn-KWFf-fw branch March 15, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants