diff --git a/partner_contact_address_default/__manifest__.py b/partner_contact_address_default/__manifest__.py index 20af23ce1..531c32f7f 100644 --- a/partner_contact_address_default/__manifest__.py +++ b/partner_contact_address_default/__manifest__.py @@ -2,20 +2,16 @@ # Copyright 2020 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { - 'name': 'Partner Contact address default', - 'summary': 'Set a default delivery and invoice address for contacts', - 'version': '12.0.1.0.0', - 'development_status': 'Beta', - 'category': 'Generic Modules/Base', - 'website': 'https://github.com/OCA/partner-contact', - 'author': 'Tecnativa, Odoo Community Association (OCA)', - 'license': 'AGPL-3', - 'application': False, - 'installable': True, - 'depends': [ - 'base', - ], - 'data': [ - 'views/res_partner_views.xml', - ], + "name": "Partner Contact address default", + "summary": "Set a default delivery and invoice address for contacts", + "version": "12.0.1.0.0", + "development_status": "Beta", + "category": "Generic Modules/Base", + "website": "https://github.com/OCA/partner-contact", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["base",], + "data": ["views/res_partner_views.xml",], } diff --git a/partner_contact_address_default/models/res_partner.py b/partner_contact_address_default/models/res_partner.py index e0aa5ec95..17f226ac0 100644 --- a/partner_contact_address_default/models/res_partner.py +++ b/partner_contact_address_default/models/res_partner.py @@ -5,26 +5,24 @@ from odoo import fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" partner_delivery_id = fields.Many2one( - comodel_name='res.partner', - string='Shipping address', + comodel_name="res.partner", string="Shipping address", ) partner_invoice_id = fields.Many2one( - comodel_name='res.partner', - string='Invoice address', + comodel_name="res.partner", string="Invoice address", ) def get_address_default_type(self): - return ['delivery', 'invoice'] + return ["delivery", "invoice"] def address_get(self, adr_pref=None): res = super().address_get(adr_pref) default_address_type_list = self.get_address_default_type() for partner in self: for addr_type in default_address_type_list: - default_address_id = partner['partner_{}_id'.format(addr_type)] + default_address_id = partner["partner_{}_id".format(addr_type)] if default_address_id: res[addr_type] = default_address_id return res diff --git a/partner_contact_address_default/tests/test_partner_contact_address_default.py b/partner_contact_address_default/tests/test_partner_contact_address_default.py index 633ead11e..d8f0f9d42 100644 --- a/partner_contact_address_default/tests/test_partner_contact_address_default.py +++ b/partner_contact_address_default/tests/test_partner_contact_address_default.py @@ -5,40 +5,37 @@ from odoo.tests import common class TestPartnerContactAddressDefault(common.TransactionCase): - def setUp(self): super().setUp() - self.Partner = self.env['res.partner'] - self.partner = self.Partner.create({ - 'name': 'Parent partner', - }) - self.partner_child_delivery1 = self.Partner.create({ - 'name': 'Child delivery 1', - 'type': 'delivery', - 'parent_id': self.partner.id, - }) - self.partner_child_delivery2 = self.Partner.create({ - 'name': 'Child delivery 2', - 'type': 'delivery', - 'parent_id': self.partner.id, - }) - self.partner_child_invoice = self.Partner.create({ - 'name': 'Child invoice', - 'type': 'invoice', - 'parent_id': self.partner.id, - }) + self.Partner = self.env["res.partner"] + self.partner = self.Partner.create({"name": "Parent partner",}) + self.partner_child_delivery1 = self.Partner.create( + { + "name": "Child delivery 1", + "type": "delivery", + "parent_id": self.partner.id, + } + ) + self.partner_child_delivery2 = self.Partner.create( + { + "name": "Child delivery 2", + "type": "delivery", + "parent_id": self.partner.id, + } + ) + self.partner_child_invoice = self.Partner.create( + {"name": "Child invoice", "type": "invoice", "parent_id": self.partner.id,} + ) def test_contact_address_default(self): self.partner.partner_delivery_id = self.partner self.partner.partner_invoice_id = self.partner res = self.partner.address_get() - self.assertEqual(res['delivery'], self.partner) - self.assertEqual(res['invoice'], self.partner) + self.assertEqual(res["delivery"], self.partner) + self.assertEqual(res["invoice"], self.partner) - self.partner_child_delivery2.partner_delivery_id =\ - self.partner_child_delivery2 - self.partner_child_delivery2.partner_invoice_id =\ - self.partner_child_delivery2 + self.partner_child_delivery2.partner_delivery_id = self.partner_child_delivery2 + self.partner_child_delivery2.partner_invoice_id = self.partner_child_delivery2 res = self.partner_child_delivery2.address_get() - self.assertEqual(res['delivery'], self.partner_child_delivery2) - self.assertEqual(res['invoice'], self.partner_child_delivery2) + self.assertEqual(res["delivery"], self.partner_child_delivery2) + self.assertEqual(res["invoice"], self.partner_child_delivery2) diff --git a/partner_contact_address_default/views/res_partner_views.xml b/partner_contact_address_default/views/res_partner_views.xml index 7247a9ca5..5330fdb07 100644 --- a/partner_contact_address_default/views/res_partner_views.xml +++ b/partner_contact_address_default/views/res_partner_views.xml @@ -1,40 +1,55 @@ - + - res.partner - + - + - + - + - +
-
You can force and delivery and invoice address for this contacts.
-
If you keep empty this fields the Odoo's behavior will be normal
+
You can force and delivery and invoice address for this contacts.
+
If you keep empty this fields the Odoo's behavior will be normal
- + - +
-