Browse Source

[FIX] base_location: Fix flake8 error, views naming, removing deprecated fields. Also use @api.one in onchanges. Using now spaces instead of tabs in xml files.

pull/81/head
Alejandro Santana 10 years ago
parent
commit
f7f02a6eb3
  1. 15
      base_location/__openerp__.py
  2. 3
      base_location/models/better_zip.py
  3. 15
      base_location/models/company.py
  4. 15
      base_location/models/partner.py
  5. 71
      base_location/views/better_zip.xml
  6. 70
      base_location/views/better_zip_view.xml
  7. 19
      base_location/views/company.xml
  8. 21
      base_location/views/company_view.xml
  9. 26
      base_location/views/partner.xml
  10. 27
      base_location/views/partner_view.xml
  11. 17
      base_location/views/res_country.xml
  12. 17
      base_location/views/res_country_view.xml
  13. 26
      base_location/views/state.xml
  14. 26
      base_location/views/state_view.xml

15
base_location/__openerp__.py

@ -32,17 +32,12 @@
'Alejandro Santana <alejandrosantana@anubia.es>',
],
'summary': '''Enhanced zip/npa management system''',
'description': '''
This module introduces a better zip/npa management system.
It enables zip, city, state and country auto-completion on partners and
companies.
Also allows different search filters.''',
'website': 'http://www.camptocamp.com',
'data': ['views/better_zip.xml',
'views/state.xml',
'views/res_country.xml',
'views/company.xml',
'views/partner.xml',
'data': ['views/better_zip_view.xml',
'views/state_view.xml',
'views/res_country_view.xml',
'views/company_view.xml',
'views/partner_view.xml',
'security/ir.model.access.csv'],
'installable': True,
'active': False,

3
base_location/models/better_zip.py

@ -27,9 +27,8 @@ class BetterZip(models.Model):
_name = "res.better.zip"
_description = __doc__
_order = "priority"
_order = "name asc"
priority = fields.Integer('Priority', default=100, deprecated=True)
name = fields.Char('ZIP')
code = fields.Char('City Code', size=64,
help="The official code for the city")

15
base_location/models/company.py

@ -27,19 +27,18 @@ class ResCompany(models.Model):
_inherit = 'res.company'
@api.multi
@api.one
@api.onchange('better_zip_id')
def on_change_city(self):
for record in self:
if record.better_zip_id:
record.zip = record.better_zip_id.name
record.city = record.better_zip_id.city
record.state_id = record.better_zip_id.state_id or False
record.country_id = record.better_zip_id.country_id or False
if self.better_zip_id:
self.zip = self.better_zip_id.name
self.city = self.better_zip_id.city
self.state_id = self.better_zip_id.state_id
self.country_id = self.better_zip_id.country_id
better_zip_id = fields.Many2one(
'res.better.zip',
string='Location',
select=1,
help=('Use the city name or the zip code to search the location'),
help='Use the city name or the zip code to search the location',
)

15
base_location/models/partner.py

@ -27,13 +27,12 @@ class ResPartner(models.Model):
_inherit = 'res.partner'
zip_id = fields.Many2one('res.better.zip', 'City/Location')
@api.multi
@api.one
@api.onchange('zip_id')
def onchange_zip_id(self):
for record in self:
if record.zip_id:
bzip = record.zip_id[0]
record.zip = bzip.name
record.city = bzip.city
record.state_id = bzip.state_id or False
record.country_id = bzip.country_id or False
if self.zip_id:
bzip = self.zip_id[0]
self.zip = bzip.name
self.city = bzip.city
self.state_id = bzip.state_id
self.country_id = bzip.country_id

71
base_location/views/better_zip.xml

@ -1,71 +0,0 @@
<?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"/>
<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="state_id"/>
<field name="country_id"/>
<field name="priority"/>
</tree>
</field>
</record>
<record id="view_better_zip_filter" model="ir.ui.view">
<field name="name">res.better.zip.select</field>
<field name="model">res.better.zip</field>
<field name="arch" type="xml">
<search string="Search city">
<field name="name"/>
<field name="code"/>
<field name="city"/>
<field name="state_id"/>
<field name="country_id"/>
<group expand="0" string="Group By">
<filter string="State" domain="[]" context="{'group_by':'state_id'}"/>
<filter string="Country" domain="[]" context="{'group_by':'country_id'}"/>
</group>
</search>
</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"/>
<field name="search_view_id" ref="view_better_zip_filter"/>
</record>
<menuitem
name="Cities/Locations Management"
id="zip_base"
parent="base.menu_localisation"
action="action_zip_tree"
/>
</data>
</openerp>

70
base_location/views/better_zip_view.xml

@ -0,0 +1,70 @@
<?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="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="state_id"/>
<field name="country_id"/>
</tree>
</field>
</record>
<record id="view_better_zip_filter" model="ir.ui.view">
<field name="name">res.better.zip.select</field>
<field name="model">res.better.zip</field>
<field name="arch" type="xml">
<search string="Search city">
<field name="name"/>
<field name="code"/>
<field name="city"/>
<field name="state_id"/>
<field name="country_id"/>
<group expand="0" string="Group By">
<filter string="State" domain="[]" context="{'group_by':'state_id'}"/>
<filter string="Country" domain="[]" context="{'group_by':'country_id'}"/>
</group>
</search>
</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"/>
<field name="search_view_id" ref="view_better_zip_filter"/>
</record>
<menuitem
name="Cities/Locations Management"
id="zip_base"
parent="base.menu_localisation"
action="action_zip_tree"
/>
</data>
</openerp>

19
base_location/views/company.xml

@ -1,19 +0,0 @@
<?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"
options="{'create_name_field': 'city'}"
colspan="4"
placeholder="City completion" />
</field>
</field>
</record>
</data>
</openerp>

21
base_location/views/company_view.xml

@ -0,0 +1,21 @@
<?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"
options="{'create_name_field': 'city'}"
colspan="4"
placeholder="City completion" />
</field>
</field>
</record>
</data>
</openerp>

26
base_location/views/partner.xml

@ -1,26 +0,0 @@
<?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">
<div class="address_format" position="before">
<field name="zip_id"
options="{'create_name_field': 'city'}"
placeholder="City completion"
attrs="{'invisible': [('use_parent_address','=',True)]}"
class="oe_edit_only" />
</div>
<xpath expr="//field[@name='child_ids']/form//div[@class='address_format']" position="before">
<field name="zip_id" options="{'create_name_field': 'city'}"
placeholder="City completion"
attrs="{'invisible': [('use_parent_address','=',True)]}"
class="oe_edit_only" />
</xpath>
</field>
</record>
</data>
</openerp>

27
base_location/views/partner_view.xml

@ -0,0 +1,27 @@
<?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">
<div class="address_format" position="before">
<field name="zip_id"
options="{'create_name_field': 'city'}"
placeholder="City completion"
attrs="{'invisible': [('use_parent_address','=',True)]}"
class="oe_edit_only" />
</div>
<xpath expr="//field[@name='child_ids']/form//div[@class='address_format']" position="before">
<field name="zip_id" options="{'create_name_field': 'city'}"
placeholder="City completion"
attrs="{'invisible': [('use_parent_address','=',True)]}"
class="oe_edit_only" />
</xpath>
</field>
</record>
</data>
</openerp>

17
base_location/views/res_country.xml

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_country_search" model="ir.ui.view">
<field name="name">res.country.search</field>
<field name="model">res.country</field>
<field name="arch" type="xml">
<search string="Country">
<field name="name"/>
<field name="code"/>
</search>
</field>
</record>
</data>
</openerp>

17
base_location/views/res_country_view.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_country_search" model="ir.ui.view">
<field name="name">res.country.search</field>
<field name="model">res.country</field>
<field name="arch" type="xml">
<search string="Country">
<field name="name"/>
<field name="code"/>
</search>
</field>
</record>
</data>
</openerp>

26
base_location/views/state.xml

@ -1,26 +0,0 @@
<?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>

26
base_location/views/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