[FIX] sale_product_configurator: edit product with variants sale line
Issue: ====== When you edit an already saved product line which has variants it will throw an error. Steps to reproduce the error: ============================= 1-create 2 products having at least one variant each and make them storable 2-create a sale order and add only the first product and save the SO 3-edit the sale line of the first product with the second product and try to save it Origin of the problem: ====================== When retrieving combination we didn't check that the variants are associated to the product. Solution: ========= Try to get the variants that are associated to the product , if there is no such variants we apply get_first_possible_combination opw-3423065 opw-3450266 closes odoo/odoo#132527 X-original-commit: 06d18005762377c5188c5537ba4d17c4efd66948 Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
This commit is contained in:
@@ -42,9 +42,10 @@ class ProductConfiguratorController(Controller):
|
||||
request.update_context(allowed_company_ids=[company_id])
|
||||
product_template = request.env['product.template'].browse(product_template_id)
|
||||
|
||||
combination = request.env['product.template.attribute.value']
|
||||
if ptav_ids:
|
||||
combination = request.env['product.template.attribute.value'].browse(ptav_ids)
|
||||
else:
|
||||
combination = request.env['product.template.attribute.value'].browse(ptav_ids).filtered(lambda ptav: ptav.product_tmpl_id.id == product_template_id)
|
||||
if not combination:
|
||||
combination = product_template._get_first_possible_combination()
|
||||
|
||||
return dict(
|
||||
|
||||
Reference in New Issue
Block a user