[FIX] point_of_sale: comboline changes
Step to reproduce: - Order a combo product in pos_restaurant - Order the same combo product for the same table - The second order will not be processed Previously the getOrderChanges method was computing the orderline changes based on a key composed of the product id, the full product name and the note. This was done considering the fact that the merge orderline was working. Combo products are not handled by the merge orderline. Because of this, if 2 orderlines of combo product were the same, only the last orderline would be taken into account. To prevent this, this commit changes the key to the uuid wich is a unique identifier to an orderline. closes odoo/odoo#140416 Related: odoo/enterprise#49893 Signed-off-by: David Monnom (moda) <moda@odoo.com>
This commit is contained in:
@@ -1632,7 +1632,7 @@ export class Order extends PosModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {{ [productKey: string]: { product_id: number, name: string, note: string, quantity: number } }}
|
||||
* @returns {{ [lineKey: string]: { product_id: number, name: string, note: string, quantity: number } }}
|
||||
* This function recalculates the information to be sent to the preparation tools,
|
||||
* it uses the variable lastOrderPrepaChange which contains the last changes sent
|
||||
* to perform this calculation.
|
||||
@@ -1650,7 +1650,6 @@ export class Order extends PosModel {
|
||||
const orderline = this.orderlines[orderlineIdx];
|
||||
const product = orderline.get_product();
|
||||
const note = orderline.getNote();
|
||||
const productKey = `${product.id} - ${orderline.get_full_product_name()} - ${note}`;
|
||||
const lineKey = `${orderline.uuid} - ${note}`;
|
||||
if (
|
||||
prepaCategoryIds.size === 0 ||
|
||||
@@ -1662,7 +1661,7 @@ export class Order extends PosModel {
|
||||
: quantity;
|
||||
|
||||
if (quantityDiff && orderline.skipChange === skipped) {
|
||||
changes[productKey] = {
|
||||
changes[lineKey] = {
|
||||
name: orderline.get_full_product_name(),
|
||||
product_id: product.id,
|
||||
attribute_value_ids: orderline.attribute_value_ids,
|
||||
@@ -1686,9 +1685,9 @@ export class Order extends PosModel {
|
||||
// was last sent to the preparation tools. If so we add this to the changes.
|
||||
for (const [lineKey, lineResume] of Object.entries(this.lastOrderPrepaChange)) {
|
||||
if (!this.getOrderedLine(lineKey)) {
|
||||
const productKey = `${lineResume["product_id"]} - ${lineResume["name"]} - ${lineResume["note"]}`;
|
||||
if (!changes[productKey]) {
|
||||
changes[productKey] = {
|
||||
const lineKey = `${lineResume["line_uuid"]} - ${lineResume["note"]}`;
|
||||
if (!changes[lineKey]) {
|
||||
changes[lineKey] = {
|
||||
product_id: lineResume["product_id"],
|
||||
name: lineResume["name"],
|
||||
note: lineResume["note"],
|
||||
@@ -1696,7 +1695,7 @@ export class Order extends PosModel {
|
||||
quantity: -lineResume["quantity"],
|
||||
};
|
||||
} else {
|
||||
changes[productKey]["quantity"] -= lineResume["quantity"];
|
||||
changes[lineKey]["quantity"] -= lineResume["quantity"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ export class ConfirmationPage extends Component {
|
||||
this.setDefautLanguage();
|
||||
}, 5000);
|
||||
|
||||
setTimeout(() => {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
this.printer.print(OrderReceipt, {
|
||||
await this.printer.print(OrderReceipt, {
|
||||
data: this.selfOrder.export_for_printing(this.confirmedOrder),
|
||||
formatCurrency: this.selfOrder.formatMonetary,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user