[FIX] server_environment: ensure _inverse_sparce is set

inverse method is not set on readonly field by Odoo
even there is a states attributes on this field
here we ensure the inverse method is set if the field
is editable
This commit is contained in:
Adrien Peiffer 2023-01-06 07:24:25 +01:00
parent 21c9210664
commit 2585c069d5
No known key found for this signature in database
GPG Key ID: D9266D898B218452
1 changed files with 6 additions and 0 deletions

View File

@ -390,6 +390,12 @@ class ServerEnvMixin(models.AbstractModel):
if hasattr(base_field, "selection"):
field_args["selection"] = base_field.selection
field = base_field_cls(**field_args)
# inverse method is not set on readonly field by Odoo
# even there is a states attributes on this field
# here we ensure the inverse method is set if the field
# is editable
if not field.inverse and field.is_editable():
field.inverse = field._inverse_sparse
self._add_field(fieldname, field)
@api.model