From e07efcdb8cc4e34cb71a0870b85389ec26cf1dfa Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Sat, 12 Oct 2019 11:47:30 +0200 Subject: [PATCH] pre-commit, black, isort --- base_location/__manifest__.py | 51 ++--- base_location/demo/res_city_zip.xml | 12 +- base_location/models/res_city.py | 17 +- base_location/models/res_city_zip.py | 22 +- base_location/models/res_company.py | 64 +++--- base_location/models/res_partner.py | 74 +++---- base_location/tests/test_base_location.py | 254 ++++++++++------------ base_location/views/res_city_view.xml | 39 ++-- base_location/views/res_city_zip_view.xml | 26 +-- base_location/views/res_company_view.xml | 22 +- base_location/views/res_country_view.xml | 17 +- base_location/views/res_partner_view.xml | 33 +-- 12 files changed, 299 insertions(+), 332 deletions(-) diff --git a/base_location/__manifest__.py b/base_location/__manifest__.py index 9f26154e6..98c6e6b9a 100644 --- a/base_location/__manifest__.py +++ b/base_location/__manifest__.py @@ -3,32 +3,29 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Location management (aka Better ZIP)', - 'version': '13.0.1.0.0', - 'depends': [ - 'base_address_city', - 'contacts', + "name": "Location management (aka Better ZIP)", + "version": "13.0.1.0.0", + "depends": ["base_address_city", "contacts"], + "author": ( + "Camptocamp," + "ACYSOS S.L.," + "Alejandro Santana," + "Tecnativa," + "AdaptiveCity," + "Odoo Community Association (OCA)" + ), + "license": "AGPL-3", + "summary": """Enhanced zip/npa management system""", + "website": "https://github.com/OCA/partner-contact", + "data": [ + "security/ir.model.access.csv", + "views/res_city_zip_view.xml", + "views/res_city_view.xml", + "views/res_country_view.xml", + "views/res_company_view.xml", + "views/res_partner_view.xml", ], - 'author': "Camptocamp," - "ACYSOS S.L.," - "Alejandro Santana," - "Tecnativa," - "AdaptiveCity," - "Odoo Community Association (OCA)", - 'license': "AGPL-3", - 'summary': '''Enhanced zip/npa management system''', - 'website': 'https://github.com/OCA/partner-contact', - 'data': [ - 'security/ir.model.access.csv', - 'views/res_city_zip_view.xml', - 'views/res_city_view.xml', - 'views/res_country_view.xml', - 'views/res_company_view.xml', - 'views/res_partner_view.xml', - ], - 'demo': [ - 'demo/res_city_zip.xml', - ], - 'installable': True, - 'auto_install': False, + "demo": ["demo/res_city_zip.xml"], + "installable": True, + "auto_install": False, } diff --git a/base_location/demo/res_city_zip.xml b/base_location/demo/res_city_zip.xml index e940e49f1..03f960184 100644 --- a/base_location/demo/res_city_zip.xml +++ b/base_location/demo/res_city_zip.xml @@ -1,13 +1,11 @@ - + - - Brussels - + Brussels + - - 1000 - + 1000 + diff --git a/base_location/models/res_city.py b/base_location/models/res_city.py index 629268b5d..34ac653c6 100644 --- a/base_location/models/res_city.py +++ b/base_location/models/res_city.py @@ -5,15 +5,16 @@ from odoo import fields, models class City(models.Model): - _inherit = 'res.city' + _inherit = "res.city" - zip_ids = fields.One2many('res.city.zip', 'city_id', - string="Zips in this city") + zip_ids = fields.One2many("res.city.zip", "city_id", string="Zips in this city") _sql_constraints = [ - ('name_state_country_uniq', - 'UNIQUE(name, state_id, country_id)', - 'You already have a city with that name in the same state.' - 'The city must have a unique name within ' - 'it\'s state and it\'s country'), + ( + "name_state_country_uniq", + "UNIQUE(name, state_id, country_id)", + "You already have a city with that name in the same state." + "The city must have a unique name within " + "it's state and it's country", + ) ] diff --git a/base_location/models/res_city_zip.py b/base_location/models/res_city_zip.py index a95fe4e74..34dcdfaf0 100644 --- a/base_location/models/res_city_zip.py +++ b/base_location/models/res_city_zip.py @@ -13,22 +13,22 @@ class ResCityZip(models.Model): _order = "name asc" _rec_name = "display_name" - name = fields.Char('ZIP', required=True) - city_id = fields.Many2one( - 'res.city', - 'City', - required=True, + name = fields.Char("ZIP", required=True) + city_id = fields.Many2one("res.city", "City", required=True) + display_name = fields.Char( + compute="_compute_new_display_name", store=True, index=True ) - display_name = fields.Char(compute='_compute_new_display_name', - store=True, index=True) _sql_constraints = [ - ('name_city_uniq', 'UNIQUE(name, city_id)', - 'You already have a zip with that code in the same city. ' - 'The zip code must be unique within it\'s city'), + ( + "name_city_uniq", + "UNIQUE(name, city_id)", + "You already have a zip with that code in the same city. " + "The zip code must be unique within it's city", + ) ] - @api.depends('name', 'city_id') + @api.depends("name", "city_id") def _compute_new_display_name(self): for rec in self: name = [rec.name, rec.city_id.name] diff --git a/base_location/models/res_company.py b/base_location/models/res_company.py index e398e1892..fedcafa72 100644 --- a/base_location/models/res_company.py +++ b/base_location/models/res_company.py @@ -2,11 +2,11 @@ # Copyright 2018 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api +from odoo import api, fields, models class ResCompany(models.Model): - _inherit = 'res.company' + _inherit = "res.company" # In order to keep the same logic used in Odoo, fields must be computed # and inversed, not related. This way we can ensure that it works @@ -21,59 +21,63 @@ class ResCompany(models.Model): # don't for all of them. Mixing both approaches produces inconsistencies. city_id = fields.Many2one( - 'res.city', - compute='_compute_address', - inverse='_inverse_city_id', - string="City ID" + "res.city", + compute="_compute_address", + inverse="_inverse_city_id", + string="City ID", ) zip_id = fields.Many2one( - 'res.city.zip', - string='ZIP Location', - compute='_compute_address', - inverse='_inverse_zip_id', - help='Use the city name or the zip code to search the location', + "res.city.zip", + string="ZIP Location", + compute="_compute_address", + inverse="_inverse_zip_id", + help="Use the city name or the zip code to search the location", ) country_enforce_cities = fields.Boolean( - related='partner_id.country_id.enforce_cities', + related="partner_id.country_id.enforce_cities" ) def _get_company_address_fields(self, partner): res = super()._get_company_address_fields(partner) - res['city_id'] = partner.city_id - res['zip_id'] = partner.zip_id + res["city_id"] = partner.city_id + res["zip_id"] = partner.zip_id return res def _inverse_city_id(self): for company in self: company.with_context( - skip_check_zip=True).partner_id.city_id = company.city_id + skip_check_zip=True + ).partner_id.city_id = company.city_id def _inverse_zip_id(self): for company in self: - company.with_context( - skip_check_zip=True).partner_id.zip_id = company.zip_id + company.with_context(skip_check_zip=True).partner_id.zip_id = company.zip_id def _inverse_state(self): - return super(ResCompany, self.with_context( - skip_check_zip=True))._inverse_state() + return super( + ResCompany, self.with_context(skip_check_zip=True) + )._inverse_state() def _inverse_country(self): - return super(ResCompany, self.with_context( - skip_check_zip=True))._inverse_country() + return super( + ResCompany, self.with_context(skip_check_zip=True) + )._inverse_country() - @api.onchange('zip_id') + @api.onchange("zip_id") def _onchange_zip_id(self): if self.zip_id: - self.update({ - 'zip': self.zip_id.name, - 'city_id': self.zip_id.city_id, - 'city': self.zip_id.city_id.name, - 'country_id': self.zip_id.city_id.country_id, - 'state_id': self.zip_id.city_id.state_id, - }) + self.update( + { + "zip": self.zip_id.name, + "city_id": self.zip_id.city_id, + "city": self.zip_id.city_id.name, + "country_id": self.zip_id.city_id.country_id, + "state_id": self.zip_id.city_id.state_id, + } + ) - @api.onchange('state_id') + @api.onchange("state_id") def _onchange_state_id(self): if self.state_id.country_id: self.country_id = self.state_id.country_id.id diff --git a/base_location/models/res_partner.py b/base_location/models/res_partner.py index e4d38b079..e62062dff 100644 --- a/base_location/models/res_partner.py +++ b/base_location/models/res_partner.py @@ -2,83 +2,77 @@ # Copyright 2018 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" - zip_id = fields.Many2one('res.city.zip', 'ZIP Location') + zip_id = fields.Many2one("res.city.zip", "ZIP Location") - @api.onchange('city_id') + @api.onchange("city_id") def _onchange_city_id(self): if not self.zip_id: super()._onchange_city_id() if self.zip_id and self.city_id != self.zip_id.city_id: - self.update({ - 'zip_id': False, - 'zip': False, - 'city': False, - }) + self.update({"zip_id": False, "zip": False, "city": False}) if self.city_id: - return { - 'domain': { - 'zip_id': [('city_id', '=', self.city_id.id)] - }, - } - return {'domain': {'zip_id': []}} + return {"domain": {"zip_id": [("city_id", "=", self.city_id.id)]}} + return {"domain": {"zip_id": []}} - @api.onchange('country_id') + @api.onchange("country_id") def _onchange_country_id(self): res = super()._onchange_country_id() if self.zip_id and self.zip_id.city_id.country_id != self.country_id: self.zip_id = False return res - @api.onchange('zip_id') + @api.onchange("zip_id") def _onchange_zip_id(self): if self.zip_id: vals = { - 'city_id': self.zip_id.city_id, - 'zip': self.zip_id.name, - 'city': self.zip_id.city_id.name, + "city_id": self.zip_id.city_id, + "zip": self.zip_id.name, + "city": self.zip_id.city_id.name, } if self.zip_id.city_id.country_id: - vals.update({'country_id': self.zip_id.city_id.country_id}) + vals.update({"country_id": self.zip_id.city_id.country_id}) if self.zip_id.city_id.state_id: - vals.update({'state_id': self.zip_id.city_id.state_id}) + vals.update({"state_id": self.zip_id.city_id.state_id}) self.update(vals) - @api.constrains('zip_id', 'country_id', 'city_id', 'state_id') + @api.constrains("zip_id", "country_id", "city_id", "state_id") def _check_zip(self): - if self.env.context.get('skip_check_zip'): + if self.env.context.get("skip_check_zip"): return for rec in self: if not rec.zip_id: continue if rec.zip_id.city_id.state_id != rec.state_id: - raise ValidationError(_( - "The state of the partner %s differs from that in " - "location %s") % (rec.name, rec.zip_id.name)) + raise ValidationError( + _("The state of the partner %s differs from that in " "location %s") + % (rec.name, rec.zip_id.name) + ) if rec.zip_id.city_id.country_id != rec.country_id: - raise ValidationError(_( - "The country of the partner %s differs from that in " - "location %s") % (rec.name, rec.zip_id.name)) + raise ValidationError( + _( + "The country of the partner %s differs from that in " + "location %s" + ) + % (rec.name, rec.zip_id.name) + ) if rec.zip_id.city_id != rec.city_id: - raise ValidationError(_( - "The city of partner %s differs from that in " - "location %s") % (rec.name, rec.zip_id.name)) + raise ValidationError( + _("The city of partner %s differs from that in " "location %s") + % (rec.name, rec.zip_id.name) + ) - @api.onchange('state_id') + @api.onchange("state_id") def _onchange_state_id(self): vals = {} if self.state_id.country_id: - vals.update({'country_id': self.state_id.country_id}) + vals.update({"country_id": self.state_id.country_id}) if self.zip_id and self.state_id != self.zip_id.city_id.state_id: - vals.update({ - 'zip_id': False, - 'zip': False, - 'city': False, - }) + vals.update({"zip_id": False, "zip": False, "city": False}) self.update(vals) diff --git a/base_location/tests/test_base_location.py b/base_location/tests/test_base_location.py index 60b19581e..b151ed63d 100644 --- a/base_location/tests/test_base_location.py +++ b/base_location/tests/test_base_location.py @@ -1,83 +1,72 @@ # Copyright 2015 Yannick Vaucher, Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import psycopg2 + from odoo.exceptions import ValidationError -from odoo.tests import tagged, common +from odoo.tests import common, tagged from odoo.tools.misc import mute_logger -import psycopg2 -@tagged('post_install', '-at_install') +@tagged("post_install", "-at_install") class TestBaseLocation(common.SavepointCase): - @classmethod def setUpClass(cls): super().setUpClass() - state_obj = cls.env['res.country.state'] - city_obj = cls.env['res.city'] - zip_obj = cls.env['res.city.zip'] - cls.partner_obj = cls.env['res.partner'] + state_obj = cls.env["res.country.state"] + city_obj = cls.env["res.city"] + zip_obj = cls.env["res.city.zip"] + cls.partner_obj = cls.env["res.partner"] cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) - cls.state_vd = state_obj.create({ - 'name': 'Vaud', - 'code': 'VD', - 'country_id': cls.env.ref('base.ch').id, - }) - cls.env.ref('base.es').write({ - 'enforce_cities': True - }) - cls.company = cls.env.ref('base.main_company') + cls.state_vd = state_obj.create( + {"name": "Vaud", "code": "VD", "country_id": cls.env.ref("base.ch").id} + ) + cls.env.ref("base.es").write({"enforce_cities": True}) + cls.company = cls.env.ref("base.main_company") - cls.state_bcn = state_obj.create({ - 'name': 'Barcelona', - 'code': '08', - 'country_id': cls.env.ref('base.es').id, - }) - cls.state_madrid = state_obj.create({ - 'name': 'Madrid', - 'code': '28', - 'country_id': cls.env.ref('base.es').id, - }) - cls.city_bcn = city_obj.create({ - 'name': 'Barcelona', - 'state_id': cls.state_bcn.id, - 'country_id': cls.env.ref('base.es').id, - }) - cls.city_madrid = city_obj.create({ - 'name': 'Madrid', - 'state_id': cls.state_madrid.id, - 'country_id': cls.env.ref('base.es').id, - }) - cls.city_lausanne = city_obj.create({ - 'name': 'Lausanne', - 'state_id': cls.state_vd.id, - 'country_id': cls.env.ref('base.ch').id, - }) - cls.lausanne = zip_obj.create({ - 'name': '666', - 'city_id': cls.city_lausanne.id, - }) - cls.barcelona = zip_obj.create({ - 'name': '444', - 'city_id': cls.city_bcn.id, - }) + cls.state_bcn = state_obj.create( + {"name": "Barcelona", "code": "08", "country_id": cls.env.ref("base.es").id} + ) + cls.state_madrid = state_obj.create( + {"name": "Madrid", "code": "28", "country_id": cls.env.ref("base.es").id} + ) + cls.city_bcn = city_obj.create( + { + "name": "Barcelona", + "state_id": cls.state_bcn.id, + "country_id": cls.env.ref("base.es").id, + } + ) + cls.city_madrid = city_obj.create( + { + "name": "Madrid", + "state_id": cls.state_madrid.id, + "country_id": cls.env.ref("base.es").id, + } + ) + cls.city_lausanne = city_obj.create( + { + "name": "Lausanne", + "state_id": cls.state_vd.id, + "country_id": cls.env.ref("base.ch").id, + } + ) + cls.lausanne = zip_obj.create({"name": "666", "city_id": cls.city_lausanne.id}) + cls.barcelona = zip_obj.create({"name": "444", "city_id": cls.city_bcn.id}) def test_onchange_partner_city_completion(self): """Test that partner data is filled accodingly""" - partner1 = self.partner_obj.new({ - 'name': 'Camptocamp', - }) + partner1 = self.partner_obj.new({"name": "Camptocamp"}) partner1.zip_id = self.barcelona partner1._onchange_zip_id() self.assertEqual(partner1.zip, self.barcelona.name) self.assertEqual(partner1.city, self.barcelona.city_id.name) self.assertEqual(partner1.state_id, self.barcelona.city_id.state_id) - self.assertEqual(partner1.country_id, - self.barcelona.city_id.country_id) + self.assertEqual(partner1.country_id, self.barcelona.city_id.country_id) def test_onchange_company_city_completion(self): """Test that company data is filled accodingly""" - company = self.env['res.company'].new({'name': 'Test'}) + company = self.env["res.company"].new({"name": "Test"}) company.zip_id = self.lausanne company._onchange_zip_id() self.assertEqual(company.zip, self.lausanne.name) @@ -88,27 +77,25 @@ class TestBaseLocation(common.SavepointCase): def test_company_address_fields(self): """Test if the partner address fields changes when changing the ones from the company""" - company = self.env['res.company'].create({ - 'name': 'Test', - }) + company = self.env["res.company"].create({"name": "Test"}) self.assertTrue(company.partner_id) - company.partner_id.write({ - 'zip_id': self.lausanne.id, - 'state_id': self.lausanne.city_id.state_id.id, - 'country_id': self.lausanne.city_id.country_id.id, - 'city_id': self.lausanne.city_id.id, - 'city': self.lausanne.city_id.name, - 'zip': self.lausanne.name, - }) + company.partner_id.write( + { + "zip_id": self.lausanne.id, + "state_id": self.lausanne.city_id.state_id.id, + "country_id": self.lausanne.city_id.country_id.id, + "city_id": self.lausanne.city_id.id, + "city": self.lausanne.city_id.name, + "zip": self.lausanne.name, + } + ) company._compute_address() self.assertEqual(company.zip_id, company.partner_id.zip_id) self.assertEqual(company.city_id, company.partner_id.city_id) def test_company_address_fields_inverse(self): """Test inverse fields from res.company""" - company = self.env['res.company'].create({ - 'name': 'Test', - }) + company = self.env["res.company"].create({"name": "Test"}) company.zip_id = self.barcelona.id company._inverse_city_id() company._inverse_zip_id() @@ -117,7 +104,7 @@ class TestBaseLocation(common.SavepointCase): def test_onchange_company_city_id_completion(self): """Test city auto-completion when changing zip in a company""" - company = self.env['res.company'].new({'name': 'Test'}) + company = self.env["res.company"].new({"name": "Test"}) company.zip_id = self.barcelona company._onchange_zip_id() self.assertEqual(company.city_id, self.barcelona.city_id) @@ -125,83 +112,77 @@ class TestBaseLocation(common.SavepointCase): def test_constrains_partner_01(self): """Test partner 1 constraints""" with self.assertRaises(ValidationError): - self.partner_obj.create({ - 'name': 'P1', - 'zip_id': self.barcelona.id, - }) + self.partner_obj.create({"name": "P1", "zip_id": self.barcelona.id}) def test_writing_company(self): self.company.zip_id = self.barcelona def test_constrains_partner_country(self): """Test partner country constraints""" - partner = self.partner_obj.create({ - 'name': 'P1', - 'zip_id': self.barcelona.id, - 'country_id': self.barcelona.city_id.country_id.id, - 'state_id': self.barcelona.city_id.state_id.id, - 'city_id': self.barcelona.city_id.id, - }) + partner = self.partner_obj.create( + { + "name": "P1", + "zip_id": self.barcelona.id, + "country_id": self.barcelona.city_id.country_id.id, + "state_id": self.barcelona.city_id.state_id.id, + "city_id": self.barcelona.city_id.id, + } + ) with self.assertRaises(ValidationError): - partner.country_id = self.ref('base.ch') + partner.country_id = self.ref("base.ch") def test_constrains_partner_state(self): """Test partner state constraints""" - partner = self.partner_obj.create({ - 'name': 'P1', - 'zip_id': self.barcelona.id, - 'country_id': self.barcelona.city_id.country_id.id, - 'state_id': self.barcelona.city_id.state_id.id, - 'city_id': self.barcelona.city_id.id, - }) + partner = self.partner_obj.create( + { + "name": "P1", + "zip_id": self.barcelona.id, + "country_id": self.barcelona.city_id.country_id.id, + "state_id": self.barcelona.city_id.state_id.id, + "city_id": self.barcelona.city_id.id, + } + ) with self.assertRaises(ValidationError): partner.state_id = self.state_vd.id def test_constrains_partner_city(self): """Test partner city constraints""" - partner = self.partner_obj.create({ - 'name': 'P1', - 'zip_id': self.barcelona.id, - 'country_id': self.barcelona.city_id.country_id.id, - 'state_id': self.barcelona.city_id.state_id.id, - 'city_id': self.barcelona.city_id.id, - }) + partner = self.partner_obj.create( + { + "name": "P1", + "zip_id": self.barcelona.id, + "country_id": self.barcelona.city_id.country_id.id, + "state_id": self.barcelona.city_id.state_id.id, + "city_id": self.barcelona.city_id.id, + } + ) with self.assertRaises(ValidationError): partner.city_id = self.city_lausanne def test_partner_onchange_country(self): """Test partner onchange country_id""" - partner = self.partner_obj.new({ - 'name': 'TEST', - 'zip_id': self.lausanne.id - }) - partner.country_id = self.env.ref('base.es') + partner = self.partner_obj.new({"name": "TEST", "zip_id": self.lausanne.id}) + partner.country_id = self.env.ref("base.es") partner._onchange_country_id() self.assertFalse(partner.zip_id) def test_partner_onchange_city(self): """Test partner onchange city_id""" - partner = self.partner_obj.new({ - 'name': 'TEST', - 'zip_id': self.lausanne.id - }) + partner = self.partner_obj.new({"name": "TEST", "zip_id": self.lausanne.id}) self.city_bcn.country_id.enforce_cities = False partner.city_id = self.city_bcn partner._onchange_city_id() self.assertFalse(partner.zip_id) partner.city_id = False res = partner._onchange_city_id() - self.assertFalse(res['domain']['zip_id']) + self.assertFalse(res["domain"]["zip_id"]) def test_partner_onchange_state(self): """Test partner onchange state_id""" - partner = self.partner_obj.new({ - 'name': 'TEST', - 'zip_id': self.lausanne.id - }) + partner = self.partner_obj.new({"name": "TEST", "zip_id": self.lausanne.id}) partner.state_id = self.state_bcn partner._onchange_state_id() self.assertFalse(partner.zip_id) @@ -211,64 +192,57 @@ class TestBaseLocation(common.SavepointCase): """Test company onchange state_id""" self.company.state_id = self.state_bcn self.company._onchange_state_id() - self.assertEqual(self.company.country_id, - self.company.state_id.country_id) + self.assertEqual(self.company.country_id, self.company.state_id.country_id) def test_display_name(self): """Test if the display_name is stored and computed properly""" self.assertEqual( self.lausanne.display_name, - '666, Lausanne, Vaud, ' + self.browse_ref( - 'base.ch' - ).name + "666, Lausanne, Vaud, " + self.browse_ref("base.ch").name, ) def test_name_search(self): """Test that zips can be searched through both the name of the city or the zip code""" - madrid_data = { - 'city_id': self.city_madrid.id, - 'name': '555', - } + madrid_data = {"city_id": self.city_madrid.id, "name": "555"} - madrid = self.env['res.city.zip'].create(madrid_data) + madrid = self.env["res.city.zip"].create(madrid_data) - found_recs = self.env['res.city.zip'].name_search(name='444') + found_recs = self.env["res.city.zip"].name_search(name="444") self.assertEqual(len(found_recs), 1) self.assertEqual(found_recs[0][0], self.barcelona.id) - found_recs = self.env['res.city.zip'].name_search(name='Barcelona') + found_recs = self.env["res.city.zip"].name_search(name="Barcelona") self.assertEqual(len(found_recs), 1) self.assertEqual(found_recs[0][0], self.barcelona.id) - found_recs = self.env['res.city.zip'].name_search(name='555') + found_recs = self.env["res.city.zip"].name_search(name="555") self.assertEqual(len(found_recs), 1) self.assertEqual(found_recs[0][0], madrid.id) - found_recs = self.env['res.city.zip'].name_search(name='Madrid') + found_recs = self.env["res.city.zip"].name_search(name="Madrid") self.assertEqual(len(found_recs), 1) self.assertEqual(found_recs[0][0], madrid.id) - found_recs = self.env['res.city.zip'].name_search(name='666') + found_recs = self.env["res.city.zip"].name_search(name="666") self.assertEqual(len(found_recs), 1) self.assertEqual(found_recs[0][0], self.lausanne.id) - found_recs = self.env['res.city.zip'].name_search(name='Lausanne') + found_recs = self.env["res.city.zip"].name_search(name="Lausanne") self.assertEqual(len(found_recs), 1) self.assertEqual(found_recs[0][0], self.lausanne.id) def test_zip_ql_constraints(self): """Test UNIQUE name within it's area for zips""" - with self.assertRaises( - psycopg2.IntegrityError), mute_logger('odoo.sql_db'): - self.env['res.city.zip'].create({ - 'name': '666', - 'city_id': self.city_lausanne.id, - }) + with self.assertRaises(psycopg2.IntegrityError), mute_logger("odoo.sql_db"): + self.env["res.city.zip"].create( + {"name": "666", "city_id": self.city_lausanne.id} + ) def test_city_sql_contraint(self): """Test UNIQUE name within it's area for cities""" - with self.assertRaises( - psycopg2.IntegrityError), mute_logger('odoo.sql_db'): - self.env['res.city'].create({ - 'name': 'Barcelona', - 'state_id': self.state_bcn.id, - 'country_id': self.ref('base.es'), - }) + with self.assertRaises(psycopg2.IntegrityError), mute_logger("odoo.sql_db"): + self.env["res.city"].create( + { + "name": "Barcelona", + "state_id": self.state_bcn.id, + "country_id": self.ref("base.es"), + } + ) diff --git a/base_location/views/res_city_view.xml b/base_location/views/res_city_view.xml index f138e1c09..3fc60a7df 100644 --- a/base_location/views/res_city_view.xml +++ b/base_location/views/res_city_view.xml @@ -1,62 +1,59 @@ - + - res.city - + - + 1 - + - res.city
- - - + + + - +
- Cities ir.actions.act_window res.city tree,form - + (0, 0, {'view_mode': 'form', 'view_id': ref('view_city_form')})]" + /> Display and manage the list of all cities that can be assigned to your partner records. Note that an option can be set on each country separately to enforce any address of it to have a city in this list. - -
diff --git a/base_location/views/res_city_zip_view.xml b/base_location/views/res_city_zip_view.xml index 92fbacc48..5d440543f 100644 --- a/base_location/views/res_city_zip_view.xml +++ b/base_location/views/res_city_zip_view.xml @@ -1,55 +1,49 @@ - + - res.city.zip.form res.city.zip
- - + +
- res.city.zip.tree res.city.zip - - + + - res.city.zip.select res.city.zip - - + + - Locations res.city.zip tree,form - - + + - - + />
diff --git a/base_location/views/res_company_view.xml b/base_location/views/res_company_view.xml index 905065c01..75b418469 100644 --- a/base_location/views/res_company_view.xml +++ b/base_location/views/res_company_view.xml @@ -1,6 +1,5 @@ - + - res.company.form.city @@ -8,20 +7,25 @@ - + placeholder="City completion" + /> - - + + - [('country_enforce_cities', '=', True)] + [('country_enforce_cities', '=', True)] - diff --git a/base_location/views/res_country_view.xml b/base_location/views/res_country_view.xml index 0292f52ab..7696ae742 100644 --- a/base_location/views/res_country_view.xml +++ b/base_location/views/res_country_view.xml @@ -1,31 +1,30 @@ - + - res.country.search res.country - - + + - res.country - + - - diff --git a/base_location/views/res_partner_view.xml b/base_location/views/res_partner_view.xml index e10fbd474..5609f7f1f 100644 --- a/base_location/views/res_partner_view.xml +++ b/base_location/views/res_partner_view.xml @@ -1,25 +1,30 @@ - + res.partner.zip_id.2 res.partner - + - + - - + + -