From 89ac818e1db0b25c127a17040e2e4c319fbfef27 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jun 2013 10:29:42 +0200 Subject: [PATCH] [MV] rename better_zip to base_location --- base_location/__init__.py | 25 +++++ base_location/__openerp__.py | 37 +++++++ base_location/better_zip.py | 72 ++++++++++++++ base_location/better_zip_view.xml | 51 ++++++++++ base_location/company.py | 45 +++++++++ base_location/company_view.xml | 19 ++++ base_location/i18n/en.po | 107 ++++++++++++++++++++ base_location/i18n/es.po | 108 +++++++++++++++++++++ base_location/i18n/fr.po | 107 ++++++++++++++++++++ base_location/partner.py | 40 ++++++++ base_location/partner_view.xml | 17 ++++ base_location/security/ir.model.access.csv | 3 + base_location/state.py | 29 ++++++ base_location/state_view.xml | 26 +++++ 14 files changed, 686 insertions(+) create mode 100644 base_location/__init__.py create mode 100644 base_location/__openerp__.py create mode 100644 base_location/better_zip.py create mode 100644 base_location/better_zip_view.xml create mode 100644 base_location/company.py create mode 100644 base_location/company_view.xml create mode 100644 base_location/i18n/en.po create mode 100644 base_location/i18n/es.po create mode 100644 base_location/i18n/fr.po create mode 100644 base_location/partner.py create mode 100644 base_location/partner_view.xml create mode 100644 base_location/security/ir.model.access.csv create mode 100644 base_location/state.py create mode 100644 base_location/state_view.xml diff --git a/base_location/__init__.py b/base_location/__init__.py new file mode 100644 index 000000000..ba9aeedea --- /dev/null +++ b/base_location/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# Contributor: Pedro Manuel Baeza +# Ignacio Ibeas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import better_zip +from . import partner +from . import state +from . import company diff --git a/base_location/__openerp__.py b/base_location/__openerp__.py new file mode 100644 index 000000000..682a4d90b --- /dev/null +++ b/base_location/__openerp__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# Contributor: Pedro Manuel Baeza +# Ignacio Ibeas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{'name': 'Location management (aka Better ZIP)', + 'version': '0.3', + 'depends': ['base'], + 'author': 'Camptocamp', + 'description': """ +Introduces a better zip/npa management system. +It enables zip/city auto-completion on partners""", + 'website': 'http://www.camptocamp.com', + 'data': ['better_zip_view.xml', + 'state_view.xml', + 'company_view.xml', + 'partner_view.xml', + 'security/ir.model.access.csv'], + 'installable': True, + 'active': False, + } diff --git a/base_location/better_zip.py b/base_location/better_zip.py new file mode 100644 index 000000000..56de4616e --- /dev/null +++ b/base_location/better_zip.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# Contributor: Pedro Manuel Baeza +# Ignacio Ibeas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import orm, fields + + +class BetterZip(orm.Model): + " City/locations completion object" + + _name = "res.better.zip" + _description = __doc__ + _order = "priority" + + _columns = {'priority': fields.integer('Priority', deprecated=True), + 'name': fields.char('ZIP', required=True), + 'city': fields.char('City', required=True), + 'state_id': fields.many2one('res.country.state', 'State'), + 'country_id': fields.many2one('res.country', 'Country'), + 'code': fields.char('City Code', size=64, + help="The official code for the city"), + } + + _defaults = {'priority': 100} + + def name_get(self, cursor, uid, ids, context=None): + res = [] + for bzip in self.browse(cursor, uid, ids): + name = [bzip.name, bzip.city] + if bzip.state_id: + name.append(bzip.state_id.name) + if bzip.country_id: + name.append(bzip.country_id.name) + res.append((bzip.id, ", ".join(name))) + return res + + def onchange_state_id(self, cr, uid, ids, state_id=False, context={}): + result = {} + if state_id: + state = self.pool['res.country.state'].browse(cr, uid, state_id, context=context) + if state: + result['value'] = {'country_id': state.country_id.id} + return result + + def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): + if args is None: + args = [] + if context is None: + context = {} + ids = [] + if name: + ids = self.search(cr, uid, [('name', 'ilike', name)] + args, limit=limit) + if not ids: + ids = self.search(cr, uid, [('city', operator, name)] + args, limit=limit) + return self.name_get(cr, uid, ids, context=context) diff --git a/base_location/better_zip_view.xml b/base_location/better_zip_view.xml new file mode 100644 index 000000000..0fc8d11de --- /dev/null +++ b/base_location/better_zip_view.xml @@ -0,0 +1,51 @@ + + + + + + res.better.zip.form + res.better.zip + +
+ + + + + + + + +
+
+
+ + + res.better.zip.tree + res.better.zip + + + + + + + + + + + + + Cites/locations Management + res.better.zip + form + tree,form + + + + +
+
diff --git a/base_location/company.py b/base_location/company.py new file mode 100644 index 000000000..03ab50bb5 --- /dev/null +++ b/base_location/company.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# Contributor: Pedro Manuel Baeza +# Ignacio Ibeas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import orm, fields + + +class ResCompany(orm.Model): + + _inherit = 'res.company' + + def on_change_city(self, cursor, uid, ids, zip_id): + result = {} + if zip_id: + bzip = self.pool['res.better.zip'].browse(cursor, uid, zip_id) + result = {'value': {'zip': bzip.name, + 'country_id': bzip.country_id.id if bzip.country_id else False, + 'city': bzip.city, + 'state_id': bzip.state_id.id if bzip.state_id else False + } + } + return result + + _columns = { + 'better_zip_id': fields.many2one('res.better.zip', 'Location', select=1, + help=('Use the city name or the zip code' + ' to search the location')), + } diff --git a/base_location/company_view.xml b/base_location/company_view.xml new file mode 100644 index 000000000..d697158e3 --- /dev/null +++ b/base_location/company_view.xml @@ -0,0 +1,19 @@ + + + + + + res.company.form.city + res.company + + + + + + + + + diff --git a/base_location/i18n/en.po b/base_location/i18n/en.po new file mode 100644 index 000000000..6d35374c8 --- /dev/null +++ b/base_location/i18n/en.po @@ -0,0 +1,107 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * better_zip +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-06-07 14:17+0000\n" +"PO-Revision-Date: 2013-05-08 12:03+0000\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: better_zip +#: model:ir.actions.act_window,name:better_zip.action_zip_tree +msgid "Cites/locations Management" +msgstr "Cites/locations Management" + +#. module: better_zip +#: field:res.better.zip,city:0 +msgid "City" +msgstr "City" + +#. module: better_zip +#: view:res.better.zip:0 field:res.better.zip,name:0 +msgid "ZIP" +msgstr "ZIP" + +#. module: better_zip +#: field:res.better.zip,country_id:0 +msgid "Country" +msgstr "Country" + +#. module: better_zip +#: field:res.better.zip,priority:0 +msgid "Priority" +msgstr "Priority" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_company +msgid "Companies" +msgstr "Companies" + +#. module: better_zip +#: field:res.better.zip,code:0 +msgid "City Code" +msgstr "City Code" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_better_zip +msgid " City/locations completion object" +msgstr " City/locations completion object" + +#. module: better_zip +#: help:res.company,better_zip_id:0 +msgid "Use the city name or the zip code to search the location" +msgstr "Use the city name or the zip code to search the location" + +#. module: better_zip +#: field:res.partner,zip_id:0 +msgid "City/Location" +msgstr "City/Location" + +#. module: better_zip +#: field:res.better.zip,state_id:0 +msgid "State" +msgstr "State" + +#. module: better_zip +#: field:res.company,better_zip_id:0 +msgid "Location" +msgstr "Location" + +#. module: better_zip +#: model:ir.ui.menu,name:better_zip.zip_base +msgid "Cities/Locations Management" +msgstr "Cities/Locations Management" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: better_zip +#: view:res.company:0 view:res.partner:0 +msgid "City completion" +msgstr "City completion" + +#. module: better_zip +#: field:res.country.state,better_zip_ids:0 +msgid "Cities" +msgstr "Cities" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_country_state +msgid "Country state" +msgstr "Country state" + +#. module: better_zip +#: help:res.better.zip,code:0 +msgid "The official code for the city" +msgstr "The official code for the city" diff --git a/base_location/i18n/es.po b/base_location/i18n/es.po new file mode 100644 index 000000000..22c7becb2 --- /dev/null +++ b/base_location/i18n/es.po @@ -0,0 +1,108 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * better_zip +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-06-07 14:17+0000\n" +"PO-Revision-Date: 2013-05-08 12:04+0000\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: better_zip +#: model:ir.actions.act_window,name:better_zip.action_zip_tree +msgid "Cites/locations Management" +msgstr "Cites/locations Management" + +#. module: better_zip +#: field:res.better.zip,city:0 +msgid "City" +msgstr "City" + +#. module: better_zip +#: view:res.better.zip:0 field:res.better.zip,name:0 +msgid "ZIP" +msgstr "ZIP" + +#. module: better_zip +#: field:res.better.zip,country_id:0 +msgid "Country" +msgstr "Country" + +#. module: better_zip +#: field:res.better.zip,priority:0 +msgid "Priority" +msgstr "Priority" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_company +msgid "Companies" +msgstr "Companies" + +#. module: better_zip +#: field:res.better.zip,code:0 +msgid "City Code" +msgstr "City Code" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_better_zip +msgid " City/locations completion object" +msgstr " City/locations completion object" + +#. module: better_zip +#: help:res.company,better_zip_id:0 +msgid "Use the city name or the zip code to search the location" +msgstr "Use the city name or the zip code to search the location" + +#. module: better_zip +#: field:res.partner,zip_id:0 +msgid "City/Location" +msgstr "City/Location" + +#. module: better_zip +#: field:res.better.zip,state_id:0 +msgid "State" +msgstr "State" + +#. module: better_zip +#: field:res.company,better_zip_id:0 +msgid "Location" +msgstr "Location" + +#. module: better_zip +#: model:ir.ui.menu,name:better_zip.zip_base +msgid "Cities/Locations Management" +msgstr "Cities/Locations Management" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: better_zip +#: view:res.company:0 view:res.partner:0 +#, fuzzy +msgid "City completion" +msgstr "City completion" + +#. module: better_zip +#: field:res.country.state,better_zip_ids:0 +msgid "Cities" +msgstr "Cities" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_country_state +msgid "Country state" +msgstr "Country state" + +#. module: better_zip +#: help:res.better.zip,code:0 +msgid "The official code for the city" +msgstr "The official code for the city" diff --git a/base_location/i18n/fr.po b/base_location/i18n/fr.po new file mode 100644 index 000000000..c7d5fc968 --- /dev/null +++ b/base_location/i18n/fr.po @@ -0,0 +1,107 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * better_zip +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-06-07 14:17+0000\n" +"PO-Revision-Date: 2013-05-08 12:03+0000\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: better_zip +#: model:ir.actions.act_window,name:better_zip.action_zip_tree +msgid "Cites/locations Management" +msgstr "Cites/locations Management" + +#. module: better_zip +#: field:res.better.zip,city:0 +msgid "City" +msgstr "Ville" + +#. module: better_zip +#: view:res.better.zip:0 field:res.better.zip,name:0 +msgid "ZIP" +msgstr "ZIP" + +#. module: better_zip +#: field:res.better.zip,country_id:0 +msgid "Country" +msgstr "Pays" + +#. module: better_zip +#: field:res.better.zip,priority:0 +msgid "Priority" +msgstr "Priorité" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: better_zip +#: field:res.better.zip,code:0 +msgid "City Code" +msgstr "Code de la ville" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_better_zip +msgid " City/locations completion object" +msgstr " City/locations completion object" + +#. module: better_zip +#: help:res.company,better_zip_id:0 +msgid "Use the city name or the zip code to search the location" +msgstr "Utilisez le nom de la ville ou le zip lors des recherches" + +#. module: better_zip +#: field:res.partner,zip_id:0 +msgid "City/Location" +msgstr "Ville/location" + +#. module: better_zip +#: field:res.better.zip,state_id:0 +msgid "State" +msgstr "Etat" + +#. module: better_zip +#: field:res.company,better_zip_id:0 +msgid "Location" +msgstr "Location" + +#. module: better_zip +#: model:ir.ui.menu,name:better_zip.zip_base +msgid "Cities/Locations Management" +msgstr "Cities/Locations Management" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: better_zip +#: view:res.company:0 view:res.partner:0 +msgid "City completion" +msgstr "Complétion par ville" + +#. module: better_zip +#: field:res.country.state,better_zip_ids:0 +msgid "Cities" +msgstr "Villes" + +#. module: better_zip +#: model:ir.model,name:better_zip.model_res_country_state +msgid "Country state" +msgstr "Etat" + +#. module: better_zip +#: help:res.better.zip,code:0 +msgid "The official code for the city" +msgstr "Code officiel de la ville" diff --git a/base_location/partner.py b/base_location/partner.py new file mode 100644 index 000000000..b6db7bc8b --- /dev/null +++ b/base_location/partner.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# Contributor: Pedro Manuel Baeza +# Ignacio Ibeas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import orm, fields + + +class ResPartner(orm.Model): + _inherit = "res.partner" + _columns = {'zip_id': fields.many2one('res.better.zip', 'City/Location')} + + def onchange_zip_id(self, cursor, uid, ids, zip_id, context=None): + if not zip_id: + return {} + if isinstance(zip_id, list): + zip_id = zip_id[0] + bzip = self.pool['res.better.zip'].browse(cursor, uid, zip_id, context=context) + return {'value': {'zip': bzip.name, + 'city': bzip.city, + 'country_id': bzip.country_id.id if bzip.country_id else False, + 'state_id': bzip.state_id.id if bzip.state_id else False, + } + } diff --git a/base_location/partner_view.xml b/base_location/partner_view.xml new file mode 100644 index 000000000..cc6b29301 --- /dev/null +++ b/base_location/partner_view.xml @@ -0,0 +1,17 @@ + + + + + res.partner.zip_id.2 + res.partner + + + + + + + + + diff --git a/base_location/security/ir.model.access.csv b/base_location/security/ir.model.access.csv new file mode 100644 index 000000000..c6562df1b --- /dev/null +++ b/base_location/security/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"ir_model_access_betterzip0","res_better_zip group_user_all","model_res_better_zip",base.group_user,1,0,0,0 +"ir_model_access_betterzip1","res_better_zip group_user","model_res_better_zip","base.group_partner_manager",1,1,1,1 \ No newline at end of file diff --git a/base_location/state.py b/base_location/state.py new file mode 100644 index 000000000..4312384af --- /dev/null +++ b/base_location/state.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Nicolas Bessi. Copyright Camptocamp SA +# Contributor: Pedro Manuel Baeza +# Ignacio Ibeas +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import orm, fields + + +class ResCountryState(orm.Model): + + _inherit = 'res.country.state' + + _columns = {'better_zip_ids': fields.one2many('res.better.zip', 'state_id', 'Cities')} diff --git a/base_location/state_view.xml b/base_location/state_view.xml new file mode 100644 index 000000000..96497c9e5 --- /dev/null +++ b/base_location/state_view.xml @@ -0,0 +1,26 @@ + + + + + + view_country_state_form2 + res.country.state + + + + + + + + + + + + + + + +