From e9c584cdd35ee04b064493695100ed27a96f1649 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 2 Nov 2018 14:34:24 +0100 Subject: [PATCH] [ADD] Unittest. --- partner_children_navigation/__init__.py | 1 + .../models/res_partner.py | 2 -- partner_children_navigation/tests/__init__.py | 1 + .../tests/test_res_partner.py | 33 +++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 partner_children_navigation/tests/__init__.py create mode 100644 partner_children_navigation/tests/test_res_partner.py diff --git a/partner_children_navigation/__init__.py b/partner_children_navigation/__init__.py index 0650744f6..0ee8b5073 100644 --- a/partner_children_navigation/__init__.py +++ b/partner_children_navigation/__init__.py @@ -1 +1,2 @@ from . import models +from . import tests diff --git a/partner_children_navigation/models/res_partner.py b/partner_children_navigation/models/res_partner.py index 9da02eac9..9e0c6e033 100644 --- a/partner_children_navigation/models/res_partner.py +++ b/partner_children_navigation/models/res_partner.py @@ -7,8 +7,6 @@ from odoo import api, fields, models class Partner(models.Model): _inherit = 'res.partner' - contact_origin = fields.Many2one('res.partner', string='Contact origin') - @api.multi def open_commercial_partner(self): """ diff --git a/partner_children_navigation/tests/__init__.py b/partner_children_navigation/tests/__init__.py new file mode 100644 index 000000000..d0f9b1de6 --- /dev/null +++ b/partner_children_navigation/tests/__init__.py @@ -0,0 +1 @@ +from . import test_res_partner \ No newline at end of file diff --git a/partner_children_navigation/tests/test_res_partner.py b/partner_children_navigation/tests/test_res_partner.py new file mode 100644 index 000000000..0e5f27a7f --- /dev/null +++ b/partner_children_navigation/tests/test_res_partner.py @@ -0,0 +1,33 @@ +# SDi +# Copyright 2018 David Juaneda - +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import TransactionCase + + +class TestResPartnerNav(TransactionCase): + + def setUp(self): + super(TestResPartnerNav, self).setUp() + + res_partner = self.env['res.partner'] + self.parent = res_partner.browse( + res_partner.name_create('IronShield')[0]) + + self.child = res_partner.create({ + 'name': 'Isen Hardearth', + 'street': 'Strongarm Avenue, 12', + 'parent_id': self.parent.id, + }) + + def test_open_commercial_partner(self): + """ This test case checks + - If the method redirects to the form view of the correct one + of an object of the 'res.partner' class. + """ + for child in self.parent.child_ids: + action = child.open_commercial_partner() + print("Child_id = {}".format(child.id)) + print("action.get('res_id') = {}".format(action.get('res_id'))) + self.assertEqual(child.id, action.get('res_id'), + 'The contact ID from the partner must be equal to' + ' the ID of the contact to be displayed.')