diff --git a/attribute_set/models/attribute_attribute.py b/attribute_set/models/attribute_attribute.py
index 064c8131..8202af80 100644
--- a/attribute_set/models/attribute_attribute.py
+++ b/attribute_set/models/attribute_attribute.py
@@ -97,6 +97,10 @@ class AttributeAttribute(models.Model):
column1="attribute_id",
column2="attribute_set_id",
)
+ allowed_attribute_set_ids = fields.Many2many(
+ comodel_name="attribute.set",
+ compute="_compute_allowed_attribute_set_ids",
+ )
attribute_group_id = fields.Many2one(
"attribute.group", "Attribute Group", required=True, ondelete="cascade"
@@ -224,6 +228,18 @@ def _build_attribute_eview(self):
return attribute_eview
+ def _get_attribute_set_allowed_model(self):
+ return self.model_id
+
+ @api.depends("model_id")
+ def _compute_allowed_attribute_set_ids(self):
+ AttributeSet = self.env["attribute.set"]
+ for record in self:
+ allowed_models = record._get_attribute_set_allowed_model()
+ record.allowed_attribute_set_ids = AttributeSet.search(
+ [("model_id", "in", allowed_models.ids)]
+ )
+
@api.onchange("model_id")
def onchange_model_id(self):
return {"domain": {"field_id": [("model_id", "=", self.model_id.id)]}}
diff --git a/attribute_set/views/attribute_attribute_view.xml b/attribute_set/views/attribute_attribute_view.xml
index 463b9c31..21984d7c 100644
--- a/attribute_set/views/attribute_attribute_view.xml
+++ b/attribute_set/views/attribute_attribute_view.xml
@@ -73,10 +73,11 @@
domain="[('model_id', '=', model_id)]"
/>
+
diff --git a/product_attribute_set/models/__init__.py b/product_attribute_set/models/__init__.py
index 533c5a5a..d3ddd3de 100644
--- a/product_attribute_set/models/__init__.py
+++ b/product_attribute_set/models/__init__.py
@@ -1,2 +1,3 @@
+from . import attribute_attribute
from . import product_category
from . import product
diff --git a/product_attribute_set/models/attribute_attribute.py b/product_attribute_set/models/attribute_attribute.py
new file mode 100644
index 00000000..80161185
--- /dev/null
+++ b/product_attribute_set/models/attribute_attribute.py
@@ -0,0 +1,14 @@
+# Copyright 2023 ForgeFlow S.L.
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from odoo import models
+
+
+class AttributeAttribute(models.Model):
+ _inherit = "attribute.attribute"
+
+ def _get_attribute_set_allowed_model(self):
+ res = super()._get_attribute_set_allowed_model()
+ if self.model_id.model == "product.product":
+ res |= self.env["ir.model"].search([("model", "=", "product.template")])
+ return res
diff --git a/product_attribute_set/models/product.py b/product_attribute_set/models/product.py
index 540d4dcf..185d335d 100644
--- a/product_attribute_set/models/product.py
+++ b/product_attribute_set/models/product.py
@@ -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"))]
diff --git a/product_attribute_set/views/product.xml b/product_attribute_set/views/product.xml
index 6419280a..648cf3db 100644
--- a/product_attribute_set/views/product.xml
+++ b/product_attribute_set/views/product.xml
@@ -1,5 +1,6 @@
+
{"include_native_attribute": 1, "search_default_filter_to_sell": 1}
@@ -17,6 +18,7 @@
name="attribute_set_id"
nolabel="1"
context="{'default_model_id': %(product.model_product_template)d}"
+ force_save="1"
/>
@@ -47,4 +49,32 @@
+
+
+
+ {"include_native_attribute": 1}
+
+
+
+
+ {"include_native_attribute": 1, "search_default_filter_to_sell": 1}
+
+
+
+
+ product.product.view.form.easy - product_attribute_set
+ product.product
+
+
+
+
+
+
+
+
+
+
+
diff --git a/product_attribute_set/views/product_category.xml b/product_attribute_set/views/product_category.xml
index ea962411..8709d081 100644
--- a/product_attribute_set/views/product_category.xml
+++ b/product_attribute_set/views/product_category.xml
@@ -8,7 +8,7 @@