[16.0][ADD] product_attribute_value_dependent_mixin#2022
[16.0][ADD] product_attribute_value_dependent_mixin#2022
Conversation
|
|
||
| |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. |
There was a problem hiding this comment.
@Kev-Roche Could be great to explain a little bit more context 😅
There was a problem hiding this comment.
Agreed! I ll did it.
|
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. |
|
@Kev-Roche What's the status of this as some other PR's depend on it ? Thanks |
rvalyi
left a comment
There was a problem hiding this comment.
The name of the module should be with dependent with an E, not dependant.
772cb88 to
c63aabc
Compare
c63aabc to
d369dbe
Compare
d369dbe to
b484f32
Compare
| @@ -0,0 +1,2 @@ | |||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | |||
There was a problem hiding this comment.
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). | |||
| @api.depends("product_tmpl_id") | ||
| def _compute_available_product_ids(self): | ||
| for rec in self: | ||
| rec.available_product_ids = self.env["product.product"].search( |
There was a problem hiding this comment.
IMHO, this should be avoided at all for performances reasons.
Why using _origin ?
I would have done the search before the loop
There was a problem hiding this comment.
Moreover, why not having used a One2many field using the direct field product_tmpl_id instead ?
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
In v16 and later, you can use fields.Binary() to avoid json.dumps()
| @@ -0,0 +1,2 @@ | |||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | |||
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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...
|
Hello @rousseldenis @rvalyi and @Kev-Roche I made a lot of changes in #2250 to improve this module. Can you provide some feedback ? |
Because there is nothing to copyright 😄 it's trivial. But that's ok |
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