I have created a website template in ODOO V8:
<template id="assets_frontend" inherit_id="website.assets_frontend" name="MyTemplate">
<xpath expr="." position="inside">
<script type="text/javascript" src="/my_module/static/src/js/main.js"></script>
</xpath>
</template>
<template id="my_template">
<script type="text/javascript" src="/my_module/static/src/js/main.js"/>
<div>
<table>
<tr>
<td>Email: <input type="text" id="email"/></td>
</tr>
<tr>
<td colspan="3">
<input type="button" value="Submit" onclick="submitEmail();"/>
</td>
</tr>
</table>
</div>
</template>
And the contents in main.js file are:
$(document).ready(function () {
"use strict";
function submitEmail() {
var self = this;
var website = openerp.website;
var Users = new openerp.website.Model('res.users');
// ...
}
})();
But on clicking the submit button in the template it shows the following error in the browser console.
Uncaught ReferenceError: openerp is not defined
I need to access the ODOO models and methods in it from the main.js
file. How can I solve the above error or is there any way I can access the models and methods defined in ODOO classes from a javascript file?
This error is not in the base modules(like website_sale) in ODOO and the error is only in new modules I have created.