From f1c67e5be1c614005624a57e1d937b5b8cb89e4e Mon Sep 17 00:00:00 2001 From: "Pedram (PEBR)" Date: Thu, 17 Aug 2023 15:12:23 +0000 Subject: [PATCH] [FIX] point_of_sale: scanning barcode should not update available_in_pos Prior to this commit, when limited product loading was enabled, scanning a product that had not been loaded yet would trigger a search for the product without taking into account the available_in_pos field, and it would also set available_in_pos to true. This commit ensures that when a product is loaded using its barcode, the behavior aligns with the changes introduced in this commit: https://github.com/odoo/odoo/pull/87329/commits/a83c7aea37b06e8b1f04f1f02982ff577d7058e9 opw-3463427 closes odoo/odoo#134038 X-original-commit: 4fee329af13d9335f743aae39ff1a4b6ad4ee0f5 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Pedram Bi Ria (pebr) --- addons/point_of_sale/models/pos_session.py | 6 +++++- .../static/src/app/screens/product_screen/product_screen.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 33be30f5450..c587c16f99c 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -2096,7 +2096,11 @@ class PosSession(models.Model): return partners def find_product_by_barcode(self, barcode): - product = self.env['product.product'].search([['barcode', '=', barcode], ['sale_ok', '=', True]]) + product = self.env['product.product'].search([ + ('barcode', '=', barcode), + ('sale_ok', '=', True), + ('available_in_pos', '=', True), + ]) if product: return {'product_id': [product.id]} diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js index 69a1433db7a..4799edc2ec3 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js @@ -174,7 +174,7 @@ export class ProductScreen extends ControlButtonsMixin(Component) { [odoo.pos_session_id, code.base_code], ); if (product_id.length) { - await this.pos._addProducts(product_id); + await this.pos._addProducts(product_id, false); if (packaging.length) { this.pos.db.add_packagings(packaging); }