测试优化代码后的代码扫描效果,优化部分代码审查问题
This commit is contained in:
@@ -1,29 +1,23 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { _lt } from "@web/core/l10n/translation";
|
||||
import { useChildRef, useOwnedDialogs, useService } from "@web/core/utils/hooks";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
import { isMobileOS } from "@web/core/browser/feature_detection";
|
||||
import * as BarcodeScanner from "@web/webclient/barcode/barcode_scanner";
|
||||
const { useRef } = owl;
|
||||
const {xml, Component} = owl;
|
||||
const { Component } = owl;
|
||||
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
||||
import {registry} from "@web/core/registry";
|
||||
import {useInputField} from "@web/views/fields/input_field_hook";
|
||||
|
||||
export class CodeField extends Component {
|
||||
setup() {
|
||||
console.log('CodeField created')
|
||||
console.log('this',this)
|
||||
console.log('this.props',this.props)
|
||||
console.log('this.props.record',this.props.value)
|
||||
// console.log('CodeField created')
|
||||
// console.log('this',this)
|
||||
// console.log('this.props',this.props)
|
||||
// console.log('this.props.record',this.props.value)
|
||||
useInputField({
|
||||
getValue: () => this.props.value,
|
||||
refName: "scan_code",
|
||||
});
|
||||
console.log('我是setup1')
|
||||
// console.log('我是setup1')
|
||||
super.setup();
|
||||
this.orm = this.env.services.orm;
|
||||
this.record = this.props.record;
|
||||
@@ -45,12 +39,12 @@ export class CodeField extends Component {
|
||||
async search(barcode) {
|
||||
// alert('我是search')
|
||||
const domain = [["code", "=", barcode]];
|
||||
console.log(domain)
|
||||
// console.log(domain)
|
||||
const fields = ["id", "code", "name", "state"];
|
||||
console.log(fields)
|
||||
// console.log(fields)
|
||||
const results = await this.orm.call("sf.tray", "search_read", [domain, fields]);
|
||||
const values = await this.orm.call("sf.tray", "search_read", [domain]);
|
||||
console.log(results)
|
||||
// console.log(results)
|
||||
return results.map((result) => {
|
||||
return {
|
||||
id: result.id,
|
||||
@@ -63,16 +57,16 @@ export class CodeField extends Component {
|
||||
}
|
||||
async onBarcodeScanned(barcode) {
|
||||
const results = await this.search(barcode);
|
||||
console.log(results)
|
||||
// console.log(results)
|
||||
const records = results.filter((r) => !!r.id);
|
||||
console.log(records)
|
||||
// console.log(records)
|
||||
if (records.length === 1) {
|
||||
if (records[0].state === '空闲') {
|
||||
console.log('currentModel',this)
|
||||
console.log('this.record.data',this.record.data)
|
||||
console.log('this.record.data.id', this.record.data.id)
|
||||
// console.log('currentModel',this)
|
||||
// console.log('this.record.data',this.record.data)
|
||||
// console.log('this.record.data.id', this.record.data.id)
|
||||
const workorder = await this.orm.call('mrp.workorder', 'read', [this.record.data.id]);
|
||||
console.log('workorder', workorder[0])
|
||||
// console.log('workorder', workorder[0])
|
||||
const updatedRecord = await this.orm.call("sf.tray", "write", [
|
||||
[records[0].id],
|
||||
{
|
||||
@@ -81,31 +75,32 @@ export class CodeField extends Component {
|
||||
production_id: workorder[0].product_id[0],
|
||||
// workorder_id: workorder.id,
|
||||
}]);
|
||||
console.log(workorder[0].routing_type);
|
||||
console.log(workorder[0].production_id);
|
||||
// console.log(workorder[0].routing_type);
|
||||
// console.log(workorder[0].production_id);
|
||||
// const productionIDS = await this.orm.call('mrp.production', 'search', [[['id', '=', workorder[0].production_id[0]]]]);
|
||||
const productionIDS = await this.orm.call('mrp.workorder', 'search', [[["production_id", "=", workorder[0].production_id[0]]]]);
|
||||
console.log('prooooooo', productionIDS);
|
||||
console.log('values', records[0].values[0]);
|
||||
// console.log('prooooooo', productionIDS);
|
||||
// console.log('values', records[0].values[0]);
|
||||
productionIDS.forEach(async (data) => {
|
||||
// 处理每一个数据
|
||||
console.log(data);
|
||||
// console.log(data);
|
||||
const updatetrayRecord = await this.orm.call("mrp.workorder", "write", [
|
||||
[data],
|
||||
{
|
||||
tray_id: records[0].values[0].id,
|
||||
// tray_id: false,
|
||||
}]);
|
||||
console.log(updatetrayRecord)
|
||||
// console.log(updatetrayRecord)
|
||||
});
|
||||
this.props.update(records[0].code);
|
||||
$('.o_form_button_save').click();
|
||||
} else {
|
||||
if (records[0].state === '占用') {
|
||||
console.log('此托盘已占用,请检查')
|
||||
// console.log('此托盘已占用,请检查')
|
||||
alert('此托盘已占用,请检查')
|
||||
} else {
|
||||
console.log('此托盘已损坏,请登记')
|
||||
// console.log('此托盘已损坏,请登记')
|
||||
alert('此托盘已损坏,请登记')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,7 @@ const { Component, xml } = owl;
|
||||
|
||||
export class BarcodeHandlerField extends Component {
|
||||
setup() {
|
||||
console.log('99999999111');
|
||||
this.actionService = useService("action")
|
||||
console.log(this.actionService)
|
||||
|
||||
const barcode = useService("barcode");
|
||||
// this.rpc = useService("rpc");
|
||||
// useBus(barcode.bus, "barcode_scanned", this.onBarcodeScanned.bind(this));
|
||||
@@ -20,9 +17,6 @@ export class BarcodeHandlerField extends Component {
|
||||
async _rpc(params) {
|
||||
// const { data } = await this.env.services.rpc('/web/dataset/call_kw', params);
|
||||
const response = await this.env.services.rpc('/web/dataset/call_kw', params);
|
||||
console.log('response', response);
|
||||
console.log('response.result', response.result);
|
||||
|
||||
// return response
|
||||
const responseObject = JSON.parse(response)
|
||||
return responseObject;
|
||||
@@ -33,8 +27,6 @@ export class BarcodeHandlerField extends Component {
|
||||
this.props.update(barcode);
|
||||
// const actionService = useService("action");
|
||||
// const productId = 12345
|
||||
console.log('111222222222211111');
|
||||
|
||||
// 根据条形码获取相关数据,例如产品ID
|
||||
const response = await this._rpc({
|
||||
model: 'mrp.workorder',
|
||||
@@ -42,11 +34,10 @@ export class BarcodeHandlerField extends Component {
|
||||
args: [barcode],
|
||||
kwargs:{},
|
||||
});
|
||||
// console.log(productId.result)
|
||||
if (response.result) {
|
||||
const action = response.result;
|
||||
console.log(action)
|
||||
console.log('11111111111111111111111111111111111');
|
||||
// const action = response.result;
|
||||
// console.log(action)
|
||||
// console.log('11111111111111111111111111111111111');
|
||||
// 通过产品ID执行操作并跳转到表单视图
|
||||
// await this.actionService.doAction({
|
||||
// // type: 'ir.actions.act_window',
|
||||
|
||||
Reference in New Issue
Block a user