在 Odoo 14 中创建客户端操作
Create a client action in Odoo 14
我正在尝试创建客户端操作小部件,但在单击菜单项时出现错误。
这是错误。
Traceback:
Error: widget.getTitle is not a function
_executeClientAction@http://localhost:5014/web/static/src/js/chrome/action_manager.js:449:27
_handleAction@http://localhost:5014/web/static/src/js/chrome/action_manager.js:670:29
*.js
odoo.define('mobile_basket_verification.BasketVerification', function (require){
'use strict';
var core = require('web.core');
var Widget = require('web.Widget');
// var ClientAction = require('stock_barcode.ClientAction');
// var ViewsWidget = require('stock_barcode.ViewsWidget');
var Qweb = core.qweb;
var _t = core._t;
var BasketWidget = Widget.extend({
// template:'BasketVerificationComponent',
contentTemplate:'BasketVerificationComponent',
init: function(parent,action){
this._super.apply(this, arguments);
},
start: function() {
this._super.apply(this, arguments);
console.log('Widget Start')
},
});
core.action_registry.add('basket_verification_client_action',BasketWidget);
return BasketWidget;
});
*static.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="mobile_basket_verification.BasketVerificationComponent">
<div class="o_barcode_message d-flex flex-column justify-content-center align-items-center bg-800">
<div class="o_barcode_pic position-relative text-center mt-2 mb-1">
<i class="fa fa-5x mx-auto fa-exclamation-triangle text-white d-none"/>
<img class="o_barcode_icon" src="/stock_barcode/static/img/barcode.svg" alt="Barcode" height="40px"/>
</div>
<div class="basket_barcode d-flex" style="float:right;width:400px;margin-right:200px;">
<span>Basket </span>
<input type="text" class="o_field_char basket_barcode_input" style="width:100px"/>
<button class="btn btn-primary verify_basket">Add</button>
</div>
</div>
<div class="o_barcode_lines_header alert mb-0"></div>
<div class="o_barcode_lines list-group flex-grow-1 d-block position-relative"></div>
</t>
</templates>
*.Menuitem
<menuitem id="basket_verification_client_action_menu" name="Basket Verification11" parent=""
action="basket_verification_client_action"/>
客户端动作。
<odoo>
<record id="basket_verification_client_action" model="ir.actions.client">
<field name="name">Basket Verification Client Action</field>
<field name="tag">basket_verification_client_action</field>
</record>
</odoo>
请帮我解决这个错误。
改为扩展 AbstractAction
。
var BasketWidget = AbstractAction.extend({
});
查看 Client actions 文档:
from the perspective of the web client, it is a widget, which inherit from the class AbstractAction
, and is supposed to be registered in the action registry under the corresponding key (from the field char)
我正在尝试创建客户端操作小部件,但在单击菜单项时出现错误。 这是错误。
Traceback:
Error: widget.getTitle is not a function
_executeClientAction@http://localhost:5014/web/static/src/js/chrome/action_manager.js:449:27
_handleAction@http://localhost:5014/web/static/src/js/chrome/action_manager.js:670:29
*.js
odoo.define('mobile_basket_verification.BasketVerification', function (require){
'use strict';
var core = require('web.core');
var Widget = require('web.Widget');
// var ClientAction = require('stock_barcode.ClientAction');
// var ViewsWidget = require('stock_barcode.ViewsWidget');
var Qweb = core.qweb;
var _t = core._t;
var BasketWidget = Widget.extend({
// template:'BasketVerificationComponent',
contentTemplate:'BasketVerificationComponent',
init: function(parent,action){
this._super.apply(this, arguments);
},
start: function() {
this._super.apply(this, arguments);
console.log('Widget Start')
},
});
core.action_registry.add('basket_verification_client_action',BasketWidget);
return BasketWidget;
});
*static.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="mobile_basket_verification.BasketVerificationComponent">
<div class="o_barcode_message d-flex flex-column justify-content-center align-items-center bg-800">
<div class="o_barcode_pic position-relative text-center mt-2 mb-1">
<i class="fa fa-5x mx-auto fa-exclamation-triangle text-white d-none"/>
<img class="o_barcode_icon" src="/stock_barcode/static/img/barcode.svg" alt="Barcode" height="40px"/>
</div>
<div class="basket_barcode d-flex" style="float:right;width:400px;margin-right:200px;">
<span>Basket </span>
<input type="text" class="o_field_char basket_barcode_input" style="width:100px"/>
<button class="btn btn-primary verify_basket">Add</button>
</div>
</div>
<div class="o_barcode_lines_header alert mb-0"></div>
<div class="o_barcode_lines list-group flex-grow-1 d-block position-relative"></div>
</t>
</templates>
*.Menuitem
<menuitem id="basket_verification_client_action_menu" name="Basket Verification11" parent=""
action="basket_verification_client_action"/>
客户端动作。
<odoo>
<record id="basket_verification_client_action" model="ir.actions.client">
<field name="name">Basket Verification Client Action</field>
<field name="tag">basket_verification_client_action</field>
</record>
</odoo>
请帮我解决这个错误。
改为扩展 AbstractAction
。
var BasketWidget = AbstractAction.extend({
});
查看 Client actions 文档:
from the perspective of the web client, it is a widget, which inherit from the class
AbstractAction
, and is supposed to be registered in the action registry under the corresponding key (from the field char)