Odoo Help


Costume Widget - Odoo V8

Tarik Tourougui
on 3/15/16, 12:39 PM 1,029 views


i am working on a costume widget that will allow me to display a Google maps snippet withing my forms.

when i try to call the widget it doesn't show anything except the value of the field i used


openerp.ressource = function (openerp) {
    openerp.web.form.widgets.add('googlemaps', 'openerp.ressource.googlemaps');
    openerp.ressource.googlemaps = openerp.web.form.FieldChar.extend(
            template: "googlemaps",
            init: function (view, code) {
                this._super(view, code);
                console.log('Loading ...');
//Google Map and marker
                function initMap() {
                    var myLatLng = {lat: -25.363, lng: 131.044};
                    // Create a map object and specify the DOM element for display.
                    var map = new google.maps.Map(document.getElementById('map'), {
                        zoom: 8,
                        center: myLatLng
                    // Create a marker and set its position.
                    var marker = new google.maps.Marker({
                        map: map,
                        position: myLatLng,
                        title: 'Hello World!'
                function loadScript() {
                    var script = document.createElement("script");
                    script.type = "text/javascript";
                    script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyDb5EetAkCD_W80-mhlYunEr8R81z3cBqI&callback=initMap";
                window.onload = loadScript;


<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="googlemaps">
    <xpath expr="." position="inside">
                <div id="map" style="width:600px;height:400px;"></div>

and of course the __openerp__.py file

# -*- coding: utf-8 -*-
    'name': "googlemapswidget",
    'summary': """
        Short (1 phrase/line) summary of the module's purpose, used as
        subtitle on modules listing or apps.openerp.com""",
    'description': """
        Long description of module's purpose
    'author': "Your Company",
    'website': "http://www.yourcompany.com",
    # Categories can be used to filter modules in modules listing
    # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
    # for the full list
    'category': 'Uncategorized',
    'version': '0.1',
    # any module necessary for this one to work correctly
    'depends': ['base'],
    # always loaded
    'data': [
        # 'security/ir.model.access.csv',
    # only loaded in demonstration mode
    'demo': [
    'qweb' : ['static/xml/resource.xml',],
    'js': ['static/js/_googlemaps.js',],
    'css': ['static/js/style.css',],

what am i doing wrong here ?

any suggestions will be appreciated.

good day

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/15/16, 12:39 PM
Seen: 1029 times
Last updated: 3/15/16, 1:57 PM