3

i want to override a ReceiptScreen method from point_of_sale module.

var ReceiptScreenWidget = ScreenWidget.extend...

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

In order to do this, i've created my own module but i don't know what steps follow to change the ReceiptScreenWidget.print() function.

Here is the screens.js that contains the Widget.Function that i want to override. (search for: ReceiptScreenWidget)

I tried to follow this example but the code is from Odoo 8 or 9 so i couldn't make it work.

*Odoo version: 10

Chavada Viki
  • 1,514
  • 1
  • 12
  • 22
Pablo Pantaleon
  • 1,506
  • 1
  • 19
  • 38

1 Answers1

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
    },
});

});

XML to add JS

<?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>

Add that xml in __manifest__.py

{
...
...
'data': [
        ...
        'views/above_xml_filename.xml',
    ],
....
}
Chavada Viki
  • 1,514
  • 1
  • 12
  • 22