diff --git a/addons/point_of_sale/__manifest__.py b/addons/point_of_sale/__manifest__.py index 40fd1c203ee..0bd9ffd40aa 100644 --- a/addons/point_of_sale/__manifest__.py +++ b/addons/point_of_sale/__manifest__.py @@ -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/**/*', ], diff --git a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js index 32ede57f24b..5bfc951ee9b 100644 --- a/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js +++ b/addons/point_of_sale/static/src/app/screens/ticket_screen/ticket_screen.js @@ -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) { diff --git a/addons/point_of_sale/static/tests/tours/TicketScreen.tour.js b/addons/point_of_sale/static/tests/tours/TicketScreen.tour.js index 682bb4c448e..ba040d4f7b2 100644 --- a/addons/point_of_sale/static/tests/tours/TicketScreen.tour.js +++ b/addons/point_of_sale/static/tests/tours/TicketScreen.tour.js @@ -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(); + } +}); diff --git a/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js b/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js index eb7b48dc346..d4f2f370c4b 100644 --- a/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js +++ b/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js @@ -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 { diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py index 911d72d8b08..78722d189cd 100644 --- a/addons/point_of_sale/tests/test_frontend.py +++ b/addons/point_of_sale/tests/test_frontend.py @@ -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'