Skip to content

Commit

Permalink
[IMP] product_attribute_set: allow displaying attributes for product …
Browse files Browse the repository at this point in the history
…variants
  • Loading branch information
JordiMForgeFlow committed Nov 23, 2023
1 parent 13eab5b commit bbd01bc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
14 changes: 12 additions & 2 deletions product_attribute_set/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,15 @@ def _onchange_categ_id(self):
self.attribute_set_id = self.categ_id.attribute_set_id


# TODO : add the 'attribute.set.owner.mixin' to product.product in order to display
# Attributes in Variants.
class ProductProduct(models.Model):

_inherit = ["product.product", "attribute.set.owner.mixin"]
_name = "product.product"

attribute_set_id = fields.Many2one(
related="product_tmpl_id.attribute_set_id", store=True
)

@api.model
def _get_attribute_set_owner_model(self):
return [("model", "in", ("product.product", "product.template"))]

Check warning on line 62 in product_attribute_set/models/product.py

View check run for this annotation

Codecov / codecov/patch

product_attribute_set/models/product.py#L62

Added line #L62 was not covered by tests
17 changes: 17 additions & 0 deletions product_attribute_set/views/product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,21 @@
</xpath>
</field>
</record>
<!-- Do not display all the attributes in the easy edit view -->
<record id="product_variant_easy_edit_view" model="ir.ui.view">
<field
name="name"
>product.product.view.form.easy - product_attribute_set</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_variant_easy_edit_view" />
<field name="arch" type="xml">
<xpath expr="//group[@name='packaging']/.." position="after">
<group>
<group name="product_attributes" string="Attributes" invisible="1">
<separator name="attributes_placeholder" />
</group>
</group>
</xpath>
</field>
</record>
</odoo>
2 changes: 1 addition & 1 deletion product_attribute_set/views/product_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<field name="parent_id" position="after">
<field
name="attribute_set_id"
domain="[('model_id', '=', 'product.template')]"
domain="[('model_id', 'in', ('product.template', 'product.product'))]"
class="oe_inline"
/>
</field>
Expand Down

0 comments on commit bbd01bc

Please sign in to comment.