From dc876eeeabd9eb34471c18765f6903942ec08869 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 14 Dec 2020 19:37:55 +0100 Subject: [PATCH] Black, isort and other pre-commit stuff --- partner_address_street3/__manifest__.py | 26 ++++----- partner_address_street3/models/res_country.py | 3 +- partner_address_street3/models/res_partner.py | 9 +-- .../tests/test_street_3.py | 41 +++++++------- partner_address_street3/views/res_partner.xml | 56 ++++++++++++------- 5 files changed, 77 insertions(+), 58 deletions(-) diff --git a/partner_address_street3/__manifest__.py b/partner_address_street3/__manifest__.py index 158c5f9d2..8c65bd2fd 100644 --- a/partner_address_street3/__manifest__.py +++ b/partner_address_street3/__manifest__.py @@ -3,17 +3,17 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Street3 in addresses', - 'summary': 'Add a third address line on partners', - 'license': 'AGPL-3', - 'version': '14.0.1.0.0', - 'author': "Camptocamp,Odoo Community Association (OCA)", - 'maintainer': 'Camptocamp', - 'category': 'Sales', - 'depends': ['base_view_inheritance_extension'], - 'website': 'https://github.com/OCA/partner-contact', - 'data': ['views/res_partner.xml'], - 'post_init_hook': 'post_init_hook', - 'uninstall_hook': 'uninstall_hook', - 'installable': True, + "name": "Street3 in addresses", + "summary": "Add a third address line on partners", + "license": "AGPL-3", + "version": "14.0.1.0.0", + "author": "Camptocamp,Odoo Community Association (OCA)", + "maintainer": "Camptocamp", + "category": "Sales", + "depends": ["base_view_inheritance_extension"], + "website": "https://github.com/OCA/partner-contact", + "data": ["views/res_partner.xml"], + "post_init_hook": "post_init_hook", + "uninstall_hook": "uninstall_hook", + "installable": True, } diff --git a/partner_address_street3/models/res_country.py b/partner_address_street3/models/res_country.py index a0b787932..d4e289fbb 100644 --- a/partner_address_street3/models/res_country.py +++ b/partner_address_street3/models/res_country.py @@ -7,7 +7,8 @@ from odoo import fields, models class ResCountry(models.Model): """Override default adresses formatting of countries""" - _inherit = 'res.country' + + _inherit = "res.country" address_format = fields.Text( default=( diff --git a/partner_address_street3/models/res_partner.py b/partner_address_street3/models/res_partner.py index d3cd747b2..1b3a2f33d 100644 --- a/partner_address_street3/models/res_partner.py +++ b/partner_address_street3/models/res_partner.py @@ -7,19 +7,20 @@ from odoo import api, fields, models class ResPartner(models.Model): """Add third field in address""" + _inherit = "res.partner" - street3 = fields.Char('Street 3') + street3 = fields.Char("Street 3") @api.model def _address_fields(self): res = super()._address_fields() - res.append('street3') + res.append("street3") return res def _display_address(self, without_company=False): """Remove empty lines which can happen when street3 field is empty.""" res = super()._display_address(without_company=without_company) - while '\n\n' in res: - res = res.replace('\n\n', '\n') + while "\n\n" in res: + res = res.replace("\n\n", "\n") return res diff --git a/partner_address_street3/tests/test_street_3.py b/partner_address_street3/tests/test_street_3.py index 2e1355a8f..308ca5b10 100644 --- a/partner_address_street3/tests/test_street_3.py +++ b/partner_address_street3/tests/test_street_3.py @@ -8,29 +8,32 @@ from odoo.tests.common import TransactionCase class TestStreet3(TransactionCase): - def test_partner(self): # Test address_format has been updated on existing countries - us_country = self.env.ref('base.us') - self.assertTrue('%(street3)s' in us_country.address_format) + us_country = self.env.ref("base.us") + self.assertTrue("%(street3)s" in us_country.address_format) - homer = self.env['res.partner'].create({ - 'name': 'Homer Simpson', - 'city': 'Springfield', - 'street': '742 Evergreen Terrace', - 'street2': 'Donut Lane', - 'street3': 'Tho', - 'country_id': us_country.id, - }) + homer = self.env["res.partner"].create( + { + "name": "Homer Simpson", + "city": "Springfield", + "street": "742 Evergreen Terrace", + "street2": "Donut Lane", + "street3": "Tho", + "country_id": us_country.id, + } + ) # test synchro of street3 on create - bart = self.env['res.partner'].create({ - 'name': 'Bart Simpson', - 'parent_id': homer.id, - 'type': 'contact', - }) - self.assertEqual(bart.street3, 'Tho') + bart = self.env["res.partner"].create( + { + "name": "Bart Simpson", + "parent_id": homer.id, + "type": "contact", + } + ) + self.assertEqual(bart.street3, "Tho") # test synchro of street3 on write - homer.write({'street3': 'in OCA we trust'}) - self.assertEqual(bart.street3, 'in OCA we trust') + homer.write({"street3": "in OCA we trust"}) + self.assertEqual(bart.street3, "in OCA we trust") diff --git a/partner_address_street3/views/res_partner.xml b/partner_address_street3/views/res_partner.xml index ca7729989..6b4066872 100644 --- a/partner_address_street3/views/res_partner.xml +++ b/partner_address_street3/views/res_partner.xml @@ -3,27 +3,37 @@ add street3 in form view res.partner - + - + expr="/form/sheet/group/group/div/field[@name='street2']" + position="after" + > + - street3 + street3 - - + + - - + + @@ -31,10 +41,10 @@ add street 3 in kanban res.partner - + - + @@ -42,10 +52,10 @@ add street 3 in res.partner.form.address res.partner - + - + @@ -53,10 +63,14 @@ add street 3 in res.partner.form.private res.partner - + - +