Browse Source

[RFR] Porting city addons into better zip:

-More complexe name get and name search.
  -Completion of country when changing state.
  -Zip object is added on company.
  -One2many from state to zip
  -Security is CSV
  -Spanish translation by Pedro M. Baeza
pull/2/head
unknown 12 years ago
committed by Stefan Rijnhart
parent
commit
46a0f2e257
  1. 7
      base_location/__init__.py
  2. 37
      base_location/__openerp__.py
  3. 72
      base_location/better_zip.py
  4. 20
      base_location/better_zip_view.xml
  5. 47
      base_location/company.py
  6. 19
      base_location/company_view.xml
  7. 109
      base_location/i18n/base_location.pot
  8. 107
      base_location/i18n/en.po
  9. 109
      base_location/i18n/es.po
  10. 107
      base_location/i18n/fr.po
  11. 41
      base_location/partner.py
  12. 17
      base_location/partner_view.xml
  13. 3
      base_location/security/ir.model.access.csv
  14. 22
      base_location/state.py
  15. 26
      base_location/state_view.xml
  16. 1
      better_zip
  17. 13
      better_zip/security/security.xml

7
better_zip/__init__.py → base_location/__init__.py

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Nicolas Bessi. Copyright Camptocamp SA
# Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# Ignacio Ibeas <ignacio@acysos.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -18,3 +20,6 @@
#
##############################################################################
from . import better_zip
from . import partner
from . import state
from . import company

37
base_location/__openerp__.py

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# Ignacio Ibeas <ignacio@acysos.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{'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,
}

72
base_location/better_zip.py

@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# Ignacio Ibeas <ignacio@acysos.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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=None):
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)

20
better_zip/better_zip_view.xml → base_location/better_zip_view.xml

@ -1,16 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.zip_id.2</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="city" position="before">
<field name="zip_id" on_change="onchange_zip_id(zip_id)" placeholder="ZIP completion"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="better_zip_form">
<field name="name">res.better.zip.form</field>
@ -19,9 +9,10 @@
<form string="ZIP" version="7.0">
<group col="4">
<field name="name"/>
<field name="code"/>
<field name="city"/>
<field name="priority"/>
<field name="state_id"/>
<field name="state_id" on_change="onchange_state_id(state_id)"/>
<field name="country_id"/>
</group>
</form>
@ -34,6 +25,7 @@
<field name="arch" type="xml">
<tree string="ZIP">
<field name="name"/>
<field name="code"/>
<field name="city"/>
<field name="country_id"/>
<field name="priority"/>
@ -42,7 +34,7 @@
</record>
<record id="action_zip_tree" model="ir.actions.act_window">
<field name="name">ZIP Management</field>
<field name="name">Cites/locations Management</field>
<field name="res_model">res.better.zip</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@ -50,9 +42,9 @@
</record>
<menuitem
name="ZIP Management"
name="Cities/Locations Management"
id="zip_base"
parent="base.menu_base_config"
parent="base.menu_localisation"
action="action_zip_tree"
/>
</data>

47
base_location/company.py

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# Ignacio Ibeas <ignacio@acysos.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class ResCompany(orm.Model):
_inherit = 'res.company'
def on_change_city(self, cr, uid, ids, zip_id, context=None):
result = {}
if context is None:
context = {}
if zip_id:
bzip = self.pool['res.better.zip'].browse(cr, uid, zip_id, context=context)
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')),
}

19
base_location/company_view.xml

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Add cities to the company form -->
<record id="view_company_form_city" model="ir.ui.view">
<field name="name">res.company.form.city</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<field name="street2" position="after">
<field name="better_zip_id"
colspan="4"
on_change="on_change_city(better_zip_id)"
placeholder="City completion" />
</field>
</field>
</record>
</data>
</openerp>

109
base_location/i18n/base_location.pot

@ -0,0 +1,109 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_location
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-06-25 08:56+0000\n"
"PO-Revision-Date: 2013-06-25 08:56+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_location
#: model:ir.actions.act_window,name:base_location.action_zip_tree
msgid "Cites/locations Management"
msgstr ""
#. module: base_location
#: field:res.better.zip,city:0
msgid "City"
msgstr ""
#. module: base_location
#: view:res.better.zip:0
#: field:res.better.zip,name:0
msgid "ZIP"
msgstr ""
#. module: base_location
#: field:res.better.zip,country_id:0
msgid "Country"
msgstr ""
#. module: base_location
#: field:res.better.zip,priority:0
msgid "Priority"
msgstr ""
#. module: base_location
#: model:ir.model,name:base_location.model_res_company
msgid "Companies"
msgstr ""
#. module: base_location
#: field:res.better.zip,code:0
msgid "City Code"
msgstr ""
#. module: base_location
#: model:ir.model,name:base_location.model_res_better_zip
msgid " City/locations completion object"
msgstr ""
#. module: base_location
#: help:res.company,better_zip_id:0
msgid "Use the city name or the zip code to search the location"
msgstr ""
#. module: base_location
#: field:res.partner,zip_id:0
msgid "City/Location"
msgstr ""
#. module: base_location
#: field:res.better.zip,state_id:0
msgid "State"
msgstr ""
#. module: base_location
#: field:res.company,better_zip_id:0
msgid "Location"
msgstr ""
#. module: base_location
#: model:ir.ui.menu,name:base_location.zip_base
msgid "Cities/Locations Management"
msgstr ""
#. module: base_location
#: model:ir.model,name:base_location.model_res_partner
msgid "Partner"
msgstr ""
#. module: base_location
#: view:res.company:0
#: view:res.partner:0
msgid "City completion"
msgstr ""
#. module: base_location
#: field:res.country.state,better_zip_ids:0
msgid "Cities"
msgstr ""
#. module: base_location
#: model:ir.model,name:base_location.model_res_country_state
msgid "Country state"
msgstr ""
#. module: base_location
#: help:res.better.zip,code:0
msgid "The official code for the city"
msgstr ""

