diff --git a/website_openstreetmap_link/README.rst b/website_openstreetmap_link/README.rst new file mode 100644 index 0000000000..a2a5b6fe96 --- /dev/null +++ b/website_openstreetmap_link/README.rst @@ -0,0 +1,94 @@ +=========================== +Website OpenStreetMap Links +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:88ad463c621184b8de9692b19b2b15193505d0b794236c6c2a40d9c845b45ccd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fwebsite-lightgray.png?logo=github + :target: https://github.com/OCA/website/tree/18.0/website_openstreetmap_link + :alt: OCA/website +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/website-18-0/website-18-0-website_openstreetmap_link + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/website&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +By default, in Odoo when website module displays directions, it provides +an Google Map URL. + +With that module, it provides an OpenStreetMap URL. + +Also if the related partner has longitude and latitude defined, it used +it, instead of a approximative search URL. + +|website_event_exemple| + +.. |website_event_exemple| image:: https://raw.githubusercontent.com/OCA/website/18.0/website_openstreetmap_link/static/description/website_event_exemple.png + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* GRAP + +Contributors +------------ + +- Sylvain LE GAL + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain + +Current `maintainer `__: + +|maintainer-legalsylvain| + +This module is part of the `OCA/website `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_openstreetmap_link/__init__.py b/website_openstreetmap_link/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/website_openstreetmap_link/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/website_openstreetmap_link/__manifest__.py b/website_openstreetmap_link/__manifest__.py new file mode 100644 index 0000000000..26e94db020 --- /dev/null +++ b/website_openstreetmap_link/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2026 - Today: GRAP https://www.grap.coop +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +{ + "name": "Website OpenStreetMap Links", + "summary": "Replace google Map Links by OpenStreetMap Links.", + "version": "18.0.1.0.0", + "author": "GRAP, Odoo Community Association (OCA)", + "maintainers": ["legalsylvain"], + "website": "https://github.com/OCA/website", + "license": "AGPL-3", + "category": "Website", + "depends": ["website"], +} diff --git a/website_openstreetmap_link/i18n/fr.po b/website_openstreetmap_link/i18n/fr.po new file mode 100644 index 0000000000..ba9ad86c75 --- /dev/null +++ b/website_openstreetmap_link/i18n/fr.po @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_social_media_link +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_social_media_link +#: model_terms:ir.ui.view,arch_db:website_social_media_link.view_website_form +msgid "Social Media" +msgstr "Média Sociaux" diff --git a/website_openstreetmap_link/models/__init__.py b/website_openstreetmap_link/models/__init__.py new file mode 100644 index 0000000000..91fed54d40 --- /dev/null +++ b/website_openstreetmap_link/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/website_openstreetmap_link/models/res_partner.py b/website_openstreetmap_link/models/res_partner.py new file mode 100644 index 0000000000..389d5fc014 --- /dev/null +++ b/website_openstreetmap_link/models/res_partner.py @@ -0,0 +1,25 @@ +# Copyright 2026 - Today: GRAP https://www.grap.coop +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +import werkzeug.urls + +from odoo import models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + def google_map_link(self, zoom=10): + self.ensure_one() + base_url = "https://www.openstreetmap.org" + country = self.country_id or self.env.company.country_id + lon, lat = self.partner_longitude, self.partner_latitude + if lon and lat: + return f"{base_url}/directions?from=&to={lat},{lon}#map={zoom}/{lat}/{lon}" + else: + params = { + "query": f"{self.street or ''}, {self.city or ''} {self.zip or ''}," + f" {country and country.display_name or ''}", + "zoom": zoom, + } + return f"{base_url}/search?" + werkzeug.urls.url_encode(params) diff --git a/website_openstreetmap_link/pyproject.toml b/website_openstreetmap_link/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_openstreetmap_link/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_openstreetmap_link/readme/CONTRIBUTORS.md b/website_openstreetmap_link/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..fea5f58349 --- /dev/null +++ b/website_openstreetmap_link/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Sylvain LE GAL \ No newline at end of file diff --git a/website_openstreetmap_link/readme/DESCRIPTION.md b/website_openstreetmap_link/readme/DESCRIPTION.md new file mode 100644 index 0000000000..5567606773 --- /dev/null +++ b/website_openstreetmap_link/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +By default, in Odoo when website module displays directions, +it provides an Google Map URL. + +With that module, it provides an OpenStreetMap URL. + +Also if the related partner has longitude and latitude defined, it used it, +instead of a approximative search URL. + +![website_event_exemple](../static/description/website_event_exemple.png) diff --git a/website_openstreetmap_link/static/description/index.html b/website_openstreetmap_link/static/description/index.html new file mode 100644 index 0000000000..d0531fd866 --- /dev/null +++ b/website_openstreetmap_link/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +Website OpenStreetMap Links + + + + + + diff --git a/website_openstreetmap_link/static/description/website_event_exemple.png b/website_openstreetmap_link/static/description/website_event_exemple.png new file mode 100644 index 0000000000..69077de8e2 Binary files /dev/null and b/website_openstreetmap_link/static/description/website_event_exemple.png differ diff --git a/website_openstreetmap_link/tests/__init__.py b/website_openstreetmap_link/tests/__init__.py new file mode 100644 index 0000000000..6d6109f686 --- /dev/null +++ b/website_openstreetmap_link/tests/__init__.py @@ -0,0 +1 @@ +from . import test_website_openstreetmap_link diff --git a/website_openstreetmap_link/tests/test_website_openstreetmap_link.py b/website_openstreetmap_link/tests/test_website_openstreetmap_link.py new file mode 100644 index 0000000000..bd735bbd1e --- /dev/null +++ b/website_openstreetmap_link/tests/test_website_openstreetmap_link.py @@ -0,0 +1,40 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + + +from odoo.tests import TransactionCase + + +class TestModule(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_with_address = cls.env["res.partner"].create( + { + "name": "Demo OpenStreetMap Partner", + "street": "3 Grande rue des feuillants", + "city": "lyon", + "zip": "69001", + "country_id": cls.env.ref("base.fr").id, + } + ) + + def test_with_lon_lat(self): + self.partner_with_address.write( + { + "partner_longitude": 4.837005, + "partner_latitude": 45.7702588, + } + ) + self.assertEqual( + self.partner_with_address.google_map_link(zoom=15), + "https://www.openstreetmap.org/directions?" + "from=&to=45.7702588,4.837005#map=15/45.7702588/4.837005", + ) + + def test_with_address(self): + self.assertEqual( + self.partner_with_address.google_map_link(zoom=15), + "https://www.openstreetmap.org/search?" + "query=3+Grande+rue+des+feuillants%2C+lyon+69001%2C+France&zoom=15", + )