From 888d15a2e874bd25823c074d74bd8d21dfc9b90b Mon Sep 17 00:00:00 2001 From: sesn-odoo Date: Thu, 29 Feb 2024 11:30:33 +0100 Subject: [PATCH] [FIX] l10n_mx: add missing decorator on create method 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 858bf9efdd9fcc29a73336863a51227c15cc19f0 opw-3772520 opw-3772469 opw-3772287 opw-3771854 opw-3771361 closes odoo/odoo#156163 X-original-commit: 59a49bda5607e8a12cf153c4338785de42cde90c Signed-off-by: Brice Bartoletti (bib) --- addons/l10n_mx/models/account_account.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/l10n_mx/models/account_account.py b/addons/l10n_mx/models/account_account.py index e1d824383c3..fe11be46629 100644 --- a/addons/l10n_mx/models/account_account.py +++ b/addons/l10n_mx/models/account_account.py @@ -1,9 +1,10 @@ -from odoo import Command, models +from odoo import api, Command, models class AccountAccount(models.Model): _inherit = 'account.account' + @api.model_create_multi def create(self, vals_list): # EXTENDS account - ensure there is a tag on created MX accounts # The computation is a bit naive and might not be correct in all cases.