Alexis de Lattre
10 years ago
7 changed files with 242 additions and 0 deletions
-
3partner_address_on_map/__init__.py
-
40partner_address_on_map/__openerp__.py
-
27partner_address_on_map/map_url_data.xml
-
46partner_address_on_map/map_url_view.xml
-
65partner_address_on_map/partner_address_on_map.py
-
27partner_address_on_map/partner_view.xml
-
34partner_address_on_map/users_view.xml
@ -0,0 +1,3 @@ |
|||||
|
# -*- encoding: utf-8 -*- |
||||
|
|
||||
|
from . import partner_address_on_map |
@ -0,0 +1,40 @@ |
|||||
|
# -*- encoding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Partner Address on Map module for Odoo |
||||
|
# Copyright (C) 2015 Akretion (http://www.akretion.com) |
||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.com> |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
|
||||
|
{ |
||||
|
'name': 'Partner Address on Map', |
||||
|
'version': '0.1', |
||||
|
'category': 'Contacts', |
||||
|
'license': 'AGPL-3', |
||||
|
'summary': 'Add Map button on partner form view to open GMaps, OSM or others', |
||||
|
'author': 'Akretion,Odoo Community Association (OCA)', |
||||
|
'website': 'http://www.akretion.com', |
||||
|
'depends': ['base'], |
||||
|
'data': [ |
||||
|
'partner_view.xml', |
||||
|
'map_url_data.xml', |
||||
|
'map_url_view.xml', |
||||
|
'users_view.xml', |
||||
|
], |
||||
|
'installable': True, |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- |
||||
|
Copyright (C) 2015 Akretion (www.akretion.com) |
||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com> |
||||
|
The licence is in the file __openerp__.py |
||||
|
--> |
||||
|
|
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<record id="openstreetmap_fr" model="map.url"> |
||||
|
<field name="name">OpenStreetMap FR</field> |
||||
|
<field name="url">http://tile.openstreetmap.fr/?q=</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="google_maps" model="map.url"> |
||||
|
<field name="name">Google Maps</field> |
||||
|
<field name="url">http://maps.google.com/maps?oi=map&q=</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="bing_maps" model="map.url"> |
||||
|
<field name="name">Bing Maps</field> |
||||
|
<field name="url">http://www.bing.com/maps/default.aspx?rtp=adr.</field> |
||||
|
</record> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,46 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- |
||||
|
Copyright (C) 2015 Akretion France (www.akretion.com) |
||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com> |
||||
|
The licence is in the file __openerp__.py |
||||
|
--> |
||||
|
|
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<record id="map_url_form" model="ir.ui.view"> |
||||
|
<field name="name">map.url.form</field> |
||||
|
<field name="model">map.url</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Map Provider"> |
||||
|
<group name="main"> |
||||
|
<field name="name"/> |
||||
|
<field name="url"/> |
||||
|
</group> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="map_url_tree" model="ir.ui.view"> |
||||
|
<field name="name">map.url.tree</field> |
||||
|
<field name="model">map.url</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<tree string="Map Providers"> |
||||
|
<field name="name"/> |
||||
|
<field name="url"/> |
||||
|
</tree> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="map_url_action" model="ir.actions.act_window"> |
||||
|
<field name="name">Map Providers</field> |
||||
|
<field name="res_model">map.url</field> |
||||
|
<field name="view_mode">tree,form</field> |
||||
|
</record> |
||||
|
|
||||
|
<!-- Menu entry under Sales > Config > Address Book > Localization --> |
||||
|
<menuitem id="map_url_menu" action="map_url_action" |
||||
|
parent="base.menu_localisation" sequence="50"/> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,65 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Partner Address on Map module for OpenERP |
||||
|
# Copyright (C) 2015 Akretion (http://www.akretion.com/) |
||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com> |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
from openerp import models, fields, api, _ |
||||
|
from openerp.exceptions import Warning |
||||
|
|
||||
|
|
||||
|
class MapUrl(models.Model): |
||||
|
_name = 'map.url' |
||||
|
_description = 'Map System' |
||||
|
|
||||
|
name = fields.Char(string='Map Provider', required=True) |
||||
|
url = fields.Char(string='URL', required=True) |
||||
|
|
||||
|
|
||||
|
class ResUsers(models.Model): |
||||
|
_inherit = 'res.users' |
||||
|
|
||||
|
# begin with context_ to allow user to change it by himself |
||||
|
context_map_url_id = fields.Many2one( |
||||
|
'map.url', string='Map Provider') |
||||
|
# TODO: Add default |
||||
|
|
||||
|
|
||||
|
class ResPartner(models.Model): |
||||
|
_inherit = 'res.partner' |
||||
|
|
||||
|
@api.multi |
||||
|
def open_map(self): |
||||
|
if not self.env.user.context_map_url_id: |
||||
|
raise Warning(_( |
||||
|
'Missing Map Provider: you should set it in your Preferences.')) |
||||
|
url = self.env.user.context_map_url_id.url |
||||
|
if self.street: |
||||
|
url += self.street |
||||
|
if self.city: |
||||
|
url += ' ' + self.city |
||||
|
if self.state_id: |
||||
|
url += ' ' + self.state_id.name |
||||
|
if self.country_id: |
||||
|
url += ' ' + self.country_id.name |
||||
|
return { |
||||
|
'type': 'ir.actions.act_url', |
||||
|
'url': url, |
||||
|
'targer': 'new', |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- |
||||
|
Copyright (C) 2015 Akretion France (www.akretion.com) |
||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com> |
||||
|
The licence is in the file __openerp__.py |
||||
|
--> |
||||
|
|
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<!-- Inherit partner view to add 'Map' button --> |
||||
|
<record id="view_partner_form" model="ir.ui.view"> |
||||
|
<field name="name">map.button.res.partner.form</field> |
||||
|
<field name="model">res.partner</field> |
||||
|
<field name="inherit_id" ref="base.view_partner_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//div[@name='buttons']" position="inside"> |
||||
|
<button class="oe_inline oe_stat_button" |
||||
|
name="open_map" type="object" string="Map" |
||||
|
attrs="{'invisible': [('street', '=', False), ('city', '=', False)]}" |
||||
|
icon="fa-map-marker"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,34 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- |
||||
|
Copyright (C) 2015 Akretion France (www.akretion.com) |
||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com> |
||||
|
The licence is in the file __openerp__.py |
||||
|
--> |
||||
|
|
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<record id="view_users_form" model="ir.ui.view"> |
||||
|
<field name="name">donation.res.users.form</field> |
||||
|
<field name="model">res.users</field> |
||||
|
<field name="inherit_id" ref="base.view_users_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<group name="preferences" position="inside"> |
||||
|
<field name="context_map_url_id" widget="selection"/> |
||||
|
</group> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="view_users_form_simple_modif" model="ir.ui.view"> |
||||
|
<field name="name">map.preferences.res.users.form</field> |
||||
|
<field name="model">res.users</field> |
||||
|
<field name="inherit_id" ref="base.view_users_form_simple_modif"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<group name="preferences" position="inside"> |
||||
|
<field name="context_map_url_id" readonly="0" widget="selection"/> |
||||
|
</group> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue