质量模块和库存扫码

This commit is contained in:
qihao.gong@jikimo.com
2023-07-24 11:42:15 +08:00
parent 8d024ad625
commit 3c89404543
228 changed files with 142596 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
/** @odoo-module */
import { KanbanController } from '@web/views/kanban/kanban_controller';
import { bus } from 'web.core';
const { onMounted, onWillUnmount } = owl;
export class StockBarcodeKanbanController extends KanbanController {
setup() {
super.setup(...arguments);
onMounted(() => {
bus.on('barcode_scanned', this, this._onBarcodeScannedHandler);
document.activeElement.blur();
});
onWillUnmount(() => {
bus.off('barcode_scanned', this, this._onBarcodeScannedHandler);
});
}
openRecord(record) {
this.actionService.doAction('stock_barcode.stock_barcode_picking_client_action', {
additionalContext: { active_id: record.resId },
});
}
async createRecord() {
const action = await this.model.orm.call(
'stock.picking',
'action_open_new_picking',
[], { context: this.props.context }
);
if (action) {
return this.actionService.doAction(action);
}
return super.createRecord(...arguments);
}
// --------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* Called when the user scans a barcode.
*
* @param {String} barcode
*/
async _onBarcodeScannedHandler(barcode) {
if (this.props.resModel != 'stock.picking') {
return;
}
const kwargs = { barcode, context: this.props.context };
const res = await this.model.orm.call(this.props.resModel, 'filter_on_barcode', [], kwargs);
if (res.action) {
this.actionService.doAction(res.action);
} else if (res.warning) {
const params = { title: res.warning.title, type: 'danger' };
this.model.notificationService.add(res.warning.message, params);
}
}
}

View File

@@ -0,0 +1,18 @@
/** @odoo-module */
import { KanbanRenderer } from '@web/views/kanban/kanban_renderer';
import { useService } from '@web/core/utils/hooks';
const { onWillStart } = owl;
export class StockBarcodeKanbanRenderer extends KanbanRenderer {
setup() {
super.setup(...arguments);
const user = useService('user');
this.display_protip = this.props.list.resModel === 'stock.picking';
onWillStart(async () => {
this.packageEnabled = await user.hasGroup('stock.group_tracking_lot');
});
}
}
StockBarcodeKanbanRenderer.template = 'stock_barcode.KanbanRenderer';

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="stock_barcode.KanbanRenderer" t-inherit="web.KanbanRenderer" owl="1">
<xpath expr="//div[hasclass('o_kanban_renderer')]" position="before">
<div t-if="display_protip" class="o_kanban_tip_filter text-center h5 w-100 mt-4 mb-2">
<p t-if="packageEnabled">Scan a transfer, a product or a package to filter your records</p>
<p t-else="">Scan a transfer or a product to filter your records</p>
</div>
</xpath>
</t>
</templates>

View File

@@ -0,0 +1,12 @@
/** @odoo-module */
import { kanbanView } from '@web/views/kanban/kanban_view';
import { registry } from "@web/core/registry";
import { StockBarcodeKanbanController } from './stock_barcode_kanban_controller';
import { StockBarcodeKanbanRenderer } from './stock_barcode_kanban_renderer';
export const stockBarcodeKanbanView = Object.assign({}, kanbanView, {
Controller: StockBarcodeKanbanController,
Renderer: StockBarcodeKanbanRenderer,
});
registry.category("views").add("stock_barcode_list_kanban", stockBarcodeKanbanView);