[FIX] point_of_sale: maintain manual quantity for lot-tracked refunds

Before this commit, refunding a lot-tracked product with a quantity
greater than one in the POS  would reset the quantity to one. This
occurred even if the user manually set a higher quantity.

This commit fixes the issue by ensuring the manually set quantity for
lot-tracked products is kept during refunds. This enhancement allows
for accurate quantity retention, improving the POS refund functionality.

opw-3568867

closes odoo/odoo#144050

X-original-commit: e5989cee1cea150b86e6f3d5ae5f2fcdb108fd51
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
Pedram (PEBR)
2023-11-30 11:44:47 +00:00
parent e190faa8ba
commit 8b10116410
@@ -506,7 +506,7 @@ export class Orderline extends PosModel {
* @param {Object} modifiedPackLotLines key-value pair of String (the cid) & String (the new lot_name)
* @param {Array} newPackLotLines array of { lot_name: String }
*/
setPackLotLines({ modifiedPackLotLines, newPackLotLines }) {
setPackLotLines({ modifiedPackLotLines, newPackLotLines , setQuantity = true }) {
// Set the new values for modified lot lines.
const lotLinesToRemove = [];
for (const lotLine of this.pack_lot_lines) {
@@ -534,7 +534,7 @@ export class Orderline extends PosModel {
}
// Set the quantity of the line based on number of pack lots.
if (!this.product.to_weight) {
if (!this.product.to_weight && setQuantity) {
this.set_quantity_by_lot();
}
}
@@ -2063,7 +2063,7 @@ export class Order extends PosModel {
}
if (options.draftPackLotLines) {
this.selected_orderline.setPackLotLines(options.draftPackLotLines);
this.selected_orderline.setPackLotLines({ ...options.draftPackLotLines, setQuantity: options.quantity === undefined });
}
if (options.comboLines?.length) {