first commit
This commit is contained in:
2
modules/google_maps/__init__.py
Normal file
2
modules/google_maps/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
BIN
modules/google_maps/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/google_maps/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/google_maps/__pycache__/address.cpython-311.pyc
Normal file
BIN
modules/google_maps/__pycache__/address.cpython-311.pyc
Normal file
Binary file not shown.
23
modules/google_maps/address.py
Normal file
23
modules/google_maps/address.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import urllib.parse
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class Address(metaclass=PoolMeta):
|
||||
__name__ = 'party.address'
|
||||
|
||||
google_maps_url = fields.Function(fields.Char('Google Maps'),
|
||||
'on_change_with_google_maps_url')
|
||||
|
||||
@fields.depends('full_address')
|
||||
def on_change_with_google_maps_url(self, name=None):
|
||||
lang = Transaction().language[:2]
|
||||
url = ' '.join((self.full_address or '').splitlines())
|
||||
if url.strip():
|
||||
return 'http://maps.google.com/maps?hl=%s&q=%s' % \
|
||||
(lang, urllib.parse.quote(url))
|
||||
return ''
|
||||
18
modules/google_maps/address.xml
Normal file
18
modules/google_maps/address.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="address_view_form">
|
||||
<field name="model">party.address</field>
|
||||
<field name="inherit" ref="party.address_view_form"/>
|
||||
<field name="name">address_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="address_view_form_simple">
|
||||
<field name="model">party.address</field>
|
||||
<field name="inherit" ref="party.address_view_form_simple"/>
|
||||
<field name="name">address_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
7
modules/google_maps/locale/bg.po
Normal file
7
modules/google_maps/locale/bg.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google карти"
|
||||
7
modules/google_maps/locale/ca.po
Normal file
7
modules/google_maps/locale/ca.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Mapes de Google"
|
||||
7
modules/google_maps/locale/cs.po
Normal file
7
modules/google_maps/locale/cs.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr ""
|
||||
7
modules/google_maps/locale/de.po
Normal file
7
modules/google_maps/locale/de.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google Maps"
|
||||
7
modules/google_maps/locale/es.po
Normal file
7
modules/google_maps/locale/es.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Mapas de Google"
|
||||
7
modules/google_maps/locale/es_419.po
Normal file
7
modules/google_maps/locale/es_419.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Mapas de Google"
|
||||
7
modules/google_maps/locale/et.po
Normal file
7
modules/google_maps/locale/et.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google kaardid"
|
||||
7
modules/google_maps/locale/fa.po
Normal file
7
modules/google_maps/locale/fa.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "نقشه های گوگل"
|
||||
7
modules/google_maps/locale/fi.po
Normal file
7
modules/google_maps/locale/fi.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr ""
|
||||
7
modules/google_maps/locale/fr.po
Normal file
7
modules/google_maps/locale/fr.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google Maps"
|
||||
7
modules/google_maps/locale/hu.po
Normal file
7
modules/google_maps/locale/hu.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr ""
|
||||
7
modules/google_maps/locale/id.po
Normal file
7
modules/google_maps/locale/id.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Peta Google"
|
||||
7
modules/google_maps/locale/it.po
Normal file
7
modules/google_maps/locale/it.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Mappe di Google"
|
||||
7
modules/google_maps/locale/lo.po
Normal file
7
modules/google_maps/locale/lo.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "ແຜນທີ່ ຄູເກີນລ໌"
|
||||
7
modules/google_maps/locale/lt.po
Normal file
7
modules/google_maps/locale/lt.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr ""
|
||||
7
modules/google_maps/locale/nl.po
Normal file
7
modules/google_maps/locale/nl.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google Maps"
|
||||
7
modules/google_maps/locale/pl.po
Normal file
7
modules/google_maps/locale/pl.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Mapy Google"
|
||||
7
modules/google_maps/locale/pt.po
Normal file
7
modules/google_maps/locale/pt.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google Maps"
|
||||
7
modules/google_maps/locale/ro.po
Normal file
7
modules/google_maps/locale/ro.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Hărți Google"
|
||||
7
modules/google_maps/locale/ru.po
Normal file
7
modules/google_maps/locale/ru.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Карта Google Maps"
|
||||
7
modules/google_maps/locale/sl.po
Normal file
7
modules/google_maps/locale/sl.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google zemljevid"
|
||||
7
modules/google_maps/locale/tr.po
Normal file
7
modules/google_maps/locale/tr.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "Google Haritalar"
|
||||
7
modules/google_maps/locale/uk.po
Normal file
7
modules/google_maps/locale/uk.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr ""
|
||||
7
modules/google_maps/locale/zh_CN.po
Normal file
7
modules/google_maps/locale/zh_CN.po
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:party.address,google_maps_url:"
|
||||
msgid "Google Maps"
|
||||
msgstr "谷歌地图"
|
||||
2
modules/google_maps/tests/__init__.py
Normal file
2
modules/google_maps/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
BIN
modules/google_maps/tests/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/google_maps/tests/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
46
modules/google_maps/tests/test_module.py
Normal file
46
modules/google_maps/tests/test_module.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class GoogleMapsTestCase(ModuleTestCase):
|
||||
'Test GoogleMaps module'
|
||||
module = 'google_maps'
|
||||
|
||||
@with_transaction()
|
||||
def test_google_maps_url(self):
|
||||
"Test Google Maps URL"
|
||||
pool = Pool()
|
||||
Address = pool.get('party.address')
|
||||
Party = pool.get('party.party')
|
||||
party = Party()
|
||||
party.save()
|
||||
address = Address()
|
||||
address.party = party
|
||||
address.street = "300 Cliff Street"
|
||||
address.postal_code = "18503"
|
||||
address.city = "Scranton"
|
||||
address.save()
|
||||
|
||||
self.assertEqual(
|
||||
address.on_change_with_google_maps_url(),
|
||||
'http://maps.google.com/maps?hl=en&'
|
||||
'q=300%20Cliff%20Street%2018503%20Scranton')
|
||||
|
||||
address = Address()
|
||||
address.party = party
|
||||
address.street = "Dépôt Street"
|
||||
address.postal_code = "18503"
|
||||
address.city = "Scranton"
|
||||
address.save()
|
||||
|
||||
self.assertEqual(
|
||||
address.on_change_with_google_maps_url(),
|
||||
'http://maps.google.com/maps?hl=en&'
|
||||
'q=D%C3%A9p%C3%B4t%20Street%2018503%20Scranton')
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
11
modules/google_maps/tryton.cfg
Normal file
11
modules/google_maps/tryton.cfg
Normal file
@@ -0,0 +1,11 @@
|
||||
[tryton]
|
||||
version=7.8.1
|
||||
depends:
|
||||
ir
|
||||
party
|
||||
xml:
|
||||
address.xml
|
||||
|
||||
[register]
|
||||
model:
|
||||
address.Address
|
||||
9
modules/google_maps/view/address_form.xml
Normal file
9
modules/google_maps/view/address_form.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="//group[@id='checkboxes']/field[@name='sequence']" position="after">
|
||||
<label name="google_maps_url"/>
|
||||
<field name="google_maps_url" widget="url"/>
|
||||
</xpath>
|
||||
</data>
|
||||
Reference in New Issue
Block a user