js :
odoo.define('test.HomePageWidget', function (require) { 'use strict'; var Widget = require('web.Widget'); var widgetRegistry = require('web.widget_registry'); var HomePageWidget = Widget.extend({ className: 'o_field_test_homepage',
start: function () { console.log('test.HomePageWidget!'); this.$el.append("<div>test.HomePageWidget!</div>"); }, }); widgetRegistry.add('test_homepage', HomePageWidget); return HomePageWidget; });
xml-template :
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="test assets" inherit_id="website.assets_frontend">
<xpath expr="link[last()]" position="after">
<script type="text/javascript" src="/test/static/src/js/test.js"></script>
</xpath>
</template>
<template id="main_page">
<t t-call="website.layout">
<div class="oe_structure">
<div class="container">
Content.<br/>
Widget1:<div class="o_field_test_homepage">widget</div>
Widget2:<widget name="test_homepage"/></div>
</div>
</t>
</template>
</odoo>
In page of website I see only :
Content.
Widget1:
widget
Widget2:
and error "Missing dependencies : web_widget_registry" in javascript console
Hey,
If you add console to print value of widgetRegistry, do you get something ?! console.log('111', widgetRegistry)
I think you would want to consider this instead : var widgetRegistry = require('web.Registry');
Let us know.