Initial commit for google_maps module
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
# Copyright (c) 2007 Cedric Krier.
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contact a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from address import *
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name" : "Google Maps",
|
||||
"version" : "0.1",
|
||||
"author" : "B2CK",
|
||||
'email': 'info@b2ck.com',
|
||||
'website': 'http://www.tryton.org/',
|
||||
"category" : "Generic",
|
||||
"description": "Add link from addresses to Google Maps",
|
||||
"depends" : [
|
||||
"ir",
|
||||
"relationship"
|
||||
],
|
||||
"xml" : [
|
||||
"address.xml",
|
||||
],
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
from trytond.osv import fields, OSV
|
||||
import urllib
|
||||
|
||||
class Address(OSV):
|
||||
_name = 'relationship.address'
|
||||
|
||||
google_maps_url = fields.Function('get_google_maps_url', type="char",
|
||||
string="Google Maps")
|
||||
|
||||
def get_google_maps_url(self, cursor, user, ids, name, arg, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = {}
|
||||
lang = context.get('language', 'en_US')[:2]
|
||||
for address in self.browse(cursor, user, ids, context=context):
|
||||
query = ''
|
||||
if address.street:
|
||||
query += ' ' + address.street
|
||||
if address.streetbis:
|
||||
query += ' ' + address.streetbis
|
||||
if address.zip:
|
||||
query += ' ' + address.zip
|
||||
if address.city:
|
||||
query += ' ' + address.city
|
||||
if address.country:
|
||||
query += ' ' + address.country.name
|
||||
if address.state:
|
||||
query += ' ' + address.state.name
|
||||
res[address.id] = 'http://maps.google.com/maps?hl=%s&q=%s' % \
|
||||
(lang, urllib.quote(query.strip()))
|
||||
return res
|
||||
|
||||
Address()
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="address_view_form">
|
||||
<field name="model">relationship.address</field>
|
||||
<field name="inherit" ref="relationship.address_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name="email"]"
|
||||
position="after">
|
||||
<newline/>
|
||||
<label name="google_maps_url"/>
|
||||
<field name="google_maps_url" widget="url"/>
|
||||
</xpath>
|
||||
</data>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from distutils.core import setup
|
||||
from distutils.command import sdist
|
||||
|
||||
|
||||
class mysdist(sdist.sdist):
|
||||
|
||||
def add_defaults(self):
|
||||
sdist.sdist.add_defaults(self)
|
||||
if self.distribution.has_pure_modules():
|
||||
build_py = self.get_finalized_command('build_py')
|
||||
data = []
|
||||
for package in build_py.packages:
|
||||
src_dir = build_py.get_package_dir(package)
|
||||
data.extend(build_py.find_data_files(package, src_dir))
|
||||
self.filelist.extend(data)
|
||||
|
||||
info = eval(file('__tryton__.py').read())
|
||||
|
||||
requires = ['trytond'] + ['trytond-' + x for x in info.get('depends', [])]
|
||||
|
||||
setup(name='trytond-' + info['name'].lower(),
|
||||
version=info.get('version', '0'),
|
||||
description=info.get('description', ''),
|
||||
author=info.get('author', ''),
|
||||
author_email=info.get('email', ''),
|
||||
url=info.get('website', ''),
|
||||
package_dir={'trytond.modules.' + info['name'].lower(): '.'},
|
||||
packages=[
|
||||
'trytond.modules.' + info['name'].lower(),
|
||||
],
|
||||
package_data={
|
||||
'trytond.modules.' + info['name'].lower(): info.get('xml', []) + ['label.odt'],
|
||||
},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Plugins',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Financial and Insurance Industry',
|
||||
'Intended Audience :: Legal Industry',
|
||||
'Intended Audience :: Manufacturing',
|
||||
'Natural Language :: English',
|
||||
'Natural Language :: French',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: Office/Business',
|
||||
],
|
||||
license=info.get('license', 'GPL-2'),
|
||||
#requires=requires,
|
||||
cmdclass={
|
||||
'sdist': mysdist,
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user