diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index 6103ad064c5..0f3bc938ebe 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -135,14 +135,20 @@ class ProductPublicCategory(models.Model): _inherit = ["website.seo.metadata", "website.multi.mixin", 'image.mixin'] _description = "Website Product Category" _parent_store = True - _order = "sequence, name" + _order = "sequence, name, id" + + def _default_sequence(self): + cat = self.search([], limit=1, order="sequence DESC") + if cat: + return cat.sequence + 5 + return 10000 name = fields.Char(required=True, translate=True) parent_id = fields.Many2one('product.public.category', string='Parent Category', index=True, ondelete="cascade") parent_path = fields.Char(index=True) child_id = fields.One2many('product.public.category', 'parent_id', string='Children Categories') parents_and_self = fields.Many2many('product.public.category', compute='_compute_parents_and_self') - sequence = fields.Integer(help="Gives the sequence order when displaying a list of product categories.", index=True) + sequence = fields.Integer(help="Gives the sequence order when displaying a list of product categories.", index=True, default=_default_sequence) website_description = fields.Html('Category Description', sanitize_attributes=False, translate=html_translate) product_tmpl_ids = fields.Many2many('product.template', relation='product_public_category_product_template_rel') diff --git a/addons/website_sale/views/product_views.xml b/addons/website_sale/views/product_views.xml index 30a31aad9f5..adbddf7f243 100644 --- a/addons/website_sale/views/product_views.xml +++ b/addons/website_sale/views/product_views.xml @@ -131,7 +131,7 @@ - +