Skip to content

Commit

Permalink
[DEV] mv_stock_qrcode: update workflow of QR-Code Scanner, Progress: 87%
Browse files Browse the repository at this point in the history
  • Loading branch information
Phat Dang (MoveoPlus) committed Apr 18, 2024
1 parent fc3388d commit 8969632
Show file tree
Hide file tree
Showing 13 changed files with 661 additions and 0 deletions.
1 change: 1 addition & 0 deletions mv_stock_qrcode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import models
6 changes: 6 additions & 0 deletions mv_stock_qrcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
'views/stock_move_line_views.xml',
'views/stock_lot_views.xml',
],
'assets': {
'web.assets_backend': [
'mv_stock_qrcode/static/src/**/*.js',
'mv_stock_qrcode/static/src/**/*.xml',
],
},
'license': 'LGPL-3',
'application': True,
}
2 changes: 2 additions & 0 deletions mv_stock_qrcode/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import stock_barcode
Empty file.
3 changes: 3 additions & 0 deletions mv_stock_qrcode/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class StockMoveLine(models.Model):
help="Help to find the max of number for Lot/Serial Number",
)

# INHERIT Fields:
inventory_period_name = fields.Char(related="inventory_period_id.week_number_str", store=True)

def _get_fields_stock_barcode(self):
fields = super(StockMoveLine, self)._get_fields_stock_barcode()
fields += ["number_call"]
Expand Down
21 changes: 21 additions & 0 deletions mv_stock_qrcode/static/src/components/line.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @odoo-module **/

import { patch } from "@web/core/utils/patch";
import LineComponent from "@stock_barcode/components/line";


patch(LineComponent.prototype, {
/**
* @override by MOVEOPLUS
* [NEW] Add new "qrCode" && "inventoryPeriod"
*/

get qrCode() {
return (this.line.qr_code || '');
},

get inventoryPeriod() {
return (this.line.inventory_period_id && this.line.inventory_period_id.week_number_str) || this.line.inventory_period_name || '';
},

});
14 changes: 14 additions & 0 deletions mv_stock_qrcode/static/src/components/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @odoo-module **/

import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch";
import MainComponent from "@stock_barcode/components/main";


patch(MainComponent.prototype, {

setup(...args) {
super.setup(...args);
}

});
8 changes: 8 additions & 0 deletions mv_stock_qrcode/static/src/components/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-inherit="stock_barcode.MainComponent" t-inherit-mode="extension">
<!-- Type your logic code here...-->
</t>

</templates>
18 changes: 18 additions & 0 deletions mv_stock_qrcode/static/src/lazy_barcode_cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @odoo-module **/

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


patch(LazyBarcodeCache.prototype, {
/**
* @override by MOVEOPLUS
*/

constructor(cacheData) {
this.setup(...arguments);
this.setCache(cacheData);
},

});
14 changes: 14 additions & 0 deletions mv_stock_qrcode/static/src/main_menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @odoo-module **/

import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch";
import { MainMenu } from "@stock_barcode/main_menu";


patch(MainMenu.prototype, {

setup() {
super.setup();
}

});
8 changes: 8 additions & 0 deletions mv_stock_qrcode/static/src/main_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-inherit="stock_barcode.MainMenu" t-inherit-mode="extension">
<!-- Type your logic code here...-->
</t>

</templates>
50 changes: 50 additions & 0 deletions mv_stock_qrcode/static/src/models/barcode_model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** @odoo-module **/

import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch";
import BarcodeModel from "@stock_barcode/models/barcode_model";


patch(BarcodeModel.prototype, {
/**
* @override by MOVEOPLUS
*/

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

// GETTER

get canCreateNewMoveLine() {
return true;
},

get useExistingMoveLine() {
return true;
},

// 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;
},

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

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

});
Loading

0 comments on commit 8969632

Please sign in to comment.