Browse Source
[MRG] porting city addons into better diff:
[MRG] porting city addons into better diff:
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 CSVpull/2/head
unknown
12 years ago
12 changed files with 226 additions and 46 deletions
-
6better_zip/__init__.py
-
15better_zip/__openerp__.py
-
48better_zip/better_zip.py
-
14better_zip/better_zip_view.xml
-
44better_zip/company.py
-
19better_zip/company_view.xml
-
39better_zip/partner.py
-
17better_zip/partner_view.xml
-
3better_zip/security/ir.model.access.csv
-
13better_zip/security/security.xml
-
28better_zip/state.py
-
26better_zip/state_view.xml
@ -0,0 +1,44 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Nicolas Bessi. Copyright Camptocamp SA |
|||
# Contributor: Pedro Manuel Baeza <pedro.baeza@gmail.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')), |
|||
} |
@ -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="ZIP completion" /> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -0,0 +1,39 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Nicolas Bessi. Copyright Camptocamp SA |
|||
# Contributor: Pedro Manuel Baeza <pedro.baeza@gmail.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', '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 if bzip.country_id else False, |
|||
'state_id': bzip.state_id.id if bzip.state_id else False, |
|||
} |
|||
} |
@ -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="ZIP completion"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -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 |
@ -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> |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Author: Nicolas Bessi. Copyright Camptocamp SA |
|||
# Contributor: Pedro Manuel Baeza <pedro.baeza@gmail.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')} |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue