[FIX] point_of_sale: correctly set lot_id on refund orders
Current behavior: When refunding an order, the lot_id of the original order was not set on the refund order. Steps to reproduce: - Create a product with tracking by lot - Open the POS and add the product to the order - Set a lot on the product - Pay the order - Refund the order - Check the lot on the refund order, there is no lot set opw-3485740 closes odoo/odoo#136991 X-original-commit: 8868f689f2aea48ca82ee00478083ba72370bfbd Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com> Signed-off-by: Robin Engels (roen) <roen@odoo.com>
This commit is contained in:
@@ -141,6 +141,7 @@
|
||||
('remove', 'point_of_sale/static/src/app/main.js'),
|
||||
# tour system FIXME: can this be added only in test mode? Are there any onboarding tours in PoS?
|
||||
'web/static/lib/jquery/jquery.js',
|
||||
'web/static/src/legacy/js/libs/jquery.js',
|
||||
'web_tour/static/src/tour_pointer/**/*',
|
||||
'web_tour/static/src/tour_service/**/*',
|
||||
],
|
||||
|
||||
@@ -560,6 +560,9 @@ export class TicketScreen extends Component {
|
||||
orderPartnerId,
|
||||
tax_ids: orderline.get_taxes().map((tax) => tax.id),
|
||||
discount: orderline.discount,
|
||||
pack_lot_lines: orderline.pack_lot_lines ? orderline.pack_lot_lines.map(lot => {
|
||||
return { lot_name: lot.lot_name };
|
||||
}) : false,
|
||||
},
|
||||
destinationOrderUid: false,
|
||||
};
|
||||
@@ -592,6 +595,7 @@ export class TicketScreen extends Component {
|
||||
*/
|
||||
_prepareRefundOrderlineOptions(toRefundDetail) {
|
||||
const { qty, orderline } = toRefundDetail;
|
||||
const draftPackLotLines = orderline.pack_lot_lines ? { modifiedPackLotLines: [], newPackLotLines: orderline.pack_lot_lines} : false;
|
||||
return {
|
||||
quantity: -qty,
|
||||
price: orderline.price,
|
||||
@@ -600,6 +604,7 @@ export class TicketScreen extends Component {
|
||||
refunded_orderline_id: orderline.id,
|
||||
tax_ids: orderline.tax_ids,
|
||||
discount: orderline.discount,
|
||||
draftPackLotLines: draftPackLotLines
|
||||
};
|
||||
}
|
||||
_setOrder(order) {
|
||||
|
||||
@@ -212,3 +212,30 @@ registry.category("web_tour.tours").add("FiscalPositionNoTaxRefund", {
|
||||
return getSteps();
|
||||
}
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("LotRefundTour", {
|
||||
test: true,
|
||||
url: "/pos/ui",
|
||||
steps: () => {
|
||||
startSteps();
|
||||
ProductScreen.do.confirmOpeningPopup();
|
||||
ProductScreen.do.clickHomeCategory();
|
||||
ProductScreen.do.clickDisplayedProduct('Product A');
|
||||
ProductScreen.do.enterLotNumber('123456789');
|
||||
ProductScreen.check.selectedOrderlineHas('Product A', '1.00');
|
||||
ProductScreen.do.clickPayButton();
|
||||
PaymentScreen.do.clickPaymentMethod('Bank');
|
||||
PaymentScreen.do.clickValidate();
|
||||
ReceiptScreen.check.isShown();
|
||||
ReceiptScreen.do.clickNextOrder();
|
||||
ProductScreen.do.clickRefund();
|
||||
TicketScreen.do.selectOrder('-0001');
|
||||
ProductScreen.do.pressNumpad('1');
|
||||
TicketScreen.check.toRefundTextContains('To Refund: 1.00');
|
||||
TicketScreen.do.confirmRefund();
|
||||
ProductScreen.check.isShown();
|
||||
ProductScreen.do.clickLotIcon();
|
||||
ProductScreen.check.checkFirstLotNumber('123456789');
|
||||
return getSteps();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -285,6 +285,27 @@ class Do {
|
||||
},
|
||||
];
|
||||
}
|
||||
clickLotIcon() {
|
||||
return [
|
||||
{
|
||||
content: 'click lot icon',
|
||||
trigger: '.line-lot-icon',
|
||||
},
|
||||
];
|
||||
}
|
||||
enterLotNumber(number) {
|
||||
return [
|
||||
{
|
||||
content: 'enter lot number',
|
||||
trigger: '.list-line-input:first()',
|
||||
run: 'text ' + number,
|
||||
},
|
||||
{
|
||||
content: 'click validate lot number',
|
||||
trigger: '.popup .button.confirm',
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class Check {
|
||||
@@ -408,6 +429,15 @@ class Check {
|
||||
},
|
||||
];
|
||||
}
|
||||
checkFirstLotNumber(number) {
|
||||
return [
|
||||
{
|
||||
content: 'Check lot number',
|
||||
trigger: `.popup-input:propValue(${number})`,
|
||||
run: () => {}, // it's a check
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class Execute {
|
||||
|
||||
@@ -1018,6 +1018,19 @@ class TestUi(TestPointOfSaleHttpCommon):
|
||||
self.main_pos_config.open_ui()
|
||||
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'FiscalPositionNoTaxRefund', login="accountman")
|
||||
|
||||
def test_lot_refund(self):
|
||||
|
||||
self.product1 = self.env['product.product'].create({
|
||||
'name': 'Product A',
|
||||
'type': 'product',
|
||||
'tracking': 'serial',
|
||||
'categ_id': self.env.ref('product.product_category_all').id,
|
||||
'available_in_pos': True,
|
||||
})
|
||||
|
||||
self.main_pos_config.open_ui()
|
||||
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'LotRefundTour', login="accountman")
|
||||
|
||||
# This class just runs the same tests as above but with mobile emulation
|
||||
class MobileTestUi(TestUi):
|
||||
browser_size = '375x667'
|
||||
|
||||
Reference in New Issue
Block a user