Browse Source

[MIG] partner_external_map from v13 to v14

Remove map website openstreetmap FR because its query URL doesn't work anymore
Use street3 if the OCA module partner_address_street3 is installed
Add sequence and active fields on map website object
14.0
Alexis de Lattre 3 years ago
parent
commit
1e46fc8bb2
  1. 4
      partner_external_map/__manifest__.py
  2. 7
      partner_external_map/data/map_website_data.xml
  3. 3
      partner_external_map/models/map_website.py
  4. 12
      partner_external_map/models/res_partner.py
  5. 6
      partner_external_map/models/res_users.py
  6. 7
      partner_external_map/readme/DESCRIPTION.rst
  7. 27
      partner_external_map/views/map_website_view.xml
  8. 4
      partner_external_map/views/res_partner_view.xml
  9. 20
      partner_external_map/views/res_users_view.xml
  10. 1
      setup/partner_external_map/odoo/addons/partner_external_map
  11. 6
      setup/partner_external_map/setup.py

4
partner_external_map/__manifest__.py

@ -5,12 +5,12 @@
{ {
"name": "Partner External Maps", "name": "Partner External Maps",
"version": "13.0.1.0.0",
"version": "14.0.1.0.0",
"category": "Extra Tools", "category": "Extra Tools",
"license": "AGPL-3", "license": "AGPL-3",
"summary": "Add Map and Map Routing buttons on partner form to " "summary": "Add Map and Map Routing buttons on partner form to "
"open GMaps, OSM, Bing and others", "open GMaps, OSM, Bing and others",
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
"author": "Akretion, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact", "website": "https://github.com/OCA/partner-contact",
"depends": ["base"], "depends": ["base"],
"data": [ "data": [

7
partner_external_map/data/map_website_data.xml

@ -30,13 +30,6 @@
name="route_lat_lon_url" name="route_lat_lon_url"
>https://www.openstreetmap.org/directions/?engine=orsm_car&amp;route={START_LATITUDE},{START_LONGITUDE};{DEST_LATITUDE},{DEST_LONGITUDE}</field> >https://www.openstreetmap.org/directions/?engine=orsm_car&amp;route={START_LATITUDE},{START_LONGITUDE};{DEST_LATITUDE},{DEST_LONGITUDE}</field>
</record> </record>
<record id="openstreetmap_fr" model="map.website">
<field name="name">OpenStreetMap FR</field>
<field name="address_url">http://tile.openstreetmap.fr/?q={ADDRESS}</field>
<field
name="lat_lon_url"
>http://tile.openstreetmap.fr/?zoom=15&amp;lat={LATITUDE}&amp;lon={LONGITUDE}</field>
</record>
<record id="bing_maps" model="map.website"> <record id="bing_maps" model="map.website">
<field name="name">Bing Maps</field> <field name="name">Bing Maps</field>
<field <field

3
partner_external_map/models/map_website.py

@ -9,6 +9,7 @@ from odoo import fields, models
class MapWebsite(models.Model): class MapWebsite(models.Model):
_name = "map.website" _name = "map.website"
_description = "Map Website" _description = "Map Website"
_order = "sequence, id"
name = fields.Char(string="Map Website Name", required=True) name = fields.Char(string="Map Website Name", required=True)
address_url = fields.Char( address_url = fields.Char(
@ -32,3 +33,5 @@ class MapWebsite(models.Model):
"latitude and longitude of the start and destination adresses " "latitude and longitude of the start and destination adresses "
"(requires the module 'base_geolocalize').", "(requires the module 'base_geolocalize').",
) )
active = fields.Boolean(default=True)
sequence = fields.Integer(default=10)

12
partner_external_map/models/res_partner.py

@ -21,6 +21,8 @@ class ResPartner(models.Model):
addr.append(self.street) addr.append(self.street)
if self.street2: if self.street2:
addr.append(self.street2) addr.append(self.street2)
if hasattr(self, "street3") and self.street3:
addr.append(self.street3)
if self.city: if self.city:
addr.append(self.city) addr.append(self.city)
if self.state_id: if self.state_id:
@ -52,12 +54,9 @@ class ResPartner(models.Model):
raise UserError( raise UserError(
_("Missing map provider: " "you should set it in your preferences.") _("Missing map provider: " "you should set it in your preferences.")
) )
if (
map_website.lat_lon_url
and hasattr(self, "partner_latitude")
and self.partner_latitude
and self.partner_longitude
):
# Since v13, fields partner_latitude and partner_longitude are
# in the "base" module
if map_website.lat_lon_url and self.partner_latitude and self.partner_longitude:
url = self._prepare_url( url = self._prepare_url(
map_website.lat_lon_url, map_website.lat_lon_url,
{ {
@ -103,7 +102,6 @@ class ResPartner(models.Model):
start_partner = self.env.user.context_route_start_partner_id start_partner = self.env.user.context_route_start_partner_id
if ( if (
map_website.route_lat_lon_url map_website.route_lat_lon_url
and hasattr(self, "partner_latitude")
and self.partner_latitude and self.partner_latitude
and self.partner_longitude and self.partner_longitude
and start_partner.partner_latitude and start_partner.partner_latitude

6
partner_external_map/models/res_users.py

@ -34,7 +34,7 @@ class ResUsers(models.Model):
context_map_website_id = fields.Many2one( context_map_website_id = fields.Many2one(
"map.website", "map.website",
string="Map Website", string="Map Website",
default=_default_map_website,
default=lambda self: self._default_map_website(),
domain=["|", ("address_url", "!=", False), ("lat_lon_url", "!=", False)], domain=["|", ("address_url", "!=", False), ("lat_lon_url", "!=", False)],
) )
# We want to give the possibility to the user to have one map provider for # We want to give the possibility to the user to have one map provider for
@ -47,7 +47,7 @@ class ResUsers(models.Model):
("route_address_url", "!=", False), ("route_address_url", "!=", False),
("route_lat_lon_url", "!=", False), ("route_lat_lon_url", "!=", False),
], ],
default=_default_route_map_website,
default=lambda self: self._default_route_map_website(),
help="Map provided used when you click on the car icon on the partner " help="Map provided used when you click on the car icon on the partner "
"form to display an itinerary.", "form to display an itinerary.",
) )
@ -62,5 +62,5 @@ class ResUsers(models.Model):
""" """
user = super(ResUsers, self).create(vals) user = super(ResUsers, self).create(vals)
if not vals.get("context_route_start_partner_id"): if not vals.get("context_route_start_partner_id"):
user.context_route_start_partner_id = user.partner_id.id
user.write({"context_route_start_partner_id": user.partner_id.id})
return user return user

7
partner_external_map/readme/DESCRIPTION.rst

@ -5,7 +5,7 @@ browser and go to Google Map with a search on the address of the partner.
This module aims at restoring this feature with several improvements: This module aims at restoring this feature with several improvements:
* Each user can select the map website he wants to use in its preferences
* Each user can select the map website he wants to use in its preferences.
* There are now two buttons on the partner form view: one to open a regular map * There are now two buttons on the partner form view: one to open a regular map
on the address of the partner, and another one to open an itinerary map from on the address of the partner, and another one to open an itinerary map from
the start address configured in the preferences of the user to the address of the start address configured in the preferences of the user to the address of
@ -19,6 +19,5 @@ This module supports several map websites:
* `Here Maps <https://www.here.com/>` * `Here Maps <https://www.here.com/>`
* `MapQuest <http://www.mapquest.com/>` * `MapQuest <http://www.mapquest.com/>`
If the module *base_geolocalize* from the official addons is installed on the
system, it will use the latitude and longitude to localize the partner (instead
of the address) if this information is present on the partner.
If partner has the latitude and longitude information, Odoo will use that
information instead of the address.

27
partner_external_map/views/map_website_view.xml

@ -9,12 +9,19 @@
<field name="model">map.website</field> <field name="model">map.website</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Map Website"> <form string="Map Website">
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<group name="main"> <group name="main">
<field name="name" /> <field name="name" />
<field name="address_url" /> <field name="address_url" />
<field name="lat_lon_url" /> <field name="lat_lon_url" />
<field name="route_address_url" /> <field name="route_address_url" />
<field name="route_lat_lon_url" /> <field name="route_lat_lon_url" />
<field name="active" invisible="1" />
</group> </group>
</form> </form>
</field> </field>
@ -24,20 +31,32 @@
<field name="model">map.website</field> <field name="model">map.website</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Map Websites"> <tree string="Map Websites">
<field name="sequence" widget="handle" />
<field name="name" /> <field name="name" />
<field name="address_url" /> <field name="address_url" />
</tree> </tree>
</field> </field>
</record> </record>
<record id="map_website_search" model="ir.ui.view">
<field name="name">map.website.search</field>
<field name="model">map.website</field>
<field name="arch" type="xml">
<search>
<field name="name" />
<filter
string="Archived"
name="inactive"
domain="[('active', '=', False)]"
/>
</search>
</field>
</record>
<record id="map_website_action" model="ir.actions.act_window"> <record id="map_website_action" model="ir.actions.act_window">
<field name="name">Map Websites</field> <field name="name">Map Websites</field>
<field name="res_model">map.website</field> <field name="res_model">map.website</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </record>
<!-- Menu entry under Settings > Technical
We prefered the menu entry of previous Odoo versions under
Sales > Config > Address Book > Localization, but in v10 that
would required a dependency on sales_team, and we don't want that -->
<menuitem <menuitem
id="root_map_website_menu" id="root_map_website_menu"
name="Map Websites" name="Map Websites"

4
partner_external_map/views/res_partner_view.xml

@ -12,7 +12,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside"> <xpath expr="//div[@name='button_box']" position="inside">
<button <button
class="oe_inline oe_stat_button"
class="oe_stat_button"
name="open_map" name="open_map"
type="object" type="object"
string="Map" string="Map"
@ -20,7 +20,7 @@
icon="fa-map-marker" icon="fa-map-marker"
/> />
<button <button
class="oe_inline oe_stat_button"
class="oe_stat_button"
name="open_route_map" name="open_route_map"
type="object" type="object"
string="Route Map" string="Route Map"

20
partner_external_map/views/res_users_view.xml

@ -24,13 +24,19 @@
<field name="inherit_id" ref="base.view_users_form_simple_modif" /> <field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<group name="preferences" position="inside"> <group name="preferences" position="inside">
<field name="context_map_website_id" readonly="0" widget="selection" />
<field
name="context_route_map_website_id"
readonly="0"
widget="selection"
/>
<field name="context_route_start_partner_id" readonly="0" />
<group name="maps">
<field
name="context_map_website_id"
readonly="0"
widget="selection"
/>
<field
name="context_route_map_website_id"
readonly="0"
widget="selection"
/>
<field name="context_route_start_partner_id" readonly="0" />
</group>
</group> </group>
</field> </field>
</record> </record>

1
setup/partner_external_map/odoo/addons/partner_external_map

@ -0,0 +1 @@
../../../../partner_external_map

6
setup/partner_external_map/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save