Browse Source

[ADD] better_zip for v7.0

pull/2/head
unknown 12 years ago
parent
commit
879c6102f7
  1. 20
      better_zip/__init__.py
  2. 29
      better_zip/__openerp__.py
  3. 57
      better_zip/better_zip.py
  4. 59
      better_zip/better_zip_view.xml
  5. 13
      better_zip/security/security.xml

20
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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import better_zip

29
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 <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,
}

57
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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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}}

59
better_zip/better_zip_view.xml

@ -0,0 +1,59 @@
<?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>
<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="city"/>
<field name="priority"/>
<field name="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="city"/>
<field name="country_id"/>
<field name="priority"/>
</tree>
</field>
</record>
<record id="action_zip_tree" model="ir.actions.act_window">
<field name="name">ZIP 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="ZIP Management"
id="zip_base"
parent="base.menu_base_config"
action="action_zip_tree"
/>
</data>
</openerp>

13
better_zip/security/security.xml

@ -0,0 +1,13 @@
<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="&quot;&quot;&quot;better_zip&quot;&quot;&quot;" 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