Skip to content

Commit

Permalink
[16.0][FIX] product_variant_configurator: overwrite existing attribut…
Browse files Browse the repository at this point in the history
…e lines in _set_product_attributes
  • Loading branch information
alexbottemanne committed Mar 7, 2024
1 parent 420051b commit 4fd07dc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions product_variant_configurator/models/product_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ def _set_product_tmpl_attributes(self):
def _set_product_attributes(self):
self.ensure_one()
if self.product_id:
self.product_attribute_ids.unlink()
attribute_lines = self.product_attribute_ids.browse([])
for vals in self.product_id._get_product_attributes_values_dict():
vals["product_tmpl_id"] = self.product_id.product_tmpl_id
vals["owner_model"] = self._name
vals["owner_id"] = self.id
attribute_lines += attribute_lines.new(vals)
vals["owner_id"] = self
new_attribute_line = attribute_lines.new(vals)
attribute_lines |= new_attribute_line
self.product_attribute_ids = attribute_lines

def _empty_attributes(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,33 @@
name="attrs"
>{'readonly': [('state', 'in', ('purchase', 'to approve','done', 'cancel'))]}</attribute>
</xpath>
<xpath
expr="//field[@name='order_line']/form//field[@name='product_id']"
position="attributes"
>
<attribute
name="attrs"
>{'readonly': [('state', 'in', ('purchase', 'to approve','done', 'cancel'))]}</attribute>
<attribute name="domain">product_id_configurator_domain</attribute>
</xpath>
<xpath
expr="//field[@name='order_line']/form//field[@name='product_id']"
position="after"
>
<field name="product_id_configurator_domain" invisible="1" />
</xpath>
<xpath
expr="//field[@name='order_line']/tree//field[@name='product_id']"
position="after"
>
<field name="product_id_configurator_domain" invisible="1" />
</xpath>
<xpath
expr="//field[@name='order_line']/tree//field[@name='product_id']"
position="attributes"
>
<attribute name="domain">product_id_configurator_domain</attribute>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 4fd07dc

Please sign in to comment.