|
@ -1,17 +1,19 @@ |
|
|
/** @odoo-module */ |
|
|
/** @odoo-module */ |
|
|
|
|
|
|
|
|
import { patch } from "@web/core/utils/patch"; |
|
|
import { patch } from "@web/core/utils/patch"; |
|
|
import { PosDB } from "@point_of_sale/app/store/db"; |
|
|
import { PosDB } from "@point_of_sale/app/store/db"; |
|
|
import { unaccent } from "@web/core/utils/strings"; |
|
|
import { unaccent } from "@web/core/utils/strings"; |
|
|
import { jsonrpc } from "@web/core/network/rpc_service"; |
|
|
import { jsonrpc } from "@web/core/network/rpc_service"; |
|
|
import { DebugWidget } from "@point_of_sale/app/debug/debug_widget"; |
|
|
import { DebugWidget } from "@point_of_sale/app/debug/debug_widget"; |
|
|
import { useService } from "@web/core/utils/hooks"; |
|
|
import { useService } from "@web/core/utils/hooks"; |
|
|
|
|
|
import { Dialog } from "@web/core/dialog/dialog"; |
|
|
|
|
|
import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; |
|
|
|
|
|
import { _t } from "@web/core/l10n/translation"; |
|
|
|
|
|
|
|
|
patch(DebugWidget.prototype, { |
|
|
patch(DebugWidget.prototype, { |
|
|
setup() { |
|
|
setup() { |
|
|
super.setup() |
|
|
super.setup() |
|
|
this.orm = useService("orm"); |
|
|
this.orm = useService("orm"); |
|
|
|
|
|
this.dialog = useService("dialog"); |
|
|
}, |
|
|
}, |
|
|
async barcodeScan() { |
|
|
async barcodeScan() { |
|
|
if (!this.barcodeReader) { |
|
|
if (!this.barcodeReader) { |
|
@ -21,9 +23,15 @@ patch(DebugWidget.prototype, { |
|
|
if (data[1]){ |
|
|
if (data[1]){ |
|
|
this.currentOrder = this.pos.get_order(); |
|
|
this.currentOrder = this.pos.get_order(); |
|
|
var product = this.pos.db.get_product_by_id(parseInt(data[1])) |
|
|
var product = this.pos.db.get_product_by_id(parseInt(data[1])) |
|
|
|
|
|
if(product){ |
|
|
this.currentOrder.add_product(product); |
|
|
this.currentOrder.add_product(product); |
|
|
} |
|
|
} |
|
|
else{ |
|
|
else{ |
|
|
|
|
|
this.dialog.add(AlertDialog, { |
|
|
|
|
|
body: _t("Product is not loaded in the POS"), |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} else{ |
|
|
await this.barcodeReader.scan(this.state.barcodeInput); |
|
|
await this.barcodeReader.scan(this.state.barcodeInput); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|