From 0239064400053c99e261530c931dfbbea4cef548 Mon Sep 17 00:00:00 2001 From: Alejandro Santana Date: Wed, 21 Jan 2015 14:20:36 +0100 Subject: [PATCH] [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. --- base_location/__openerp__.py | 15 ++--- base_location/models/better_zip.py | 3 +- base_location/models/company.py | 15 +++-- base_location/models/partner.py | 15 +++-- base_location/views/better_zip.xml | 71 ------------------------ base_location/views/better_zip_view.xml | 70 +++++++++++++++++++++++ base_location/views/company.xml | 19 ------- base_location/views/company_view.xml | 21 +++++++ base_location/views/partner.xml | 26 --------- base_location/views/partner_view.xml | 27 +++++++++ base_location/views/res_country.xml | 17 ------ base_location/views/res_country_view.xml | 17 ++++++ base_location/views/state.xml | 26 --------- base_location/views/state_view.xml | 26 +++++++++ 14 files changed, 181 insertions(+), 187 deletions(-) delete mode 100644 base_location/views/better_zip.xml create mode 100644 base_location/views/better_zip_view.xml delete mode 100644 base_location/views/company.xml create mode 100644 base_location/views/company_view.xml delete mode 100644 base_location/views/partner.xml create mode 100644 base_location/views/partner_view.xml delete mode 100644 base_location/views/res_country.xml create mode 100644 base_location/views/res_country_view.xml delete mode 100644 base_location/views/state.xml create mode 100644 base_location/views/state_view.xml diff --git a/base_location/__openerp__.py b/base_location/__openerp__.py index 1281ea1c3..d37507884 100644 --- a/base_location/__openerp__.py +++ b/base_location/__openerp__.py @@ -32,17 +32,12 @@ 'Alejandro Santana ', ], '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, diff --git a/base_location/models/better_zip.py b/base_location/models/better_zip.py index 412d1e8f7..3f86f8ed4 100644 --- a/base_location/models/better_zip.py +++ b/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") diff --git a/base_location/models/company.py b/base_location/models/company.py index 33e2b923a..6368761cf 100644 --- a/base_location/models/company.py +++ b/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', ) diff --git a/base_location/models/partner.py b/base_location/models/partner.py index 7bb0833d2..b0234d8a7 100644 --- a/base_location/models/partner.py +++ b/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 diff --git a/base_location/views/better_zip.xml b/base_location/views/better_zip.xml deleted file mode 100644 index 221bfb977..000000000 --- a/base_location/views/better_zip.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - res.better.zip.form - res.better.zip - -
- - - - - - - - -
-
-
- - - res.better.zip.tree - res.better.zip - - - - - - - - - - - - - - res.better.zip.select - res.better.zip - - - - - - - - - - - - - - - - - Cites/locations Management - res.better.zip - form - tree,form - - - - - -
-
diff --git a/base_location/views/better_zip_view.xml b/base_location/views/better_zip_view.xml new file mode 100644 index 000000000..d0e1782a7 --- /dev/null +++ b/base_location/views/better_zip_view.xml @@ -0,0 +1,70 @@ + + + + + + res.better.zip.form + res.better.zip + +
+ + + + + + + +
+
+
+ + + res.better.zip.tree + res.better.zip + + + + + + + + + + + + + res.better.zip.select + res.better.zip + + + + + + + + + + + + + + + + + Cites/locations Management + res.better.zip + form + tree,form + + + + + + +
+
diff --git a/base_location/views/company.xml b/base_location/views/company.xml deleted file mode 100644 index 32c955a05..000000000 --- a/base_location/views/company.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - res.company.form.city - res.company - - - - - - - - - diff --git a/base_location/views/company_view.xml b/base_location/views/company_view.xml new file mode 100644 index 000000000..e723db3a7 --- /dev/null +++ b/base_location/views/company_view.xml @@ -0,0 +1,21 @@ + + + + + + + res.company.form.city + res.company + + + + + + + + + + diff --git a/base_location/views/partner.xml b/base_location/views/partner.xml deleted file mode 100644 index 7e7b4cc0d..000000000 --- a/base_location/views/partner.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - res.partner.zip_id.2 - res.partner - - -
- -
- - - -
-
- -
-
diff --git a/base_location/views/partner_view.xml b/base_location/views/partner_view.xml new file mode 100644 index 000000000..517a179e9 --- /dev/null +++ b/base_location/views/partner_view.xml @@ -0,0 +1,27 @@ + + + + + + res.partner.zip_id.2 + res.partner + + +
+ +
+ + + +
+
+ +
+
diff --git a/base_location/views/res_country.xml b/base_location/views/res_country.xml deleted file mode 100644 index a2ed80258..000000000 --- a/base_location/views/res_country.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - res.country.search - res.country - - - - - - - - - - diff --git a/base_location/views/res_country_view.xml b/base_location/views/res_country_view.xml new file mode 100644 index 000000000..7e1deaa09 --- /dev/null +++ b/base_location/views/res_country_view.xml @@ -0,0 +1,17 @@ + + + + + + res.country.search + res.country + + + + + + + + + + diff --git a/base_location/views/state.xml b/base_location/views/state.xml deleted file mode 100644 index 96497c9e5..000000000 --- a/base_location/views/state.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - view_country_state_form2 - res.country.state - - - - - - - - - - - - - - - - diff --git a/base_location/views/state_view.xml b/base_location/views/state_view.xml new file mode 100644 index 000000000..38b550c97 --- /dev/null +++ b/base_location/views/state_view.xml @@ -0,0 +1,26 @@ + + + + + + view_country_state_form2 + res.country.state + + + + + + + + + + + + + + + +