diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 8e4d8955600..348e5d8881d 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -27,10 +27,6 @@ class ProductCategory(models.Model): store=True) parent_id = fields.Many2one('product.category', 'Parent Category', index=True, ondelete='cascade') child_id = fields.One2many('product.category', 'parent_id', 'Child Categories') - type = fields.Selection([ - ('view', 'View'), - ('normal', 'Normal')], 'Category Type', default='normal', - help="A category of the view type is a virtual category that can be used as the parent of another category to create a hierarchical structure.") parent_left = fields.Integer('Left Parent', index=1) parent_right = fields.Integer('Right Parent', index=1) product_count = fields.Integer( diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index efb701a6092..af1cf89c871 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -21,14 +21,12 @@ class ProductTemplate(models.Model): if self._context.get('categ_id') or self._context.get('default_categ_id'): return self._context.get('categ_id') or self._context.get('default_categ_id') category = self.env.ref('product.product_category_all', raise_if_not_found=False) - if category and category.type == 'normal': - return category.id - # fallback if no category "All" exists, because yes, users do delete default data! - category = self.env['product.category'].search([('type', '=', 'normal')], limit=1) + if not category: + category = self.env['product.category'].search([], limit=1) if category: return category.id else: - err_msg = _('You must define at least one product category (that is not a view) in order to be able to create products.') + err_msg = _('You must define at least one product category in order to be able to create products.') redir_msg = _('Go to Internal Categories') raise RedirectWarning(err_msg, self.env.ref('product.product_category_action_form').id, redir_msg) @@ -59,7 +57,7 @@ class ProductTemplate(models.Model): rental = fields.Boolean('Can be Rent') categ_id = fields.Many2one( 'product.category', 'Internal Category', - change_default=True, default=_get_default_category_id, domain="[('type','=','normal')]", + change_default=True, default=_get_default_category_id, required=True, help="Select category for the current product") currency_id = fields.Many2one( @@ -265,11 +263,6 @@ class ProductTemplate(models.Model): if len(p.product_variant_ids) == 1: p.product_variant_ids.packaging_ids = p.packaging_ids - @api.constrains('categ_id') - def _check_category(self): - if self.categ_id.type == 'view': - raise ValidationError(_("You cannot create a product with an Internal Category set as View. Please change the category or the category type.")) - @api.constrains('uom_id', 'uom_po_id') def _check_uom(self): if any(template.uom_id and template.uom_po_id and template.uom_id.category_id != template.uom_po_id.category_id for template in self): diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml index af0981744d1..8368c6beb18 100644 --- a/addons/product/views/product_views.xml +++ b/addons/product/views/product_views.xml @@ -421,9 +421,8 @@