I am trying to create a widget for my custom module. I can't seem to get the js to see the qweb template. Here are the files
services/static/src/js/signature.js
odoo.debug = true;
odoo.define('services.signature', function (require) {
"use strict";
var core = require('web.core');
var Widget = require('web.Widget');
console.log("working");
var Signature = Widget.extend({
template: "sigPad",
events: {
// events binding example
'click .get-signature': function(){
console.log("Handle click has been clicked");
}
},
init: function(parent){
this._super(parent);
console.log("The signaure has been initiated");
},
start: function(){
var sup = this._super();
console.log("The start function has launched");
}
});
core.form_widget_registry.add('signaturePad', Signature);
});
services/static/src/xml/signature.xml
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="sigPad">
<div class="panel panel-default mt16 mb0 " id="drawsign">
<p>This is the signature area</p>
</div>
</t>
</templates>
views/resources.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="sws_services_signature_backend" name="sws_services_signature assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/services/static/src/js/socket.io-client.js"></script>
<script type="text/javascript" src="/services/static/src/js/signature.js"></script>
</xpath>
</template>
</odoo>
calling it like this inside a form xml
views/views.xml
.....
<field name="signature" widget="signaturePad"/>
......
__manifest__.py
..............
'depends': ['base','web'],
# always loaded
'data': [
'views/views.xml',
'views/service_workflow.xml',
'views/resources.xml',
],
'js': [
'static/src/js/signature.js'],
'qweb': [
'static/src/xml/signature.xml', ]
...........
No matter what I do I get this error:
TypeError: w.set_input_id is not a function. (In 'w.set_input_id($label.attr("for"))', 'w.set_input_id' is undefined)
or If I remove core.form_widget_registry.add('signaturePad', Signature);
and just instantiate it with new and use appendtTo() it tells me it can't find the qweb template. Even though I can inspect the browser and verify that the template is there.
Any idea on how to get this working?