Skip to content

Commit

Permalink
[FIX] point_of_sale: ensure correct display of custom attributes
Browse files Browse the repository at this point in the history
Before this commit, the custom attribute names were not correctly
displayed when added to an order.

opw-3795843

X-original-commit: c6b1d28
  • Loading branch information
pedrambiria committed Mar 29, 2024
1 parent c9a74bd commit 9102607
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions addons/point_of_sale/static/src/app/store/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,21 @@ export class Orderline extends PosModel {
isPartOfCombo() {
return Boolean(this.combo_parent_id || this.combo_line_ids?.length);
}
findAttribute(values) {
findAttribute(values, customAttributes) {
const listOfAttributes = [];
Object.values(this.pos.models['product.template.attribute.line'].getAll()).filter(
(attribute) => {
const attFound = attribute.product_template_value_ids.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;
}
});
}
});
if (attFound.length > 0) {
const modifiedAttribute = {
Expand Down Expand Up @@ -891,7 +900,7 @@ export class Orderline extends PosModel {
price_without_discount: this.env.utils.formatCurrency(
this.getUnitDisplayPriceBeforeDiscount()
),
attributes: this.attribute_value_ids ? this.findAttribute(this.attribute_value_ids) : false
attributes: this.attribute_value_ids ? this.findAttribute(this.attribute_value_ids, this.custom_attribute_value_ids) : false
};
}
}
Expand Down

0 comments on commit 9102607

Please sign in to comment.