Skip to content

[16.0][ADD] product_attribute_value_dependent_mixin#2022

Open
Kev-Roche wants to merge 1 commit intoOCA:16.0from
akretion:16.0-add-product_attribute_value_dependant_mixin
Open

[16.0][ADD] product_attribute_value_dependent_mixin#2022
Kev-Roche wants to merge 1 commit intoOCA:16.0from
akretion:16.0-add-product_attribute_value_dependant_mixin

Conversation

@Kev-Roche
Copy link
Copy Markdown
Contributor

This technical module was written to help developers depend on product attribute values on any model by inheriting from the mixin.

cc @chafique-delli , @sebastienbeau


|badge1| |badge2| |badge3| |badge4| |badge5|

This technical module was written to help developers depend on product attribute values on any model by inheriting from the mixin.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kev-Roche Could be great to explain a little bit more context 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! I ll did it.

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 15, 2026
@rousseldenis
Copy link
Copy Markdown
Contributor

@Kev-Roche What's the status of this as some other PR's depend on it ? Thanks

Copy link
Copy Markdown
Member

@rvalyi rvalyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the module should be with dependent with an E, not dependant.

@github-actions github-actions Bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 22, 2026
@rousseldenis
Copy link
Copy Markdown
Contributor

@Kev-Roche

@Kev-Roche Kev-Roche force-pushed the 16.0-add-product_attribute_value_dependant_mixin branch from 772cb88 to c63aabc Compare March 27, 2026 08:26
@Kev-Roche Kev-Roche changed the title [16.0][ADD] product_attribute_value_dependant_mixin [16.0][ADD] product_attribute_value_dependent_mixin Mar 27, 2026
@Kev-Roche Kev-Roche force-pushed the 16.0-add-product_attribute_value_dependant_mixin branch from c63aabc to d369dbe Compare March 27, 2026 08:29
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @rousseldenis

Do you mean the file init.py itself is not necessary or the License statement ? Sorry, I don't understand why...

@@ -0,0 +1,91 @@
# Copyright 2023-2026 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https is better

@api.depends("product_tmpl_id")
def _compute_available_product_ids(self):
for rec in self:
rec.available_product_ids = self.env["product.product"].search(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this should be avoided at all for performances reasons.

Why using _origin ?

I would have done the search before the loop

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, why not having used a One2many field using the direct field product_tmpl_id instead ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, this One2many field already exists on product.template, it is the product_variant_ids field defined in the product module... (it was already there in 14.0 too)
See https://github.com/odoo/odoo/blob/f28eb1478fe47c4627fc3377fa505c78a6a7ea82/addons/product/models/product_template.py#L122

@chafique-delli or @Kev-Roche Do you remember a reason for using self instead of rec and _origin in the search to get a Many2many instead of the One2many field ? I can't find where the field is used... not in sale_warehouse_rule at least...

string="Attribute Values",
)

available_attribute_value_domain = fields.Char(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v16 and later, you can use fields.Binary() to avoid json.dumps()

Copy link
Copy Markdown

@metaminux metaminux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do the changes in #2250

@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @rousseldenis

Do you mean the file init.py itself is not necessary or the License statement ? Sorry, I don't understand why...

@api.depends("product_tmpl_id")
def _compute_available_product_ids(self):
for rec in self:
rec.available_product_ids = self.env["product.product"].search(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, this One2many field already exists on product.template, it is the product_variant_ids field defined in the product module... (it was already there in 14.0 too)
See https://github.com/odoo/odoo/blob/f28eb1478fe47c4627fc3377fa505c78a6a7ea82/addons/product/models/product_template.py#L122

@chafique-delli or @Kev-Roche Do you remember a reason for using self instead of rec and _origin in the search to get a Many2many instead of the One2many field ? I can't find where the field is used... not in sale_warehouse_rule at least...

@metaminux
Copy link
Copy Markdown

Hello @rousseldenis @rvalyi and @Kev-Roche

I made a lot of changes in #2250 to improve this module.

Can you provide some feedback ?

@rousseldenis
Copy link
Copy Markdown
Contributor

Hello @rousseldenis

Do you mean the file init.py itself is not necessary or the License statement ? Sorry, I don't understand why...

Because there is nothing to copyright 😄 it's trivial. But that's ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants