From 46a197f4c6e44fca03fcb29b1ddb061a9ec1cac1 Mon Sep 17 00:00:00 2001 From: ernesto Date: Mon, 12 Nov 2018 19:41:50 -0500 Subject: [PATCH] [MIG] partner_external_map: Migration to 12.0 --- partner_external_map/README.rst | 76 ++- partner_external_map/__init__.py | 1 - partner_external_map/__manifest__.py | 4 +- .../data/map_website_data.xml | 2 +- partner_external_map/hooks.py | 5 +- partner_external_map/models/__init__.py | 1 - partner_external_map/models/map_website.py | 6 +- partner_external_map/models/res_partner.py | 6 +- partner_external_map/models/res_users.py | 6 +- partner_external_map/readme/CONFIGURE.rst | 5 + partner_external_map/readme/CONTRIBUTORS.rst | 8 + partner_external_map/readme/DESCRIPTION.rst | 24 + partner_external_map/readme/ROADMAP.rst | 2 + partner_external_map/readme/USAGE.rst | 8 + .../static/description/index.html | 479 ++++++++++++++++++ partner_external_map/tests/__init__.py | 1 - .../tests/test_partner_external_map.py | 31 +- .../views/map_website_view.xml | 2 +- .../views/res_partner_view.xml | 2 +- partner_external_map/views/res_users_view.xml | 2 +- 20 files changed, 622 insertions(+), 49 deletions(-) create mode 100644 partner_external_map/readme/CONFIGURE.rst create mode 100644 partner_external_map/readme/CONTRIBUTORS.rst create mode 100644 partner_external_map/readme/DESCRIPTION.rst create mode 100644 partner_external_map/readme/ROADMAP.rst create mode 100644 partner_external_map/readme/USAGE.rst create mode 100644 partner_external_map/static/description/index.html diff --git a/partner_external_map/README.rst b/partner_external_map/README.rst index 9e8a530a9..25173f099 100644 --- a/partner_external_map/README.rst +++ b/partner_external_map/README.rst @@ -1,11 +1,30 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - ===================== Partner External Maps ===================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/12.0/partner_external_map + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-partner_external_map + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + In the old days of Odoo/OpenERP, back in version 6.1, there was an official *google_map* module ; this module added a *Map* button on the partner form view and, when the user clicked on that button, it would open a new tab on its web @@ -31,6 +50,11 @@ 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. +**Table of contents** + +.. contents:: + :local: + Configuration ============= @@ -52,10 +76,6 @@ First, you need to configure in your preferences: Then you can use the two new buttons on the partner form to open a regular map or a route map. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/134/11.0 - Known issues / Roadmap ====================== @@ -65,33 +85,47 @@ Known issues / Roadmap Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Akretion +* Tecnativa + Contributors ------------- +~~~~~~~~~~~~ + +* `Akretion `__: -* Akretion (http://www.akretion.com): * Alexis de Lattre -* Tecnativa (https://www.tecnativa.com): - * Pedro M. Baeza -Maintainer ----------- +* `Tecnativa `__: + + * Pedro M. Baeza + * Ernesto Tejeda + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/partner-contact `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_external_map/__init__.py b/partner_external_map/__init__.py index 915bc22c8..143d98dd5 100644 --- a/partner_external_map/__init__.py +++ b/partner_external_map/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from . import models from .hooks import set_default_map_settings diff --git a/partner_external_map/__manifest__.py b/partner_external_map/__manifest__.py index 4e08ee95c..b1db59de9 100644 --- a/partner_external_map/__manifest__.py +++ b/partner_external_map/__manifest__.py @@ -1,11 +1,11 @@ -# -*- coding: utf-8 -*- # Copyright 2015-2016 Akretion - Alexis de Lattre # Copyright 2016-2017 Tecnativa - Pedro M. Baeza +# Copyright 2018 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Partner External Maps', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Extra Tools', 'license': 'AGPL-3', 'summary': 'Add Map and Map Routing buttons on partner form to ' diff --git a/partner_external_map/data/map_website_data.xml b/partner_external_map/data/map_website_data.xml index 52c20a67f..747d1785b 100644 --- a/partner_external_map/data/map_website_data.xml +++ b/partner_external_map/data/map_website_data.xml @@ -1,5 +1,5 @@ - diff --git a/partner_external_map/hooks.py b/partner_external_map/hooks.py index a66e504b0..1ee83cadc 100644 --- a/partner_external_map/hooks.py +++ b/partner_external_map/hooks.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2015 Alexis de Lattre -# © 2016 Pedro M. Baeza +# Copyright 2015 Alexis de Lattre +# Copyright 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, SUPERUSER_ID diff --git a/partner_external_map/models/__init__.py b/partner_external_map/models/__init__.py index f727dbdc9..3693814db 100644 --- a/partner_external_map/models/__init__.py +++ b/partner_external_map/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from . import map_website from . import res_partner diff --git a/partner_external_map/models/map_website.py b/partner_external_map/models/map_website.py index f8befdfca..640bd401c 100644 --- a/partner_external_map/models/map_website.py +++ b/partner_external_map/models/map_website.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- -# © 2015-2016 Akretion (Alexis de Lattre ) -# © 2016 Pedro M. Baeza +# Copyright 2015 Akretion (Alexis de Lattre ) +# Copyright 2016 Akretion (Alexis de Lattre ) +# Copyright 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, fields diff --git a/partner_external_map/models/res_partner.py b/partner_external_map/models/res_partner.py index 1ccccdc5b..e1f63c834 100644 --- a/partner_external_map/models/res_partner.py +++ b/partner_external_map/models/res_partner.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- -# © 2015-2016 Akretion (Alexis de Lattre ) -# © 2016 Pedro M. Baeza +# Copyright 2015 Akretion (Alexis de Lattre ) +# Copyright 2016 Akretion (Alexis de Lattre ) +# Copyright 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, api, _ diff --git a/partner_external_map/models/res_users.py b/partner_external_map/models/res_users.py index cf4a3136d..a43a80691 100644 --- a/partner_external_map/models/res_users.py +++ b/partner_external_map/models/res_users.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- -# © 2015-2016 Akretion (Alexis de Lattre ) -# © 2016 Pedro M. Baeza +# Copyright 2015 Akretion (Alexis de Lattre ) +# Copyright 2016 Akretion (Alexis de Lattre ) +# Copyright 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, fields, api diff --git a/partner_external_map/readme/CONFIGURE.rst b/partner_external_map/readme/CONFIGURE.rst new file mode 100644 index 000000000..d8b8fc2fb --- /dev/null +++ b/partner_external_map/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ +If you want to create additional map websites, go to the menu +*Settings > Technical > Map Websites > Map Websites*. You are +invited to send the configuration information of your additional map websites +to one of the authors of the module, so that the module can be updated with +more pre-configured map websites. diff --git a/partner_external_map/readme/CONTRIBUTORS.rst b/partner_external_map/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..5e7de1710 --- /dev/null +++ b/partner_external_map/readme/CONTRIBUTORS.rst @@ -0,0 +1,8 @@ +* `Akretion `__: + + * Alexis de Lattre + +* `Tecnativa `__: + + * Pedro M. Baeza + * Ernesto Tejeda diff --git a/partner_external_map/readme/DESCRIPTION.rst b/partner_external_map/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ce76da367 --- /dev/null +++ b/partner_external_map/readme/DESCRIPTION.rst @@ -0,0 +1,24 @@ +In the old days of Odoo/OpenERP, back in version 6.1, there was an official +*google_map* module ; this module added a *Map* button on the partner form view +and, when the user clicked on that button, it would open a new tab on its web +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: + +* 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 + 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 partner. + +This module supports several map websites: + +* `Google Maps ` +* `OpenStreetMap ` +* `Bing Maps ` +* `Here Maps ` +* `MapQuest ` + +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. diff --git a/partner_external_map/readme/ROADMAP.rst b/partner_external_map/readme/ROADMAP.rst new file mode 100644 index 000000000..fd4792c76 --- /dev/null +++ b/partner_external_map/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +* Let decide if the user prefers to use addresses instead coordinates when + *base_geolocalize* is installed. diff --git a/partner_external_map/readme/USAGE.rst b/partner_external_map/readme/USAGE.rst new file mode 100644 index 000000000..d4cbc37e9 --- /dev/null +++ b/partner_external_map/readme/USAGE.rst @@ -0,0 +1,8 @@ +First, you need to configure in your preferences: + +* The map website to use for the regular maps, +* The map website to use for the route maps, +* The start address for the route maps. + +Then you can use the two new buttons on the partner form to open a regular map +or a route map. diff --git a/partner_external_map/static/description/index.html b/partner_external_map/static/description/index.html new file mode 100644 index 000000000..fc5491869 --- /dev/null +++ b/partner_external_map/static/description/index.html @@ -0,0 +1,479 @@ + + + + + + +Partner External Maps + + + +
+

Partner External Maps

+ + +

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runbot

+

In the old days of Odoo/OpenERP, back in version 6.1, there was an official +google_map module ; this module added a Map button on the partner form view +and, when the user clicked on that button, it would open a new tab on its web +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:

+
    +
  • 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 +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 partner.
  • +
+

This module supports several map websites:

+
    +
  • Google Maps <https://www.google.com/maps>
  • +
  • OpenStreetMap <https://www.openstreetmap.org/>
  • +
  • Bing Maps <https://www.bing.com/maps/>
  • +
  • Here Maps <https://www.here.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.

+

Table of contents

+ +
+

Configuration

+

If you want to create additional map websites, go to the menu +Settings > Technical > Map Websites > Map Websites. You are +invited to send the configuration information of your additional map websites +to one of the authors of the module, so that the module can be updated with +more pre-configured map websites.

+
+
+

Usage

+

First, you need to configure in your preferences:

+
    +
  • The map website to use for the regular maps,
  • +
  • The map website to use for the route maps,
  • +
  • The start address for the route maps.
  • +
+

Then you can use the two new buttons on the partner form to open a regular map +or a route map.

+
+
+

Known issues / Roadmap

+
    +
  • Let decide if the user prefers to use addresses instead coordinates when +base_geolocalize is installed.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/partner-contact project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/partner_external_map/tests/__init__.py b/partner_external_map/tests/__init__.py index 944b0eb14..38052c83d 100644 --- a/partner_external_map/tests/__init__.py +++ b/partner_external_map/tests/__init__.py @@ -1,3 +1,2 @@ -# -*- coding: utf-8 -*- from . import test_partner_external_map diff --git a/partner_external_map/tests/test_partner_external_map.py b/partner_external_map/tests/test_partner_external_map.py index 6cb8c1d1d..b2e6d10cd 100644 --- a/partner_external_map/tests/test_partner_external_map.py +++ b/partner_external_map/tests/test_partner_external_map.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# © 2016 Pedro M. Baeza +# Copyright 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.tests import common @@ -22,13 +21,18 @@ class TestPartnerExternalMap(common.TransactionCase): self.partner = self.env['res.partner'].create({ 'name': 'Test partner', 'city': 'Madrid', + 'street': 'street_test', + 'street2': 'street2_test', + 'state_id': self.ref('base.state_es_m'), + 'country_id': self.ref('base.es'), }) def test_post_init_hook(self): # Call this again for coverage purposes, but it has been already run set_default_map_settings(self.cr, self.registry) - self.assertTrue(self.env.user.context_map_website_id) - self.assertTrue(self.env.user.context_route_map_website_id) + usrs = self.env['res.users'].search([]) + self.assertTrue(all([u.context_map_website_id.id for u in usrs])) + self.assertTrue(all([u.context_route_map_website_id.id for u in usrs])) self.assertEqual(self.env.user.partner_id, self.env.user.context_route_start_partner_id) @@ -39,13 +43,15 @@ class TestPartnerExternalMap(common.TransactionCase): def test_open_map(self): action = self.partner.sudo(self.user.id).open_map() self.assertEqual( - action['url'], "https://www.google.com/maps?ie=UTF8&q=Madrid") + action['url'], "https://www.google.com/maps?ie=UTF8" + "&q=street_test street2_test Madrid Madrid Spain") def test_open_route_map(self): action = self.partner.sudo(self.user.id).open_route_map() self.assertEqual( - action['url'], "https://www.google.com/maps?saddr=Tomelloso&daddr=" - "Madrid&directionsmode=driving") + action['url'], "https://www.google.com/maps?saddr=Tomelloso" + "&daddr=street_test street2_test Madrid Madrid " + "Spain&directionsmode=driving") def test_open_map_with_coordinates(self): # Simulate that we have the base_geolocalize module installed creating @@ -58,6 +64,17 @@ class TestPartnerExternalMap(common.TransactionCase): action['url'], "https://www.google.com/maps?z=15&q=39.15837,-3.02145") + def test_exception_no_addr(self): + self.partner.write({ + 'city': False, + 'street': False, + 'street2': False, + 'state_id': False, + 'country_id': False, + }) + with self.assertRaises(UserError): + self.partner.sudo(self.user.id).open_route_map() + def test_exception_no_map_website(self): self.user.context_map_website_id = False with self.assertRaises(UserError): diff --git a/partner_external_map/views/map_website_view.xml b/partner_external_map/views/map_website_view.xml index 543b87b73..8d86cb6c2 100644 --- a/partner_external_map/views/map_website_view.xml +++ b/partner_external_map/views/map_website_view.xml @@ -1,6 +1,6 @@ diff --git a/partner_external_map/views/res_partner_view.xml b/partner_external_map/views/res_partner_view.xml index 9b367bb18..6fdd156ce 100644 --- a/partner_external_map/views/res_partner_view.xml +++ b/partner_external_map/views/res_partner_view.xml @@ -1,6 +1,6 @@ diff --git a/partner_external_map/views/res_users_view.xml b/partner_external_map/views/res_users_view.xml index 013d2b0f3..38a903e88 100644 --- a/partner_external_map/views/res_users_view.xml +++ b/partner_external_map/views/res_users_view.xml @@ -1,6 +1,6 @@