Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to show the cordinates on Google Map in OpenERP/Odoo ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.23k
    Comment on it

    To Add two fields to product for storing a latitude and a longitude, then for this you have to create a new form widget to display the latitude and longitude of a product's origin on a map.
    Displaying the two position fields and a map widget using them in a new notebook page of the product's form view.
    For example see the code is given below.

    local.WidgetCoordinates = instance.web.form.FormWidget.extend({
        start: function() {
            this._super();
            this.field_manager.on("field_changed:provider_latitude", this, this.display_map);
            this.field_manager.on("field_changed:provider_longitude", this, this.display_map);
            this.display_map();
        },
        display_map: function() {
            this.$el.html(QWeb.render("WidgetCoordinates", {
                "latitude": this.field_manager.get_field_value("provider_latitude") || 0,
                "longitude": this.field_manager.get_field_value("provider_longitude") || 0,
            }));
        }
    });
    
    instance.web.form.custom_widgets.add('coordinates', 'instance.oepetstore.WidgetCoordinates');
    <t t-name="WidgetCoordinates">
        <iframe t-attf-src="https://maps.google.com/?ie=UTF8&amp;ll={{latitude}},{{longitude}}&amp;output=embed" height="300" width="400">
        </iframe>
    </t>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: