[IMP] website_sale_aplicoop: add sequence field to product.category for web ordering
- Add sequence field (default 10) to product.category with _order = "sequence, name" - Inherit product.category tree view to add drag-handle widget - Sort category hierarchy and available categories by sequence in controller - Migration 18.0.1.9.0: add sequence column to product_category table - Bump version to 18.0.1.9.0
This commit is contained in:
parent
5bb5d20244
commit
f8ef927a9e
5 changed files with 52 additions and 8 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
{ # noqa: B018
|
||||
"name": "Website Sale - Aplicoop",
|
||||
"version": "18.0.1.8.0",
|
||||
"version": "18.0.1.9.0",
|
||||
"category": "Website/Sale",
|
||||
"summary": "Modern replacement of legacy Aplicoop - Collaborative consumption group orders",
|
||||
"author": "Odoo Community Association (OCA), Criptomart",
|
||||
|
|
@ -34,6 +34,7 @@
|
|||
"security/record_rules.xml",
|
||||
# Vistas
|
||||
"views/group_order_views.xml",
|
||||
"views/product_category_views.xml",
|
||||
"views/res_partner_views.xml",
|
||||
"views/res_config_settings_views.xml",
|
||||
"views/website_templates.xml",
|
||||
|
|
|
|||
13
website_sale_aplicoop/migrations/18.0.1.9.0/pre-migrate.py
Normal file
13
website_sale_aplicoop/migrations/18.0.1.9.0/pre-migrate.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"""Add sequence field to product.category.
|
||||
|
||||
Ensures the sequence column exists with a default of 10 for all existing rows.
|
||||
The ORM will also handle this on upgrade, but we add it explicitly so the
|
||||
column is present before any post-install logic runs.
|
||||
"""
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
cr.execute("""
|
||||
ALTER TABLE product_category
|
||||
ADD COLUMN IF NOT EXISTS sequence INTEGER NOT NULL DEFAULT 10;
|
||||
""")
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
from . import group_order
|
||||
from . import product_extension
|
||||
from . import res_config_settings
|
||||
from . import res_partner_extension
|
||||
from . import sale_order_extension
|
||||
from . import stock_picking_extension
|
||||
from . import js_translations
|
||||
from . import group_order # noqa: F401
|
||||
from . import group_order_slot # noqa: F401
|
||||
from . import product_category_extension # noqa: F401
|
||||
from . import product_extension # noqa: F401
|
||||
from . import res_config_settings # noqa: F401
|
||||
from . import res_partner_extension # noqa: F401
|
||||
from . import sale_order_extension # noqa: F401
|
||||
from . import stock_picking_extension # noqa: F401
|
||||
from . import js_translations # noqa: F401
|
||||
|
|
|
|||
12
website_sale_aplicoop/models/product_category_extension.py
Normal file
12
website_sale_aplicoop/models/product_category_extension.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
_order = "sequence, name"
|
||||
|
||||
sequence = fields.Integer(default=10)
|
||||
16
website_sale_aplicoop/views/product_category_views.xml
Normal file
16
website_sale_aplicoop/views/product_category_views.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="product_category_view_tree_sequence" model="ir.ui.view">
|
||||
<field name="name">product.category.list.sequence</field>
|
||||
<field name="model">product.category</field>
|
||||
<field name="inherit_id" ref="product.product_category_list_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//list" position="attributes">
|
||||
<attribute name="default_order">sequence, name</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//list/field[1]" position="before">
|
||||
<field name="sequence" widget="handle"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue