[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) <jcb@odoo.com>
This commit is contained in:
Pedram (pebr)
2024-03-28 14:16:49 +00:00
parent 3dda5576ac
commit c6b1d287e7
@@ -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)
: [],
};
}