[FIX] base: allow to remove default properties when uninstalling module

Uninstalling a module shouldn't be blocked by properties using the
record.
Instead, we are removing the property.

Part-of: odoo/odoo#110016
This commit is contained in:
william-andre
2023-02-17 19:30:39 +01:00
parent 14ab457c6f
commit b08b46f6f2
+4 -1
View File
@@ -3518,8 +3518,11 @@ class BaseModel(metaclass=MetaModel):
# Check if the records are used as default properties.
refs = [f'{self._name},{id_}' for id_ in sub_ids]
if Property.search([('res_id', '=', False), ('value_reference', 'in', refs)], limit=1):
default_properties = Property.search([('res_id', '=', False), ('value_reference', 'in', refs)])
if not self._context.get(MODULE_UNINSTALL_FLAG) and default_properties:
raise UserError(_('Unable to delete this document because it is used as a default property'))
else:
ir_property_unlink |= default_properties
# Delete the records' properties.
ir_property_unlink |= Property.search([('res_id', 'in', refs)])