summaryrefslogtreecommitdiff
path: root/addons/event
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-05-25 21:11:27 +0200
committerAntony Lesuisse <al@openerp.com>2012-05-25 21:11:27 +0200
commitdf59b0b7d2146d5d8b2a88e19e79f1a24f07bfce (patch)
treefd30adfd0d8cf1ea543b64c52fa9ca165fc2a12d /addons/event
parentcdd8b9d47ad3fcd9aeb2279c05a0725ba68dad62 (diff)
[FIX] google map on event part1
bzr revid: al@openerp.com-20120525191127-v5o88etlbdq0jbzn
Diffstat (limited to 'addons/event')
-rw-r--r--addons/event/__openerp__.py3
-rw-r--r--addons/event/event_view.xml4
-rw-r--r--addons/event/static/src/js/google_map.js74
3 files changed, 3 insertions, 78 deletions
diff --git a/addons/event/__openerp__.py b/addons/event/__openerp__.py
index c491dd06138..f1a9769f803 100644
--- a/addons/event/__openerp__.py
+++ b/addons/event/__openerp__.py
@@ -39,7 +39,7 @@ Note that:
Association / Configuration / Types of Events
""",
'author': 'OpenERP SA',
- 'depends': ['email_template'],
+ 'depends': ['email_template','google_map'],
'init_xml': [],
'update_xml': [
'security/event_security.xml',
@@ -53,7 +53,6 @@ Note that:
],
'demo_xml': ['event_demo.xml'],
'test': ['test/process/event_draft2done.yml'],
- 'js': ['static/src/js/google_map.js'],
'css': ['static/src/css/event.css'],
'installable': True,
'application': True,
diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml
index 190445d6c20..69d0135d091 100644
--- a/addons/event/event_view.xml
+++ b/addons/event/event_view.xml
@@ -68,7 +68,7 @@
<group col="2" colspan="2" class="oe_form_group_label_border" style="margin-top: 20px;">
<field name="type" on_change="onchange_event_type(type,context)"/>
<field name="user_id"/>
- <field name="address_id" widget ="many2one_Geo_address"/>
+ <field name="address_id" widget ="many2one_address_google_map" widget_option="{'placeholder':'.oe_form_google_map'}"/>
<field name="address"/>
</group>
<group col="2" colspan="2" class="oe_form_group_label_border" style="margin-top: 20px;">
@@ -77,7 +77,7 @@
<field name="register_min"/>
<field name="register_max"/>
</group>
- <div id="oe_mapbox" class="oe_mapbox"></div>
+ <div class="oe_form_google_map"></div>
</group>
<notebook colspan="4">
diff --git a/addons/event/static/src/js/google_map.js b/addons/event/static/src/js/google_map.js
deleted file mode 100644
index 4a02086b85a..00000000000
--- a/addons/event/static/src/js/google_map.js
+++ /dev/null
@@ -1,74 +0,0 @@
-openerp.event = function(instance) {
- instance.web.form.widgets.add('many2one_Geo_address', 'instance.event.Many2OneAddress');
-
- instance.web.GoogleMapConnector = instance.web.Class.extend({
- init: function(){
- this.googleMapsLoaded = $.Deferred();
- this.map_load();
- },
- map_load: function() {
- var self = this;
- if(this.googleMapsLoaded.state() != "pending"){return this.googleMapsLoaded.promise();}
- googleMapsCallback = function () {
- self.googleMapsLoaded.resolve();
- };
- $.ajax({
- url: "https://maps.googleapis.com/maps/api/js?v=3&callback=googleMapsCallback&sensor=false",
- dataType: "script"
- }).fail(self.googleMapsLoaded.reject);
- return this.googleMapsLoaded.promise();
- },
- render_map: function(address,$element){
- var geocoder = new google.maps.Geocoder();
- geocoder.geocode( { 'address': address}, function(results, status){
- if (status == google.maps.GeocoderStatus.OK){
- var lat = results[0].geometry.location.lat(),lng =results[0].geometry.location.lng();
- var myOptions = {
- zoom: 17,
- center: new google.maps.LatLng(lat,lng),
- mapTypeId: google.maps.MapTypeId.ROADMAP
- }
- return new google.maps.Marker({
- map : new google.maps.Map($element,myOptions),
- position: new google.maps.LatLng(lat,lng)
- });
- }
- });
- },
- });
- instance.event.Many2OneAddress = instance.web.form.FieldMany2One.extend({
- init: function(field_manager, node){
- this._super(field_manager, node);
- this.map = new instance.web.GoogleMapConnector();
- },
- get_address:function(value){
- var self = this;
- if (!value || value.length == 0){
- return $.Deferred().reject();
- }
- (value instanceof Array)?value = parseInt(value[0]):false;
- var data = new instance.web.DataSet(this,this.field.relation, this.build_context());
- data.read_ids(value,["street","city","zip","country_id"]).done(function(value){
- var address;
- if value['country_id'] {
- address = _.str.sprintf('%(street)s, %(zip)s %(city)s, %(country_id[1])s', value);
- } else {
- address = _.str.sprintf('%(street)s, %(zip)s %(city)s', value);
- }
-
- self.map.googleMapsLoaded.done(function(){
- self.map.render_map(address,document.getElementById("oe_mapbox"));
- })
- });
- },
- set_value:function(value){
- this._super(value);
- this.get_address(value);
- },
-
- render_value:function(no_recurse){
- this.get_address(this.get("value"));
- this._super(no_recurse);
- }
- });
-};