|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +############################################################################## |
| 3 | +# For copyright and license notices, see __openerp__.py file in root directory |
| 4 | +############################################################################## |
| 5 | + |
| 6 | +from openerp.tests.common import TransactionCase |
| 7 | + |
| 8 | + |
| 9 | +class TestPartnerProspect(TransactionCase): |
| 10 | + |
| 11 | + def setUp(self): |
| 12 | + super(TestPartnerProspect, self).setUp() |
| 13 | + self.sale_order_model = self.env['sale.order'] |
| 14 | + self.partner_model = self.env['res.partner'] |
| 15 | + self.partner1 = self.partner_model.create({'name': 'Partner1'}) |
| 16 | + self.partner2 = self.partner_model.create({ |
| 17 | + 'name': 'Partner2', |
| 18 | + 'parent_id': self.partner1.id, |
| 19 | + }) |
| 20 | + self.partner3 = self.partner_model.create({ |
| 21 | + 'name': 'Partner3', |
| 22 | + 'parent_id': self.partner1.id, |
| 23 | + }) |
| 24 | + self.partner4 = self.partner_model.create({'name': 'Partner4'}) |
| 25 | + self.product = self.env.ref('product.product_product_4') |
| 26 | + self.sale_order1 = self.sale_order_model.create({ |
| 27 | + 'partner_id': self.partner1.id, |
| 28 | + 'order_policy': 'manual', |
| 29 | + 'order_line': [(0, 0, {'product_id': self.product.id, })], |
| 30 | + }) |
| 31 | + self.sale_order2 = self.sale_order_model.create({ |
| 32 | + 'partner_id': self.partner2.id, |
| 33 | + 'order_policy': 'manual', |
| 34 | + 'order_line': [(0, 0, {'product_id': self.product.id, })], |
| 35 | + }) |
| 36 | + self.sale_order3 = self.sale_order_model.create({ |
| 37 | + 'partner_id': self.partner4.id, |
| 38 | + 'order_policy': 'manual', |
| 39 | + 'order_line': [(0, 0, {'product_id': self.product.id, })], |
| 40 | + }) |
| 41 | + |
| 42 | + def test_partner_child_check(self): |
| 43 | + self.sale_order2.action_button_confirm() |
| 44 | + self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect') |
| 45 | + self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect') |
| 46 | + self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect') |
| 47 | + |
| 48 | + def test_partner_parent_check(self): |
| 49 | + self.sale_order1.action_button_confirm() |
| 50 | + self.assertFalse(self.partner1.prospect, 'Partner1 is a prospect') |
| 51 | + self.assertFalse(self.partner2.prospect, 'Partner2 is a prospect') |
| 52 | + self.assertFalse(self.partner3.prospect, 'Partner3 is a prospect') |
| 53 | + |
| 54 | + def test_partner_prospect(self): |
| 55 | + self.assertTrue(self.partner4.prospect, 'Partner4 is not a prospect') |
| 56 | + self.sale_order3.action_button_confirm() |
| 57 | + self.assertFalse(self.partner4.prospect, 'Partner4 is a prospect') |
| 58 | + self.sale_order3.action_cancel() |
| 59 | + self.assertTrue(self.partner4.prospect, 'Partner4 is not a prospect') |
0 commit comments