[IMP] product: do not allow the deletion of the main product category
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user