[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) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
Pedram (PEBR)
2023-09-04 09:19:16 +00:00
parent b580444adc
commit f1c67e5be1
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -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]}
@@ -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);
}