Odoo Help


How to get xml model value from widget javascript?

on 9/21/14, 1:37 AM 3,042 views

Hey, i am creating a widget that'll show a google maps, but i need to get elements of the one2many field where i am using it, i am not sure how to do that. Here's how i call the widget:

<field name="destins" string="Destinos" widget="test" colspan="4" nolabel="1"  context="{'group_by':'fleet'}">
                                    <field name="coord"/>
                                    <field name="fleet"/>
                                    <field name="order"/>

And this is the widget template:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="test">
            <script>(function(d, s, id) {
              var map;

              function initialize(){
                var chicago = new google.maps.LatLng(-40.321, 175.54);
                  var myOptions = {
                      zoom: 6,
                      mapTypeId: google.maps.MapTypeId.ROADMAP,
                      center: chicago
                  map = new google.maps.Map(d.getElementById("map_canvas"), myOptions);

              function prepGoogleMaps(){
                if(typeof google != 'undefined'){

              function loadGoogleMaps(){
                var script_tag = document.createElement('script');
                (d.getElementsByTagName("head")[0] || d.documentElement).appendChild(script_tag);
            window.onload = loadGoogleMaps();
            }(document, 'script', 'map-root'));</script>
            <div id="map_canvas"></div>

Showsa google maps, but i need to use coord field of one2many, can anybody help me do this?


Ben Bernard
On 9/21/14, 7:54 AM

Have you ever read web framework training [1]? I think that is a good reference to hacking odoo frontend. I see your problem can be solved via context helper or directly querying odoo model. Beside that, I wonder why you choose to make new html page for the widget?


[1] https://doc.odoo.com/trunk/training/web_framework/

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: 9/21/14, 1:37 AM
Seen: 3042 times
Last updated: 3/16/15, 8:10 AM