summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js52
1 files changed, 36 insertions, 16 deletions
diff --git a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js
index 97daa35801d..6d3308ee3c3 100644
--- a/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js
+++ b/addons/point_of_sale/static/src/js/Screens/ProductScreen/ProductScreen.js
@@ -62,11 +62,7 @@ odoo.define('point_of_sale.ProductScreen', function(require) {
return true;
return false;
}
- async _clickProduct(event) {
- if (!this.currentOrder) {
- this.env.pos.add_new_order();
- }
- const product = event.detail;
+ async _getAddProductOptions(product) {
let price_extra = 0.0;
let draftPackLotLines, weight, description, packLotLinesToEdit;
@@ -141,14 +137,18 @@ odoo.define('point_of_sale.ProductScreen', function(require) {
}
}
+ return { draftPackLotLines, quantity: weight, description, price_extra };
+ }
+ async _clickProduct(event) {
+ if (!this.currentOrder) {
+ this.env.pos.add_new_order();
+ }
+ const product = event.detail;
+ const options = await this._getAddProductOptions(product);
+ // Do not add product if options is undefined.
+ if (!options) return;
// Add the product after having the extra information.
- this.currentOrder.add_product(product, {
- draftPackLotLines,
- description: description,
- price_extra: price_extra,
- quantity: weight,
- });
-
+ this.currentOrder.add_product(product, options);
NumberBuffer.reset();
}
_setNumpadMode(event) {
@@ -203,11 +203,31 @@ odoo.define('point_of_sale.ProductScreen', function(require) {
}
}
}
- _barcodeProductAction(code) {
- // NOTE: scan_product call has side effect in pos if it returned true.
- if (!this.env.pos.scan_product(code)) {
- this._barcodeErrorAction(code);
+ async _barcodeProductAction(code) {
+ const product = this.env.pos.db.get_product_by_barcode(code.base_code)
+ if (!product) {
+ return this._barcodeErrorAction(code);
+ }
+ const options = await this._getAddProductOptions(product);
+ // Do not proceed on adding the product when no options is returned.
+ // This is consistent with _clickProduct.
+ if (!options) return;
+
+ // update the options depending on the type of the scanned code
+ if (code.type === 'price') {
+ Object.assign(options, { price: code.value });
+ } else if (code.type === 'weight') {
+ Object.assign(options, {
+ quantity: code.value,
+ merge: false,
+ });
+ } else if (code.type === 'discount') {
+ Object.assign(options, {
+ discount: code.value,
+ merge: false,
+ });
}
+ this.currentOrder.add_product(product, options)
}
_barcodeClientAction(code) {
const partner = this.env.pos.db.get_partner_by_barcode(code.code);