Javascript odoo 10扫描条形码并开始操作
Javascript odoo 10扫描条形码并开始操作,javascript,python,odoo,Javascript,Python,Odoo,使用odoo 10在我的模块中,我通过创建带有条形码的维修单来管理我的车间,因此我要做的是通过使用条形码扫描仪读取条形码值来单击按钮启动\u btn,这样我可以在扫描维修单后启动计时器,在我的方法eon\u barcode\u scanned中,我调用了toggle\u start按钮状态发生了变化,但计时器没有启动 有人告诉我,我必须使用javascript才能神奇地点击按钮,但我不知道该怎么做,等待你的帮助 提前谢谢,敬请原谅 class project_task(models.Model)
使用odoo 10
在我的模块中,我通过创建带有条形码的维修单来管理我的车间,因此我要做的是通过使用条形码扫描仪读取条形码值来单击按钮启动\u btn
,这样我可以在扫描维修单后启动计时器,在我的方法eon\u barcode\u scanned
中,我调用了toggle\u start
按钮状态发生了变化,但计时器没有启动
有人告诉我,我必须使用javascript才能神奇地点击按钮,但我不知道该怎么做,等待你的帮助
提前谢谢,敬请原谅
class project_task(models.Model):
_name = 'project.task'
_inherit = ['project.task', 'barcodes.barcode_events_mixin']
# _barcode_scanned is in the formview
_barcode_scanned = fields.Char("Barcode Scanned", help="Value of the last barcode scanned.", store=False)
def on_barcode_scanned(self, barcode):
self.toggle_start()
我认为:
<div name="button_box" position="inside">
<field name='test_barcode' options="{'barcode_events': 'True'}" widget="field_float_scannable"/>
<button name="toggle_start" id="start_btn" type="object"
class="oe_stat_button" icon="fa-clock-o">
<field name="task_timer" widget="boolean_button"
options='{"terminology": {
"string_true": "Started",
"hover_true": "Pause",
"string_false": "Timer",
"hover_false": "Start"
}}'/>
</button>
</div>
我对
arodoo\u stock\u barcode
模块和project\u task\u timer
您尝试使用的模块进行深入研究后发现:
- 您必须在型号
\u条形码\u扫描的
字段中添加
class project_task(models.Model): _name = 'project.task' _inherit = ['project.task', 'barcodes.barcode_events_mixin'] # _barcode_scanned is in the formview _barcode_scanned = fields.Char("Barcode Scanned", help="Value of the last barcode scanned.", store=False) test_barcode = fields.Char("barcode")
- 不要在扫描的条形码上使用
方法:只使用一个javascript文件,如何操作:。
odoo.define('project_task_timer.MyScript', function (require) { "use strict"; var core = require('web.core'); var Model = require('web.Model'); var flag = false; var FormViewBarcodeHandler = require('barcodes.FormViewBarcodeHandler'); var _t = core._t; var MyScript = FormViewBarcodeHandler.extend({ init: function (parent, context) { if (parent.ViewManager.action) { this.form_view_initial_mode = parent.ViewManager.action.context.form_view_initial_mode; } else if (parent.ViewManager.view_form) { this.form_view_initial_mode = parent.ViewManager.view_form.options.initial_mode; } }, start: function () { }); }, pre_onchange_hook: function (barcode) { var barcode_filed = this.form_view.datarecord.test_barcode; var deferred = $.Deferred(); if (barcode_filed === barcode) { // to change the stage from new to being serviced $(".o_form_view ul.oe_form_status_clickable li:nth-child(2)").click(); $(".oe_button_box button:nth-child(3)").click(); return deferred.reject(); } }, open_wizard: function (action) { var self = this; this.form_view.trigger('detached'); this.do_action(action, { on_close: function () { self.form_view.trigger('attached'); self.form_view.reload(); } }); } }); core.form_widget_registry.add('myscript', MyScript); return MyScript; });
on\u barcode\u scanned
methode,您可以这样做,但不能使用python单击按钮
祝你好运。嗨,我编辑了你的问题,添加了odoo-10标签,并改进了一些格式,使你的问题问得很好,更容易找到/回答,但我不知道你为什么要把它回滚?我错过了什么?伊玛德先生我现在真的需要你的帮助@伊马德