2
votes

I trying to create a custom widget,

*.js

odoo.define('pos_widget',function (require) {
var PosBaseWidget = require('point_of_sale.BaseWidget');
aleert('Alert One');//It alerts
var NewWidget = PosBaseWidget.extend({
template: 'NewWidget',
init: function(parent,options){
     alert('Alert Two inside init function'); // It not alerts       
     var self = this;
  },
});

});

But getting an error on console:

Error: Service pos_widget already defined  boot.js:119:27
No type for action Object { context: Object }  action_manager.js:631:13
error: Some modules could not be started 
Failed modules:          Array [ "point_of_sale.chrome" ] 
Non loaded modules:      Array [ "point_of_sale.main" ] 
Debug:                   Object { point_of_sale.main: Object, point_of_sale.chrome: Object } 

Note I have added these lines in chrome.js file (point_of_sale module) directly, and works. But not in custom module.

How can i resolve this?

2

2 Answers

1
votes

It seems that the name you have used is conflict 'pos_widget'

Change it to with your something like modulename.pos_custom_widget

1
votes

Check path of your js file given in your xml file. It should be like this way:

XML file :

<?xml version="1.0" encoding="utf-8"?>

    <template id="assets" inherit_id="point_of_sale.assets">
      <xpath expr="." position="inside">
          <script type="text/javascript" src="/custom_module/static/src/js/js_file.js"></script>
       </xpath>
    </template>

After that for js file it should be like this:

JS file:

odoo.define('custom_module.file_name', function (require) {
"use strict";
var PosBaseWidget = require('point_of_sale.BaseWidget');
var TableWidget = PosBaseWidget.extend({
template: 'TableWidget',
init: function(parent, options){
    this._super(parent, options);
    alert("Custom Widget");
}
});
});

After this add your xml file in manifest like this:

Manifest file:

'data': [
     'views/pos_restaurant_views.xml',
    ],

Also after this you have to create your qweb template in xml file. And add this qweb temlpate in manifest like this:

qweb template in manifest

'qweb': [
   'static/src/xml/qweb_file.xml',
   ],

After this run your POS in front.