From b08b46f6f27260baca2b9299b5f4a86d0764d807 Mon Sep 17 00:00:00 2001 From: william-andre Date: Thu, 2 Feb 2023 15:57:15 +0000 Subject: [PATCH] [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 --- odoo/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/odoo/models.py b/odoo/models.py index 4bdd985b206..a3c9c4ebc85 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -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)])