From c2a22b5ac74a9f387e5e7b9b058dafa83eccab7d Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 12 Apr 2023 17:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E6=9D=BF=E6=89=AB=E7=A0=81=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E6=89=98=E7=9B=98=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E8=BF=98=E5=AD=98=E5=9C=A8=E5=B0=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/static/src/js/test.js | 212 +++++++++++++++++++++-- 1 file changed, 193 insertions(+), 19 deletions(-) diff --git a/sf_machine_connect/static/src/js/test.js b/sf_machine_connect/static/src/js/test.js index 1f1c1d58..9744a786 100644 --- a/sf_machine_connect/static/src/js/test.js +++ b/sf_machine_connect/static/src/js/test.js @@ -1,3 +1,85 @@ +// /** @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 {xml, Component} = owl; +// import { standardFieldProps } from "@web/views/fields/standard_field_props"; +// // Import the registry +// import {registry} from "@web/core/registry"; +// +// +// export class CodeField extends Component { +// setup() { +// super.setup(); +// } +// async onBarcodeBtnClick() { +// const barcode = await BarcodeScanner.scanBarcode(); +// if (barcode) { +// await this.onBarcodeScanned(barcode); +// if ("vibrate" in browser.navigator) { +// browser.navigator.vibrate(100); +// } +// } else { +// this.notification.add(this.env._t("Please, scan again !"), { +// type: "warning", +// }); +// } +// } +// async search(barcode) { +// const results = await this.orm.call("sf.tray", "name_search", [code], { +// name: barcode, +// args: this.getDomain(), +// operator: "ilike", +// limit: 2, // If one result we set directly and if more than one we use normal flow so no need to search more +// context: this.context, +// }); +// return results.map((result) => { +// const [id, displayName] = result; +// return { +// id, +// name: displayName, +// }; +// }); +// } +// async onBarcodeScanned(barcode) { +// const results = await this.search(barcode); +// const records = results.filter((r) => !!r.id); +// if (records.length === 1) { +// this.update([{ id: records[0].id, name: records[0].name }]); +// } else { +// const searchInput = this.autocompleteContainerRef.el.querySelector("input"); +// searchInput.value = barcode; +// searchInput.dispatchEvent(new Event("input")); +// if (this.env.isSmall) { +// searchInput.click(); +// } +// } +// } +// } +// +// CodeField.template = xml` +//