From a2be3a0dbf74604644008e124e1495aacb00f540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 16 Jul 2025 14:32:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99=E7=9A=84js?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/src/js/custom_barcode_handlers.js | 62 ------------------- sf_base/static/src/js/remove_focus.js | 42 ------------- sf_manufacturing/__manifest__.py | 2 +- 3 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 sf_base/static/src/js/custom_barcode_handlers.js delete mode 100644 sf_base/static/src/js/remove_focus.js diff --git a/sf_base/static/src/js/custom_barcode_handlers.js b/sf_base/static/src/js/custom_barcode_handlers.js deleted file mode 100644 index 18db64e7..00000000 --- a/sf_base/static/src/js/custom_barcode_handlers.js +++ /dev/null @@ -1,62 +0,0 @@ -/** @odoo-module **/ - -import { registry } from "@web/core/registry"; -import { barcodeGenericHandlers } from '@barcodes/barcode_handlers'; -import { patch } from "@web/core/utils/patch"; - -// 定义新的 clickOnButton 函数 -function customClickOnButton(selector) { - console.log("This is the custom clickOnButton function!"); - - const buttons = document.body.querySelectorAll(selector); - - let length = buttons.length; - if (length > 0) { - buttons[length - 1].click(); - } else { - console.warn(`Button with selector ${selector} not found`); - } -} - -patch(barcodeGenericHandlers, "start", { - start(env, { ui, barcode, notification }) { - // 使用新定义的 clickOnButton 函数 - const COMMANDS = { - "O-CMD.EDIT": () => customClickOnButton(".o_form_button_edit"), - "O-CMD.DISCARD": () => customClickOnButton(".o_form_button_cancel"), - "O-CMD.SAVE": () => customClickOnButton(".o_form_button_save"), - "O-CMD.PREV": () => customClickOnButton(".o_pager_previous"), - "O-CMD.NEXT": () => customClickOnButton(".o_pager_next"), - "O-CMD.PAGER-FIRST": () => updatePager("first"), - "O-CMD.PAGER-LAST": () => updatePager("last"), - "O-CMD.CONFIRM": () => customClickOnButton(".jikimo_button_confirm"), - "O-CMD.FLUSHED": () => customClickOnButton(".jikimo_button_flushed"), - }; - - barcode.bus.addEventListener("barcode_scanned", (ev) => { - const barcode = ev.detail.barcode; - if (barcode.startsWith("O-BTN.")) { - let targets = []; - try { - targets = getVisibleElements(ui.activeElement, `[barcode_trigger=${barcode.slice(6)}]`); - } catch (_e) { - console.warn(`Barcode '${barcode}' is not valid`); - } - for (let elem of targets) { - elem.click(); - } - } - if (barcode.startsWith("O-CMD.")) { - const fn = COMMANDS[barcode]; - if (fn) { - fn(); - } else { - notification.add(env._t("Barcode: ") + `'${barcode}'`, { - title: env._t("Unknown barcode command"), - type: "danger" - }); - } - } - }); - } -}) diff --git a/sf_base/static/src/js/remove_focus.js b/sf_base/static/src/js/remove_focus.js deleted file mode 100644 index 9a524360..00000000 --- a/sf_base/static/src/js/remove_focus.js +++ /dev/null @@ -1,42 +0,0 @@ -/** @odoo-module **/ - -import { registry } from '@web/core/registry'; - -import { formView } from '@web/views/form/form_view'; -import { FormController } from '@web/views/form/form_controller'; - -import { listView } from '@web/views/list/list_view'; -import { ListController } from '@web/views/list/list_controller' - -import { onRendered, onMounted } from "@odoo/owl"; - -export class RemoveFocusFormController extends FormController { - setup() { - super.setup(); - - onMounted(() => { - this.__owl__.bdom.el.querySelectorAll(':focus').forEach(element => element.blur()); - }) - } -} - -registry.category('views').add('remove_focus_form_view', { - ...formView, - Controller: RemoveFocusFormController, -}); - - -export class RemoveFocusListController extends ListController { - setup() { - super.setup(); - - onMounted(() => { - this.__owl__.bdom.el.querySelectorAll(':focus').forEach(element => element.blur()); - }) - } -} - -registry.category('views').add('remove_focus_list_view', { - ...listView, - Controller: RemoveFocusListController, -}); \ No newline at end of file diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index f30c1300..0d67a3da 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -11,7 +11,7 @@ 'category': 'sf', 'website': 'https://www.sf.jikimo.com', 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse', 'jikimo_attachment_viewer', - 'jikimo_sale_multiple_supply_methods', 'product'], + 'jikimo_sale_multiple_supply_methods', 'product', 'jikimo_tree_header_buttons_always_visible'], 'data': [ 'data/cron_data.xml', 'data/stock_data.xml',