From 879c6102f7066223f917d54517c64d3e6ad95207 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jan 2013 16:15:15 +0100 Subject: [PATCH] [ADD] better_zip for v7.0 --- better_zip/__init__.py | 20 +++++++++++ better_zip/__openerp__.py | 29 ++++++++++++++++ better_zip/better_zip.py | 57 ++++++++++++++++++++++++++++++ better_zip/better_zip_view.xml | 59 ++++++++++++++++++++++++++++++++ better_zip/security/security.xml | 13 +++++++ 5 files changed, 178 insertions(+) create mode 100644 better_zip/__init__.py create mode 100644 better_zip/__openerp__.py create mode 100644 better_zip/better_zip.py create mode 100644 better_zip/better_zip_view.xml create mode 100644 better_zip/security/security.xml diff --git a/better_zip/__init__.py b/better_zip/__init__.py new file mode 100644 index 000000000..cc8209e99 --- /dev/null +++ b/better_zip/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Nicolas Bessi. Copyright Camptocamp SA +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from . import better_zip diff --git a/better_zip/__openerp__.py b/better_zip/__openerp__.py new file mode 100644 index 000000000..e88013c19 --- /dev/null +++ b/better_zip/__openerp__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Nicolas Bessi. Copyright Camptocamp SA +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +{'name': 'Better zip management', + 'version': '0.3', + 'depends': ['base',], + 'author': 'Camptocamp', + 'description': """Introduce a better zip/npa management system. Enable partner completion""", + 'website': 'http://www.camptocamp.com', + 'data': ['security/security.xml', 'better_zip_view.xml'], + 'installable': True, + 'active': False, + } diff --git a/better_zip/better_zip.py b/better_zip/better_zip.py new file mode 100644 index 000000000..aa9d844ad --- /dev/null +++ b/better_zip/better_zip.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Nicolas Bessi. Copyright Camptocamp SA +# +# 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv.orm import Model, fields + + +class BetterZip(Model): + " Zip/NPA object" + + _name = "res.better.zip" + _description = __doc__ + _order = "priority" + + _columns = {'priority': fields.integer('Priority'), + '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'), + } + + _defaults = {'priority': 100} + + def name_get(self, cursor, uid, ids, context=None): + res = [] + for bzip in self.browse(cursor, uid, ids): + res.append((bzip.id, u"%s %s" % (bzip.name, bzip.city))) + return res + + +class Partner(Model): + _inherit = "res.partner" + _columns = {'zip_id': fields.many2one('res.better.zip', 'ZIP/PN')} + + 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, 'state_id': bzip.state_id.id}} diff --git a/better_zip/better_zip_view.xml b/better_zip/better_zip_view.xml new file mode 100644 index 000000000..0bf23ca0e --- /dev/null +++ b/better_zip/better_zip_view.xml @@ -0,0 +1,59 @@ + + + + + res.partner.zip_id.2 + res.partner + + + + + + + + + + res.better.zip.form + res.better.zip + +
+ + + + + + + +
+
+
+ + + res.better.zip.tree + res.better.zip + + + + + + + + + + + + ZIP Management + res.better.zip + form + tree,form + + + + +
+
diff --git a/better_zip/security/security.xml b/better_zip/security/security.xml new file mode 100644 index 000000000..4139e2ea5 --- /dev/null +++ b/better_zip/security/security.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file