diff --git a/addons/product_matrix/static/src/js/section_and_note_widget.js b/addons/product_matrix/static/src/js/section_and_note_widget.js index 5cbc318ed76..3cdddf0f596 100644 --- a/addons/product_matrix/static/src/js/section_and_note_widget.js +++ b/addons/product_matrix/static/src/js/section_and_note_widget.js @@ -76,7 +76,12 @@ SectionAndNoteFieldOne2Many.include({ // find one of the SO widget // (not so lines because the grid values are computed on the SO) // and get the grid information from its recordData. - var gridInfo = result.find(r => r.recordData.grid).recordData.grid; + var gridInfo = result.find( + r => r.recordData.grid && r.recordData.grid.includes("header") + ).recordData.grid; + // includes "header" is necessary to ensure the correct data is taken + // because the grid data isn't correctly updated in all widgets + // when in an new record environment. self._openMatrixConfigurator(gridInfo, productTemplateId, editedCellAttributes); } }); diff --git a/addons/sale_product_matrix/models/sale_order.py b/addons/sale_product_matrix/models/sale_order.py index 814093e3bdc..f5d5469e78f 100644 --- a/addons/sale_product_matrix/models/sale_order.py +++ b/addons/sale_product_matrix/models/sale_order.py @@ -55,7 +55,10 @@ class SaleOrder(models.Model): # create or find product variant from combination product = product_template._create_product_variant(combination) - order_lines = self.order_line.filtered(lambda line: (line._origin or line).product_id == product and (line._origin or line).product_no_variant_attribute_value_ids == no_variant_attribute_values) + order_lines = self.order_line.filtered( + lambda line: line.product_id.id == product.id + and line.product_no_variant_attribute_value_ids.ids == no_variant_attribute_values.ids + ) # if product variant already exist in order lines old_qty = sum(order_lines.mapped('product_uom_qty')) diff --git a/addons/sale_product_matrix/static/tests/tours/sale_product_matrix_tour.js b/addons/sale_product_matrix/static/tests/tours/sale_product_matrix_tour.js index 622784b115f..10259a98176 100644 --- a/addons/sale_product_matrix/static/tests/tours/sale_product_matrix_tour.js +++ b/addons/sale_product_matrix/static/tests/tours/sale_product_matrix_tour.js @@ -35,6 +35,38 @@ tour.register('sale_matrix_tour', { }, { trigger: 'span:contains("Confirm")', run: 'click' +}, { + trigger: 'span:contains("Matrix (PAV11, PAV22, PAV31)\n\nPA4: PAV41")', + extra_trigger: '.o_form_editable', + run: 'click' +}, { + trigger: '.o_edit_product_configuration', + run: 'click' // edit the matrix +}, { + trigger: '.o_product_variant_matrix', + run: function () { + // set all qties to 3 + $('.o_matrix_input').val(3); + } +}, { + trigger: 'span:contains("Confirm")', + run: 'click' // apply the matrix +}, { + trigger: 'span:contains("Matrix (PAV11, PAV22, PAV31)\n\nPA4: PAV41")', + extra_trigger: '.o_form_editable', + run: 'click' +}, { + trigger: '.o_edit_product_configuration', + run: 'click' // edit the matrix +}, { + trigger: '.o_product_variant_matrix', + run: function () { + // reset all qties to 1 + $('.o_matrix_input').val(1); + } +}, { + trigger: 'span:contains("Confirm")', + run: 'click' // apply the matrix }, { trigger: ".o_form_editable .o_field_many2one[name='partner_id'] input", extra_trigger: ".o_sale_order",