Hello, Everyone,
I'm new to Odoo Framework I have requirements as follows
I should not expose any model information in js. like I should not call using RPC.query everything should route via the handler.
From Controller am recieving data in json format:
As a new view, I try to create with the following code in JS
JS:-
odoo.define('web_hospital_dashboard.datatable', function (require) {
"use strict"
var core = require('web.core');
var Widget = require('web.Widget');
var rpc = require('web.rpc');
var qweb = core.qweb;
var ajax = require('web.ajax');
ajax.loadXML('/web_corona_dashboard/static/src/xml/datatable.xml', qweb);
var ActionManager = require('web.ActionManager');
var view_registry = require('web.view_registry');
var AbstractAction = require('web.AbstractAction');
var result = [];
var hospital_datatable=Widget.extend({
template :'hospital_datatable',
init: function (parent) {
this._super(parent);
},
willStart: function(){
ajax.jsonRpc("/hospital/get_data", 'call', {}, {
'async': false
}).then(function (data) {
var parseData=JSON.parse(data)
result.push(parseData);
});
},
start: function () {
console.log("Widget rendered")
console.log("got the result",result)
$('#hospital_table').DataTable( {
data: result,
columns: [
{ data: 'name' },
{ data: 'type_of_hospital' },
{ data: 'isFunction' },
{ data: 'isApproved' }]
}
);
},});
console.log("Trying to add Action");
var Test_Client = AbstractAction.extend({
template: 'hospital_datatable',
init: function() {
console.log("Action Function is intialized");
},});
core.action_registry.add("web_covid_view_main",Test_Client);
return Test_Client;
});
My xml template:-
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="hospital_datatable">
<div>
<table id="hospital_table" class="table table-stripped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Type Of Hospital</th>
<th>is Function</th>
<th>Is Approved.</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Type Of Hospital</th>
<th>is Function</th>
<th>Is Approved.</th>
</tr>
</tfoot>
</table>
</div>
</t>
</templates>
Added Asset:-
<odoo>
<template id="asset_backend" name="Web Home view assets" inherit_id="web.assets_backend" priority="17">
<xpath expr="." position="inside">
<script type="text/javscript" src="/web_corona_dashboard/static/src/js/dataTables.bootstrap4.min.js"></script>
<script type="text/javscript" src="/web_hospital_dashboard/static/src/js/jquery.dataTables.min.js"></script>
<script type="text/javscript" src="/web_hospital_dashboard/static/src/js/datatable.js"></script>
</xpath>
</template>
</odoo>
Facing Following issue:-
Uncaught TypeError: d is undefined
<anonymous> http://localhost:8089/web_hospital_dashboard/static/src/js/dataTables.bootstrap4.min.js:8
<anonymous> http://localhost:8089/web_hospital_dashboard/static/src/js/dataTables.bootstrap4.min.js:8
<anonymous> http://localhost:8089/web_hospital_dashboard/static/src/js/dataTables.bootstrap4.min.js:8
dataTables.bootstrap4.min.js:8:348
Second Issue
Uncaught TypeError: self.__edispatcherEvents is undefined
on http://localhost:8089/web/static/src/js/core/mixins.js:297
forEach Underscore
on http://localhost:8089/web/static/src/js/core/mixins.js:296
_startController http://localhost:8089/web/static/src/js/chrome/action_manager.js:907
_executeAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:343
jQuery 8
_executeAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:334
_executeClientAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:488
_handleAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:689
_handleAction http://localhost:8089/web/static/src/js/chrome/action_manager_report.js:163
OdooClass.extend/Class.include/</prototype[name]</< http://localhost:8089/web/static/src/js/core/class.js:123
_handleAction http://localhost:8089/web/static/src/js/chrome/action_manager_act_window.js:488
OdooClass.extend/Class.include/</prototype[name]</< http://localhost:8089/web/static/src/js/core/class.js:123
doAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:179
jQuery 21
genericJsonRpc http://localhost:8089/web/static/src/js/core/ajax.js:65
jQuery 8
mixins.js:297:13
on http://localhost:8089/web/static/src/js/core/mixins.js:297
forEach Underscore
on http://localhost:8089/web/static/src/js/core/mixins.js:296
_startController http://localhost:8089/web/static/src/js/chrome/action_manager.js:907
_executeAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:343
jQuery 8
_executeAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:334
_executeClientAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:488
_handleAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:689
_handleAction http://localhost:8089/web/static/src/js/chrome/action_manager_report.js:163
OdooClass.extend/Class.include/</prototype[name]</< http://localhost:8089/web/static/src/js/core/class.js:123
_handleAction http://localhost:8089/web/static/src/js/chrome/action_manager_act_window.js:488
OdooClass.extend/Class.include/</prototype[name]</< http://localhost:8089/web/static/src/js/core/class.js:123
doAction http://localhost:8089/web/static/src/js/chrome/action_manager.js:179
jQuery 11
<anonymous> self-hosted:844
jQuery 10
genericJsonRpc http://localhost:8089/web/static/src/js/core/ajax.js:65
jQuery 8