107
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"

109
base_location/i18n/es.po

@ -0,0 +1,109 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_location
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-06-25 08:47+0000\n"
"PO-Revision-Date: 2013-06-25 10:47+0100\n"
"Last-Translator: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: base_location
#: model:ir.actions.act_window,name:base_location.action_zip_tree
msgid "Cites/locations Management"
msgstr "Gestión de ciudades/ubicaciones"
#. module: base_location
#: field:res.better.zip,city:0
msgid "City"
msgstr "Ciudad"
#. module: base_location
#: view:res.better.zip:0
#: field:res.better.zip,name:0
msgid "ZIP"
msgstr "C.P."
#. module: base_location
#: field:res.better.zip,country_id:0
msgid "Country"
msgstr "País"
#. module: base_location
#: field:res.better.zip,priority:0
msgid "Priority"
msgstr "Prioridad"
#. module: base_location
#: model:ir.model,name:base_location.model_res_company
msgid "Companies"
msgstr "Compañías"
#. module: base_location
#: field:res.better.zip,code:0
msgid "City Code"
msgstr "Código de ciudad"
#. module: base_location
#: model:ir.model,name:base_location.model_res_better_zip
msgid " City/locations completion object"
msgstr " Objeto de completado de ciudad/ubicación"
#. module: base_location
#: help:res.company,better_zip_id:0
msgid "Use the city name or the zip code to search the location"
msgstr "Utilice el nombre de ciudad o el código postal para buscar la ubicación"
#. module: base_location
#: field:res.partner,zip_id:0
msgid "City/Location"
msgstr "Ciudad/Ubicación"
#. module: base_location
#: field:res.better.zip,state_id:0
msgid "State"
msgstr "Provincia"
#. module: base_location
#: field:res.company,better_zip_id:0
msgid "Location"
msgstr "Ubicación"
#. module: base_location
#: model:ir.ui.menu,name:base_location.zip_base
msgid "Cities/Locations Management"
msgstr "Ciudad/Ubicaciones"
#. module: base_location
#: model:ir.model,name:base_location.model_res_partner
msgid "Partner"
msgstr "Empresa"
#. module: base_location
#: view:res.company:0
#: view:res.partner:0
msgid "City completion"
msgstr "Autocompletado a partir de la ciudad"
#. module: base_location
#: field:res.country.state,better_zip_ids:0
msgid "Cities"
msgstr "Ciudades"
#. module: base_location
#: model:ir.model,name:base_location.model_res_country_state
msgid "Country state"
msgstr "Provincia"
#. module: base_location
#: help:res.better.zip,code:0
msgid "The official code for the city"
msgstr "El código oficial para la ciudad"

107
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"

41
better_zip/better_zip.py → base_location/partner.py

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Nicolas Bessi. Copyright Camptocamp SA
# Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# Ignacio Ibeas <ignacio@acysos.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -17,35 +19,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv.orm import Model, fields
from openerp.osv import orm, 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):
class ResPartner(orm.Model):
_inherit = "res.partner"
_columns = {'zip_id': fields.many2one('res.better.zip', 'ZIP/PN')}
_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:
@ -53,5 +32,9 @@ class Partner(Model):
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}}
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,
}
}

17
base_location/partner_view.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.zip_id.2</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="city" position="before">
<field name="zip_id"
on_change="onchange_zip_id(zip_id)"
placeholder="City completion"/>
</field>
</field>
</record>
</data>
</openerp>

3
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

22
better_zip/__openerp__.py → base_location/state.py

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Nicolas Bessi. Copyright Camptocamp SA
# Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
# Ignacio Ibeas <ignacio@acysos.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -17,13 +19,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{'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,
}
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')}

26
base_location/state_view.xml

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Add cities to the State form -->
<record model="ir.ui.view" id="view_country_state_form2">
<field name="name">view_country_state_form2</field>
<field name="model">res.country.state</field>
<field name="inherit_id" ref="base.view_country_state_form"/>
<field name="arch" type="xml">
<field name="country_id" position="after">
<field name="better_zip_ids"
context="{'country_id': country_id}"
colspan="4"
nolabel="1">
<tree editable="top">
<field name="name"/>
<field name="code"/>
<field name="city"/>
<field name="country_id"/>
</tree>
</field>
</field>
</field>
</record>
</data>
</openerp>

1
better_zip

@ -0,0 +1 @@
base_location

13
better_zip/security/security.xml

@ -1,13 +0,0 @@
<openerp>
<data>
<record id="ir_model_access_betterzip0" model="ir.model.access">
<field name="model_id" ref="better_zip.model_res_better_zip"/>
<field eval="1" name="perm_read"/>
<field eval="'better_zip'" name="name"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_create"/>
<field name="group_id" ref="base.group_user"/>
</record>
</data>
</openerp>
Loading…
Cancel
Save