[19.0][ADD] product_class: classes to group product attributes#2273
[19.0][ADD] product_class: classes to group product attributes#2273Ricardoalso wants to merge 1 commit intoOCA:19.0from
Conversation
96216f0 to
8c641f8
Compare
8c641f8 to
2b3aece
Compare
| <xpath expr="//field[@name='attribute_line_ids']" position="attributes"> | ||
| <attribute | ||
| name="domain" | ||
| >[('attribute_id', 'in', class_id.attribute_ids.ids if class_id else [])]</attribute> |
There was a problem hiding this comment.
This domain doesn't seem to be working. See video below:
Screen.Recording.2026-04-23.at.8.41.03.AM.mov
The constraint catches the issue and prevents saving the record, but the UI still allows to select wrong attributes.
AFAIR you can't have expressions like this in the domain attribute, so that may be why it's not working.
The way to work around this typical case is to have an intermediate allowed_attribute_ids non-stored computed field. At least in previous versions, maybe in 19.0 there's a better way that I'm not aware of
There was a problem hiding this comment.
Hm, tricky situation here 🤔
The domain doesn’t work even with the allowed_attribute_ids approach, and the only thing preventing the user from setting an incorrect attribute is the _check_class_attributes constraint. I could override the web_name_search method, but that feels like overkill and adds complexity for limited UX benefit.
I’m open to suggestions
Thanks 🙏
There was a problem hiding this comment.
@ivantodorovich handled it with the approach we discussed about ce5ea6a
Thanks again 🚀
EDIT (context):
Using parent.class_id.attribute_ids directly does not work and triggers :
Invalid composed field class_id.attribute_ids in domain of <field name="attribute_id"> ([('id', 'in', parent.class_id.attribute_ids)] if parent.class_id else [])
Relating to the comment :
AFAIR you can't have expressions like this in the domain attribute, so that may be why it's not working.
normalize_domain handles it
>>> from odoo.fields import Command, Domain
>>> normalize_domain([('id', 'in', [1,2])] if True else [])
[('id', 'in', [1, 2])]
>>> normalize_domain([('id', 'in', [1,2])] if False else [])
[(1, '=', 1)]
2b3aece to
ec42e77
Compare
ivantodorovich
left a comment
There was a problem hiding this comment.
LG.
Small comments, pre-approving
This module introduces Product Classes to group product attributes and standardize product setup.
7486878 to
ef484ff
Compare
This module introduces Product Classes to group product attributes and standardize product setup.