Odoo Help


This community 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.


Costume Widget - Odoo V8

Tarik Tourougui
on 3/15/16, 12:39 PM 415 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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