Before this revision, if the user did not re-order
the sequence of its attribute values manually,
the attributes in the variant name were ordered
randomly.
e.g. On the ipod, one time it could be the color before
the GB, one time the other way around.
Besides, this could lead to an issue in the pivot table,
as mentioned in the revision
834b38a84d.
However, on the contrary on what is done in the above revision,
these attributes must not be ordered on their value name,
but rather on their sequence, and if they have the same,
on their attribute, so the order is always deterministic.
Currently the variants are ordered by the attribute value in the name_get. That way, all the attributes aren't displayed in the same order.
Ordering by the variant attribute name will solve this issue.
Closes https://github.com/odoo/odoo/pull/17034
Use case when it can happens (non deterministic):
- Enable product variant
- Have different stock moves with the product variant
- Click on the stock moves in the section reports
- Switch to pivot view
-> Traceback : can't find path of null
This happens in the js in the function find_path_in_tree,
this function try to find path for children object. There is
a condition root.children[i].path[l] === path[l] (2 strings
comparaison).
With product variant this condition can be overpass when it should
have been triggered. The product path string is represented as follow
[Ref]Name(variants) -> Sometime the variants in the string do not have
the same order and thus the condition is never true and the function
return null instead of the correct root.
This commit corrects the name_get function for product product
in order to always return the variants in the same order.
=======
purpose
=======
By default, the sequence is 0 for all new attributes and the result is messed up. The product attribute values are not ordered in the same way in a list view.
That's because the results are not returned from sql ordered by id if the sequence is the same. Just add this in the order definition will remove the non-deterministic behavior.
`id1`, `id2`, `rel` are deprecated now that we switched to the
new API, and are simply ignored.
Keeping them is confusing because the default names are being
used instead.
@rco-odoo: We should add a warning in the m2m constructor if these
unsupported parameters are still passed.
A new field `create_variant` has been added on `product.attribute`.
If unchecked, the attribute will not create variant.
These attributes will be added on the sale order description if bought from the shop.
The lines of a product with these attributes will be splitted to keep the description.
product.py and product_views.xml contained code related to several models.
This commit split those files to separate submodels :
* decimal_precision
* product_attribute: product.attribute, product.attribute.value,
product.attribute.line
* product_template: product.template
* product_uom: product.uom and product.uom.categ
* res_currency
Product now contains product.product model, along with some smaller
models (product.packaging, product.supplierinfo, product.category,
product.price.history)