[FIX] base: validation for studio fields compute dependencies
Before this commit: `id` cannot be set as the dependency for a field's compute method. So, when a user configures `id` as a dependency for a studio field's compute, there is no error shown to the user and the field is saved with `id` as a dependency. After this commit: It will throw a `UserError` to the user. sentry-3979435039 closes odoo/odoo#124660 X-original-commit: 9eab433e09aafafd3015f731b9ec449965d97748 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
@@ -12443,6 +12443,13 @@ msgstr ""
|
||||
msgid "Compute"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#. odoo-python
|
||||
#: code:addons/base/models/ir_model.py:0
|
||||
#, python-format
|
||||
msgid "Compute method cannot depend on field 'id'"
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: model:ir.module.module,summary:base.module_sale_subscription_taxcloud
|
||||
msgid "Compute taxes with TaxCloud after automatic invoice creation."
|
||||
|
||||
@@ -672,6 +672,8 @@ class IrModelFields(models.Model):
|
||||
names = seq.strip().split(".")
|
||||
last = len(names) - 1
|
||||
for index, name in enumerate(names):
|
||||
if name == 'id':
|
||||
raise UserError(_("Compute method cannot depend on field 'id'"))
|
||||
field = model._fields.get(name)
|
||||
if field is None:
|
||||
raise UserError(_("Unknown field %r in dependency %r") % (name, seq.strip()))
|
||||
|
||||
Reference in New Issue
Block a user