commit 737994800a4db348e63a27113520c352c6fe15fb Author: Cédric Krier Date: Thu Jun 5 10:21:33 2008 +0200 Initial commit for google_maps module diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000000..743e34e64a --- /dev/null +++ b/__init__.py @@ -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 * diff --git a/__tryton__.py b/__tryton__.py new file mode 100644 index 0000000000..979684bb3d --- /dev/null +++ b/__tryton__.py @@ -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", + ], +} diff --git a/address.py b/address.py new file mode 100644 index 0000000000..096bc5d227 --- /dev/null +++ b/address.py @@ -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() diff --git a/address.xml b/address.xml new file mode 100644 index 0000000000..a9a9f709f5 --- /dev/null +++ b/address.xml @@ -0,0 +1,22 @@ + + + + + relationship.address + + + + + + + + ]]> + + + + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..375ebb3beb --- /dev/null +++ b/setup.py @@ -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, + }, +)