2017-02-02 128 views
2

我想添加一个按钮到POS屏幕。我有很多这方面的信息与Odoo 8有关,这可能是为什么它不起作用。我安装了自定义插件没有任何错误,但我没有看到按钮。运行POS时我也没有遇到任何错误。在第8版有一个widgets.js文件,其中包括Odoo 10添加按钮到POS

module.PosWidget.include({ 
     build_widgets: function(){ 
     var self = this; 
     this._super() 

有版本10没有widgets.js,我猜这是我的问题。它只是一个猜测,我真的不知道如何添加一个按钮到POS。

这里是我的pos_custom.js

odoo.pos_custom = function(instance){ 
    var module = instance.point_of_sale; 
    var round_pr = instance.web.round_precision 
    var QWeb = instance.web.qweb; 

    console.log("POS JS Loaded") 
    module.PosWidget.include({ 
     build_widgets: function(){ 
     var self = this; 
     this._super() 

     custom_btn = $(QWeb.render(`custom_btn`)) 
     custom_btn.click(function(){ 
      alert("hello") 
     }) 
     console.log("button <<<>>> ",custom_btn,this.$(`.control-button`)) 
     custom_btn.appendTo(this.$(`.control-button`)) 


     this.$control_buttons`).removeClass(`oe_hidden`) 


      } 
}) 

}; 

我/src/xml/pos_custom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<templates xml="template" xml:space="preserve"> 

    <t t-name="custom_btn"> 
     <button>Cust Button</button> 
    </t> 

</templates> 

我/views/templates.xml

<?xml version="1.0"?> 
<openerp> 
    <data> 
     <template id="assets_backend" name="pos_custom assets" inherit_id="web.assets_backend"> 
      <xpath expr="." position="inside"> 

       <script type="text/javascript" src="/pos_custom/static/src/js/pos_custom.js"></script> 
       </xpath> 
      </template> 

    </data> 
</openerp> 

清单 .py

{ 
    'name': 'Point Custom Module', 
    'version': '1.2', 
    'category': 'Point of Sale', 
    'summary': 'Custom Point of Sale ', 
    'description': "", 
    'data': [ 
     "views/templates.xml" 

    ], 
    'depends': ['point_of_sale'], 


    'qweb': ['static/src/xml/*.xml'], 
    'application': True, 


} 

回答

1

有关具体示例,请查看addons/pos_discount/static/src/js/discount.js。你可以在这里看到一个标签为Discount的按钮被添加到Odoo POS的其中一个屏幕中。检查整个模块,因为什么是基本不被添加在POS(附截图)的动作按钮一个按钮

enter image description here

还要检查addons/pos_discount/static/src/xml/discount_templates.xml的模板按钮的布局。

0

也许你应该改变你的代码

id="assets_backend"id="assets"&

inherit_id="web.assets_backend"inherit_id="point_of_sale.assets"