From 3a05a2e88425fd21a088ffa9988402f3b5fc146b Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Mon, 9 Feb 2015 16:59:24 +0100 Subject: [PATCH] [IMP] account_invoice_partner basic test --- account_invoice_partner/tests/__init__.py | 23 +++++++++ .../tests/test_account_invoice_partner.py | 50 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 account_invoice_partner/tests/__init__.py create mode 100644 account_invoice_partner/tests/test_account_invoice_partner.py diff --git a/account_invoice_partner/tests/__init__.py b/account_invoice_partner/tests/__init__.py new file mode 100644 index 00000000000..2177f4e1e8d --- /dev/null +++ b/account_invoice_partner/tests/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Invoice partner test module for OpenERP +# Copyright (C) 2015 ACSONE SA/NV (http://acsone.eu) +# @author Laurent Mignon +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import test_account_invoice_partner diff --git a/account_invoice_partner/tests/test_account_invoice_partner.py b/account_invoice_partner/tests/test_account_invoice_partner.py new file mode 100644 index 00000000000..5fb59595321 --- /dev/null +++ b/account_invoice_partner/tests/test_account_invoice_partner.py @@ -0,0 +1,50 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Invoice partner test module for OpenERP +# Copyright (C) 2015 ACSONE SA/NV (http://acsone.eu) +# @author Laurent Mignon +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import openerp.tests.common as common + + +class TestAccountInvoiceParner(common.TransactionCase): + + def setUp(self): + super(TestAccountInvoiceParner, self).setUp() + self.inv_model = self.env['account.invoice'] + self.partner_model = self.env['res.partner'] + self.partner_2 = self.ref('base.res_partner_2') + self.partner_address_3 = self.ref('base.res_partner_address_3') + + def test_0(self): + # partner_2 has no address defined for invoice + addr_ids = self.partner_model.search( + [('parent_id', '=', self.partner_2), + ('type', '=', 'invoice')]) + self.assertFalse(addr_ids) + res = self.inv_model.onchange_partner_id( + invoice_type='in_invoice', partner_id=self.partner_2) + self.assertFalse('partner_id' in res['value']) + + # declare partner_address3 as invoice address + self.partner_model.browse(self.partner_address_3).write( + {'type': 'invoice'}) + res = self.inv_model.onchange_partner_id( + invoice_type='in_invoice', partner_id=self.partner_2) + self.assertEqual(self.partner_address_3, res['value']['partner_id'])