You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

9 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests.common import TransactionCase
  5. from ..hooks import post_init_hook
  6. class TestContractPaymentInit(TransactionCase):
  7. # Use case : Prepare some data for current test case
  8. def setUp(self):
  9. super(TestContractPaymentInit, self).setUp()
  10. self.payment_mode = self.env.ref('account_payment.payment_mode_1')
  11. self.partner = self.env['res.partner'].create({
  12. 'name': 'Test contract partner',
  13. 'customer_payment_mode': self.payment_mode.id,
  14. })
  15. def _contract_payment_mode_id(self, contract_id):
  16. contract = self.env['account.analytic.account'].search([
  17. ('id', '=', contract_id),
  18. ])
  19. return contract.payment_mode_id.id
  20. def test_post_init_hook(self):
  21. contract = self.env['account.analytic.account'].create({
  22. 'name': 'Test contract',
  23. 'type': 'contract',
  24. 'partner_id': self.partner.id,
  25. 'payment_mode_id': self.payment_mode.id,
  26. })
  27. self.assertEqual(self._contract_payment_mode_id(contract.id),
  28. self.payment_mode.id)
  29. contract.payment_mode_id = False
  30. self.assertEqual(self._contract_payment_mode_id(contract.id), False)
  31. post_init_hook(self.cr, self.env)
  32. self.assertEqual(self._contract_payment_mode_id(contract.id),
  33. self.payment_mode.id)