Browse Source

[MV] rename better_zip to base_location

14.0
unknown 12 years ago
committed by Pedro M. Baeza
parent
commit
89ac818e1d
  1. 25
      base_location/__init__.py
  2. 37
      base_location/__openerp__.py
  3. 72
      base_location/better_zip.py
  4. 51
      base_location/better_zip_view.xml
  5. 45
      base_location/company.py
  6. 19
      base_location/company_view.xml
  7. 107
      base_location/i18n/en.po
  8. 108
      base_location/i18n/es.po
  9. 107
      base_location/i18n/fr.po
  10. 40
      base_location/partner.py
  11. 17
      base_location/partner_view.xml
  12. 3
      base_location/security/ir.model.access.csv
  13. 29
      base_location/state.py
  14. 26
      base_location/state_view.xml

25
base_location/__init__.py

@ -0,0 +1,25 @@
# -*- 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 . 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={}):
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)

51
base_location/better_zip_view.xml

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="better_zip_form">
<field name="name">res.better.zip.form</field>
<field name="model">res.better.zip</field>
<field name="arch" type="xml">
<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" on_change="onchange_state_id(state_id)"/>
<field name="country_id"/>
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="better_zip_tree">
<field name="name">res.better.zip.tree</field>
<field name="model">res.better.zip</field>
<field name="arch" type="xml">
<tree string="ZIP">
<field name="name"/>
<field name="code"/>
<field name="city"/>
<field name="country_id"/>
<field name="priority"/>
</tree>
</field>
</record>
<record id="action_zip_tree" model="ir.actions.act_window">
<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>
<field ref="better_zip_tree" name="view_id"/>
</record>
<menuitem
name="Cities/Locations Management"
id="zip_base"
parent="base.menu_localisation"
action="action_zip_tree"
/>
</data>
</openerp>

45
base_location/company.py

@ -0,0 +1,45 @@
# -*- 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, 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')),
}

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>

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"

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

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"

40
base_location/partner.py

@ -0,0 +1,40 @@
# -*- 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 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,
}
}

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

29
base_location/state.py

@ -0,0 +1,29 @@
# -*- 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 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>
Loading…
Cancel
Save