[IMP] product: do not allow the deletion of the main product category

This commit is contained in:
Victor Feyens
2020-02-20 14:51:13 +00:00
parent 6d94f02ea1
commit 2d688510d1
+6 -1
View File
@@ -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"