diff --git a/addons/account/wizard/account_invoice_state_view.xml b/addons/account/wizard/account_invoice_state_view.xml
index d83c0c6f2dc..e0c22a0007f 100644
--- a/addons/account/wizard/account_invoice_state_view.xml
+++ b/addons/account/wizard/account_invoice_state_view.xml
@@ -1,22 +1,22 @@
-
+ account.invoice.confirm.formaccount.invoice.confirmform
-
-
+
-
+ Confirm Draft Invoicesaccount.invoice.confirmform
@@ -25,7 +25,7 @@
new
-
+ Confirm Draft Invoices
@@ -33,24 +33,24 @@
actionaccount.invoice
-
+
-
+ account.invoice.cancel.formaccount.invoice.cancelform
-
-
+
-
+ Cancel Selected Invoicesaccount.invoice.cancelform
@@ -59,7 +59,7 @@
new
-
+ Cancel Selected Invoices
@@ -67,7 +67,7 @@
actionaccount.invoice
-
+
-
-
\ No newline at end of file
+
+
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index da111cf9518..95ab6a1d0df 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -83,7 +83,8 @@
-
+
+
@@ -134,6 +135,27 @@
icon="gtk-convert" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/partner_geo_assign/__init__.py b/addons/partner_geo_assign/__init__.py
new file mode 100644
index 00000000000..e1957dfb286
--- /dev/null
+++ b/addons/partner_geo_assign/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import partner_geo_assign
diff --git a/addons/partner_geo_assign/__openerp__.py b/addons/partner_geo_assign/__openerp__.py
new file mode 100644
index 00000000000..2d18649236e
--- /dev/null
+++ b/addons/partner_geo_assign/__openerp__.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+
+{
+ 'name': 'Partner Geo-Localisation',
+ 'version': '1.0',
+ 'category': 'Generic Modules/Production',
+ 'description': """
+This is the module used by OpenERP SA to redirect customers to his partners,
+based on geolocalisation.
+ """,
+ 'author': 'OpenERP SA',
+ 'depends': ['crm'],
+ 'update_xml': ['res_partner_view.xml'],
+ 'demo_xml': [],
+ 'installable': True,
+ 'active': False,
+ 'certificate': False,
+}
diff --git a/addons/partner_geo_assign/partner_geo_assign.py b/addons/partner_geo_assign/partner_geo_assign.py
new file mode 100644
index 00000000000..2ed96e3125d
--- /dev/null
+++ b/addons/partner_geo_assign/partner_geo_assign.py
@@ -0,0 +1,113 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import urllib,re
+import random, time
+
+def geo_find(addr):
+ import urllib,re
+ regex = '([+-]?[0-9\.]+),([+-]?[0-9\.]+),([+-]?[0-9\.]+)'
+ url = 'http://maps.google.com/maps/geo?q=' + urllib.quote(addr) + '&output=xml&oe=utf8&sensor=false'
+ xml = urllib.urlopen(url).read()
+ if '' in xml:
+ print 'Error'
+ return None
+ result = re.search(regex, xml, re.M|re.I)
+ if not result:
+ print 'No Regex', xml
+ return None
+ return float(result.group(1)),float(result.group(2))
+
+class res_partner(osv.osv):
+ _inherit = "res.partner"
+ _columns = {
+ 'partner_latitude': fields.float('Geo Latitude', digits=(16,2)),
+ 'partner_longitude': fields.float('Geo Longitude', digits=(16,2)),
+ 'partner_weight': fields.integer('Weight',
+ help="Gives the probability to assign a lead to this partner. (0 means no assignation.)"),
+ }
+ _defaults = {
+ 'partner_weight': lambda *args: 0
+ }
+ def geo_localize(self, cr, uid, ids, context=None):
+ regex = '([+-]?[0-9\.]+),([+-]?[0-9\.]+),([+-]?[0-9\.]+)'
+ for partner in self.browse(cr, uid, ids, context=context):
+ part = partner.address[0]
+ addr = ', '.join(filter(None, [part.street, part.street2, (part.zip or '')+' '+(part.city or ''), part.state_id and part.state_id.name, part.country_id and part.country_id.name]))
+ result = geo_find(addr)
+ if result:
+ print 'Write', {
+ 'partner_latitude': result[0],
+ 'partner_longitude': result[1]
+ }
+ self.write(cr, uid, [partner.id], {
+ 'partner_latitude': result[0],
+ 'partner_longitude': result[1]
+ }, context=context)
+ return True
+res_partner()
+
+class crm_lead(osv.osv):
+ _inherit = "crm.lead"
+ _columns = {
+ 'partner_latitude': fields.float('Geo Latitude', digits=(16,2)),
+ 'partner_longitude': fields.float('Geo Longitude', digits=(16,2)),
+ 'partner_assigned_id': fields.many2one('res.partner','Assigned Partner')
+ 'date_assign': fields.date('Assignation Date')
+ }
+ def assign_partner(self, cr, uid, ids, context=None):
+ for part in self.browse(cr, uid, ids, context=context):
+ if not part.country_id:
+ continue
+ addr = ', '.join(filter(None, [part.street, part.street2, (part.zip or '')+' '+(part.city or ''), part.state_id and part.state_id.name, part.country_id and part.country_id.name]))
+ result = geo_find(addr)
+ if result:
+ self.write(cr, uid, [part.id], {
+ 'partner_latitude': result[0],
+ 'partner_longitude': result[1]
+ }, context=context)
+
+ part_ids = self.pool.get('res.partner').search(cr, uid, [
+ ('partner_weight','>',0),
+ ('partner_latitude','>',result[0]-2), ('partner_latitude','<',result[0]+2),
+ ('partner_longitude','>',result[1]-1.5), ('partner_longitude','<',result[1]+1.5)
+ ], context=context)
+ if not part_ids:
+ part_ids = self.pool.get('res.partner').search(cr, uid, [
+ ('partner_weight','>',0),
+ ('partner_latitude','>',result[0]-4), ('partner_latitude','<',result[0]+4),
+ ('partner_longitude','>',result[1]-3), ('partner_longitude','<',result[1]+3)
+ ], context=context)
+ total = 0
+ toassign = []
+ for part2 in self.pool.get('res.partner').browse(cr, uid, part_ids, context=context):
+ total += part2.partner_weight
+ toassign.append( (part2.id, total) )
+ mypartner = random.randint(0,total)
+ for t in toassign:
+ if mypartner<=t[1]:
+ self.write(cr, uid, [part.id], {'partner_assigned_id': t[0], 'date_assign': time.strftime('%Y-%m-%d')}, context=context)
+ break
+ return True
+crm_lead()
+
diff --git a/addons/partner_geo_assign/res_partner_view.xml b/addons/partner_geo_assign/res_partner_view.xml
new file mode 100644
index 00000000000..d5f4f918d98
--- /dev/null
+++ b/addons/partner_geo_assign/res_partner_view.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ crm.lead.geo_assign.inherit
+ crm.lead
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ res.partner.geo.inherit
+ res.partner
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index d5050c69b18..8d3402804a9 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -91,9 +91,9 @@
-
+
-
+
@@ -233,7 +233,13 @@
+
+
+
+
+
@@ -243,17 +249,14 @@
-
-
-
-
-
-
-
+
+
+
+
-
-
+
+
@@ -313,7 +316,7 @@
src_model="product.product"
groups="base.group_extended"/>
- procurement.order.form.inherit
- procurement.order
-
- form
-
-
-
-
-
+ procurement.order.form.inherit
+ procurement.order
+
+ form
+
+
+
+
+