[IMP] website_sale: add default sequence to category
New categories will now we added at the end by default. The sequence field is hidden in the form view. It's still possible to order them from the list view. Part of task-2002125 Closes #25535 Co-authored-by fja-odoo <fja@odoo.com> Co-authored-by Sébastien Theys <seb@odoo.com> closes odoo/odoo#46600 Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
This commit is contained in:
committed by
Sébastien Theys
parent
0280b5fb01
commit
25025a886c
@@ -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')
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
<field name="name"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/>
|
||||
<field name="sequence"/>
|
||||
<field name="sequence" groups="base.group_no_one"/>
|
||||
</group>
|
||||
</div>
|
||||
</sheet>
|
||||
|
||||
Reference in New Issue
Block a user