[FIX] product: traceback on deleting category
before this commit, when deleting a product category from a db where expense category is already deleted before this commit [1] is raising exception after this commit, exception wont be shown in existing db where expense category is deleted. 1 https://github.com/odoo/odoo/commit/09e4b2fb586ac83adb984672e027ce6dd62affb2 closes odoo/odoo#119754 X-original-commit: 20b5518110b233ba3b59158a8362db04b9a89aad Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
committed by
Yannick Tivisse
parent
a7cd003173
commit
1e7127c92e
@@ -57,9 +57,9 @@ class ProductCategory(models.Model):
|
||||
|
||||
@api.ondelete(at_uninstall=False)
|
||||
def _unlink_except_default_category(self):
|
||||
main_category = self.env.ref('product.product_category_all')
|
||||
if main_category in self:
|
||||
main_category = self.env.ref('product.product_category_all', raise_if_not_found=False)
|
||||
if main_category and main_category in self:
|
||||
raise UserError(_("You cannot delete this product category, it is the default generic category."))
|
||||
expense_category = self.env.ref('product.cat_expense')
|
||||
if expense_category in self:
|
||||
expense_category = self.env.ref('product.cat_expense', raise_if_not_found=False)
|
||||
if expense_category and expense_category in self:
|
||||
raise UserError(_("You cannot delete the %s product category.", expense_category.name))
|
||||
|
||||
Reference in New Issue
Block a user