From c6b1d287e7611e668c2f0722adbef602881f6aa0 Mon Sep 17 00:00:00 2001 From: "Pedram (pebr)" Date: Fri, 22 Mar 2024 12:55:46 +0100 Subject: [PATCH] [FIX] point_of_sale: ensure correct display of custom attributes Before this commit, the custom attribute names were not correctly displayed when added to an order. opw-3795843 closes odoo/odoo#158805 Signed-off-by: Joseph Caburnay (jcb) --- addons/point_of_sale/static/src/app/store/models.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/app/store/models.js b/addons/point_of_sale/static/src/app/store/models.js index d7eed801921..4bedf08714f 100644 --- a/addons/point_of_sale/static/src/app/store/models.js +++ b/addons/point_of_sale/static/src/app/store/models.js @@ -1093,13 +1093,22 @@ export class Orderline extends PosModel { isPartOfCombo() { return Boolean(this.comboParent || this.comboLines?.length); } - findAttribute(values) { + findAttribute(values, customAttributes) { const listOfAttributes = []; for (const value of values){ for (const ptal_id of this.pos.ptal_ids_by_ptav_id[value]){ const attribute = this.pos.attributes_by_ptal_id[ptal_id] const attFound = attribute.values.filter((target) => { return Object.values(values).includes(target.id); + }).map(att => ({...att})); // make a copy + attFound.forEach((att) => { + if (att.is_custom) { + customAttributes.forEach((customAttribute) => { + if (att.id === customAttribute.custom_product_template_attribute_value_id) { + att.name = customAttribute.value; + } + }); + } }); const modifiedAttribute = { ...attribute, @@ -1130,7 +1139,7 @@ export class Orderline extends PosModel { this.getUnitDisplayPriceBeforeDiscount() ), attributes: this.attribute_value_ids - ? this.findAttribute(this.attribute_value_ids) + ? this.findAttribute(this.attribute_value_ids, this.custom_attribute_value_ids) : [], }; }