Odoo 10 - 扩展销售点模块的Javascript

时间:2017-07-14 01:59:19

标签: openerp odoo-10 point-of-sale

我想从 point_of_sale 模块覆盖 ReceiptScreen 方法。

var ReceiptScreenWidget = ScreenWidget.extend...

gui.define_screen({name:'receipt', widget: ReceiptScreenWidget});

为了做到这一点,我已经创建了自己的模块,但我不知道更改 ReceiptScreenWidget.print()功能后面的步骤。

这是包含我要覆盖的Widget.Function的screens.js。 (搜索:ReceiptScreenWidget)

我尝试遵循此example,但代码来自Odoo 8或9,因此我无法使其正常工作。

* Odoo版本:10

1 个答案:

答案 0 :(得分:5)

<强> JS

odoo.define('your_module_name.filename', function (require) {
"use strict";

var gui = require('point_of_sale.gui');
var screens = require('point_of_sale.screens');
var core = require('web.core');
var QWeb = core.qweb;
var _t = core._t;

screens.ReceiptScreenWidget.include({
    print: function() {
    // Your code
    },
});

});

添加JS的XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
        <template id="assets" inherit_id="point_of_sale.assets">
          <xpath expr="." position="inside">
              <script type="text/javascript" src="/your_module_name/static/js/filename.js"></script>
          </xpath>
        </template>
</odoo>

在__manifest __。py

中添加该xml
{
...
...
'data': [
        ...
        'views/above_xml_filename.xml',
    ],
....
}