Skip to content

Commit

Permalink
[DEV+FIX] mv_stock_qrcode: re-update QR-Code Scanner Workflow and Bar…
Browse files Browse the repository at this point in the history
…code Scanner Workflow
  • Loading branch information
Phat Dang (MoveoPlus) committed Apr 20, 2024
1 parent 8969632 commit 136d982
Show file tree
Hide file tree
Showing 4 changed files with 457 additions and 248 deletions.
1 change: 0 additions & 1 deletion mv_stock_qrcode/static/src/components/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import LineComponent from "@stock_barcode/components/line";
patch(LineComponent.prototype, {
/**
* @override by MOVEOPLUS
* [NEW] Add new "qrCode" && "inventoryPeriod"
*/

get qrCode() {
Expand Down
7 changes: 3 additions & 4 deletions mv_stock_qrcode/static/src/lazy_barcode_cache.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @odoo-module **/

import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch";
import LazyBarcodeCache from '@stock_barcode/lazy_barcode_cache';

Expand All @@ -10,9 +9,9 @@ patch(LazyBarcodeCache.prototype, {
* @override by MOVEOPLUS
*/

constructor(cacheData) {
this.setup(...arguments);
this.setCache(cacheData);
_constructor() {
super._constructor(...arguments);
this.barcodeFieldByModel['stock.move.line'] = 'qr_code';
},

});
59 changes: 35 additions & 24 deletions mv_stock_qrcode/static/src/models/barcode_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,52 @@ patch(BarcodeModel.prototype, {
* @override by MOVEOPLUS
*/

setData(data) {
super.setData(...arguments);
super.setData(data);
constructor() {
super.setup(...arguments);
},

// GETTER

get canCreateNewMoveLine() {
return true;
},

get useExistingMoveLine() {
return true;
setData() {
super.setData(...arguments);
},

// ACTIONS

async processBarcode(barcode) {
console.debug("MOVEOPLUS Debugging on Model: " + this.resModel);
// console.debug("Print Cache: " + JSON.stringify(this.cache));
this.actionMutex.exec(() => this._processBarcode(barcode));
},

createNewLine(params) {
// return this._createNewLine(params);
console.debug("Params Creation: " + params);
return;
const codeScanning = barcode;
let scanningQRCode = false;
let scanningBarcode = false;

let moveLinesObj = Object.values(this.cache.dbIdCache['stock.move.line']);
if (moveLinesObj) {
let listQRCodeToCompare = moveLinesObj.map(rec => rec.qr_code);
if (listQRCodeToCompare.includes(codeScanning)) {
scanningQRCode = true;
} else {
scanningBarcode = true;
}
} else {
scanningBarcode = true;
}

// Validate: Picking DONE
if (this.isDone && !this.commands[codeScanning]) {
return this.notification(_t("Picking is already DONE!"), { type: "danger" });
}

if (scanningQRCode) {
const moveLineObj = await this.orm.searchRead(
"stock.move.line",
[["picking_id", "in", this.recordIds], ["qr_code", "=", codeScanning]],
["id", "product_id", "lot_name", "inventory_period_name", "qr_code", "quantity"]
);
this.actionMutex.exec(() => this._processQRCode(codeScanning, moveLineObj));
} else {
this.actionMutex.exec(() => this._processBarcode(codeScanning));
}
},

// --------------------------------------------------------------------------
// Private
// --------------------------------------------------------------------------

_shouldSearchForAnotherMoveLine(code, filters) {
return !code.match && filters['stock.move.line'] && !this.canCreateNewMoveLine && this.useExistingMoveLine;
},

});
Loading

0 comments on commit 136d982

Please sign in to comment.