From f8ef927a9ef87281f17900a150d581786a348510 Mon Sep 17 00:00:00 2001 From: snt Date: Wed, 20 May 2026 12:50:28 +0200 Subject: [PATCH] [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 --- website_sale_aplicoop/__manifest__.py | 3 ++- .../migrations/18.0.1.9.0/pre-migrate.py | 13 +++++++++++++ website_sale_aplicoop/models/__init__.py | 16 +++++++++------- .../models/product_category_extension.py | 12 ++++++++++++ .../views/product_category_views.xml | 16 ++++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 website_sale_aplicoop/migrations/18.0.1.9.0/pre-migrate.py create mode 100644 website_sale_aplicoop/models/product_category_extension.py create mode 100644 website_sale_aplicoop/views/product_category_views.xml diff --git a/website_sale_aplicoop/__manifest__.py b/website_sale_aplicoop/__manifest__.py index a566e3d..e820bd8 100644 --- a/website_sale_aplicoop/__manifest__.py +++ b/website_sale_aplicoop/__manifest__.py @@ -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", diff --git a/website_sale_aplicoop/migrations/18.0.1.9.0/pre-migrate.py b/website_sale_aplicoop/migrations/18.0.1.9.0/pre-migrate.py new file mode 100644 index 0000000..9c7071d --- /dev/null +++ b/website_sale_aplicoop/migrations/18.0.1.9.0/pre-migrate.py @@ -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; + """) diff --git a/website_sale_aplicoop/models/__init__.py b/website_sale_aplicoop/models/__init__.py index b94d3ea..0a00ead 100644 --- a/website_sale_aplicoop/models/__init__.py +++ b/website_sale_aplicoop/models/__init__.py @@ -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 diff --git a/website_sale_aplicoop/models/product_category_extension.py b/website_sale_aplicoop/models/product_category_extension.py new file mode 100644 index 0000000..e562b10 --- /dev/null +++ b/website_sale_aplicoop/models/product_category_extension.py @@ -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) diff --git a/website_sale_aplicoop/views/product_category_views.xml b/website_sale_aplicoop/views/product_category_views.xml new file mode 100644 index 0000000..184f237 --- /dev/null +++ b/website_sale_aplicoop/views/product_category_views.xml @@ -0,0 +1,16 @@ + + + + product.category.list.sequence + product.category + + + + sequence, name + + + + + + +