diff --git a/addons/product/models/product.py b/addons/product/models/product.py index a1343337fa8..20e8c4fbb74 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -5,7 +5,7 @@ import logging import re from odoo import api, fields, models, tools, _ -from odoo.exceptions import ValidationError +from odoo.exceptions import UserError, ValidationError from odoo.osv import expression @@ -61,6 +61,11 @@ class ProductCategory(models.Model): def name_create(self, name): return self.create({'name': name}).name_get()[0] + def unlink(self): + main_category = self.env.ref('product.product_category_all') + if main_category in self: + raise UserError(_("You cannot delete this product category, it is the default generic category.")) + class ProductProduct(models.Model): _name = "product.product"