New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] product_variants_no_automatic_creation: Bug Product attribute e… #1252
[FIX] product_variants_no_automatic_creation: Bug Product attribute e… #1252
Conversation
@@ -31,8 +31,10 @@ class ProductConfigurator(models.AbstractModel): | |||
@api.depends('product_attribute_ids', 'product_attribute_ids.value_id') | |||
def _compute_price_extra(self): | |||
for record in self: | |||
record.price_extra = sum( | |||
record.mapped('product_attribute_ids.price_extra')) | |||
for variant_id in record.attribute_value_ids: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto debe hacerse sólo cuando product_id no está establecido. Además, utiliza mapped
y filtered
en una sola línea que queda mucho más elegante y legible, en lugar de tanto for.
Sigue sin estar contemplado el caso en el que haya product_id establecido. Recuerda que el product_tmpl_id es algo que añadimos nosotros y, por tanto, no en todas las BDs tiene por qué estar relleno. |
@pedrobaeza como ves los últimos cambios? |
def _compute_price_extra(self): | ||
for record in self: | ||
record.price_extra = sum( | ||
record.mapped('product_attribute_ids.price_extra')) | ||
if record.product_id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto sería al revés, ¿no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pero si no tengo product_id
no puedo hacer referencia al campo attribute_value_ids
, ya que ese campo no se encuentra en la clase abstracta.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sí, perdona, lo he dicho mal.
¿Esto sigue ocurriendo? |
@pedrobaeza Si, sigue ocurriendo, de hecho nos lo acaban de reportar de nuevo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Current coverage is 57.56% (diff: 100%)@@ 8.0 #1252 diff @@
==========================================
Files 268 268
Lines 8027 8031 +4
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 4621 4623 +2
- Misses 3406 3408 +2
Partials 0 0
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works.
…xtra prices are not automatically added
odoomrp#1252) * [FIX] product_variants_no_automatic_creation: Bug Product attribute extra prices are not automatically added * [FIX] product_variants_no_automatic_creation: fix flake-8
Bug Product attribute extra prices are not automatically added.