Order the list of variants on the product

Closes #14285
This commit is contained in:
Cédric Krier committed 2025-10-10 17:42:08 +02:00
1 parent a5330ab1ff
commit e138ff1286
7 files changed
+32 -5

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Order the list of variants on the product
* Allow a different list price to be set for each variant
Version 7.6.0 - 2025-04-28
+11
View File
@@ -120,6 +120,10 @@ class Template(
'template', 'category', "Categories", readonly=True)
products = fields.One2Many(
'product.product', 'template', "Variants",
order=[
('position', 'ASC NULLS FIRST'),
('id', 'ASC'),
],
help="The different variants the product comes in.")
@classmethod
@@ -416,6 +420,9 @@ class Product(
code = fields.Char(
"Code", readonly=True,
help="A unique identifier for the variant.")
position = fields.Integer(
"Position",
help="The order of the variant in the list of variants on product.")
identifiers = fields.One2Many(
'product.identifier', 'product', "Identifiers",
help="Other identifiers associated with the variant.")
@@ -498,6 +505,10 @@ class Product(
]
cls._sql_indexes.add(
Index(t, (t.code, Index.Similarity(cardinality='high'))))
cls._sql_indexes.add(
Index(t,
(t.position, Index.Range(order='ASC NULLS FIRST')),
(t.id, Index.Range(order='ASC'))))
for attr in dir(Template):
tfield = getattr(Template, attr)
+7
View File
@@ -113,6 +113,13 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">product_tree_simple</field>
</record>
<record model="ir.ui.view" id="product_view_tree_simple_sequence">
<field name="model">product.product</field>
<field name="type">tree</field>
<field name="priority" eval="20"/>
<field name="name">product_tree_simple_sequence</field>
</record>
<record model="ir.ui.view" id="product_view_form">
<field name="model">product.product</field>
<field name="type" eval="None"/>
+5 -3
View File
@@ -2,9 +2,6 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="template"/>
<field name="template"/>
<newline/>
<label name="code"/>
<group col="-1" name="code" string="">
<field name="prefix_code"/>
@@ -13,6 +10,11 @@ this repository contains the full copyright notices and license terms. -->
<label name="active"/>
<field name="active"/>
<label name="template"/>
<field name="template"/>
<label name="position"/>
<field name="position"/>
<label name="list_price"/>
<field name="list_price"/>
<newline/>
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree sequence="position">
<field name="rec_name" expand="1"/>
</tree>
+1 -1
View File
@@ -29,7 +29,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="cost_price_method"/>
<newline/>
<field name="products" mode="form,tree" colspan="2"
view_ids="product.product_view_form_simple"/>
view_ids="product.product_view_form_simple,product.product_view_tree_simple_sequence"/>
<group id="categories" colspan="2" col="2" yexpand="1" yfill="1">
<field name="categories" colspan="2" yexpand="1" yfill="1" view_ids="product.category_view_list"/>
</group>
+1 -1
View File
@@ -192,7 +192,7 @@ class Product(IdentifiersMixin, metaclass=PoolMeta):
@classmethod
def __setup__(cls):
super().__setup__()
cls._shopify_fields.update(['code', 'attributes'])
cls._shopify_fields.update(['code', 'attributes', 'position'])
@classmethod
def get_shopify_identifier_to_update(cls, records):