mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
Adding test
This commit is contained in:
committed by
Pedro M. Baeza
parent
266051882b
commit
57a282ee04
@@ -13,7 +13,10 @@ def post_init_hook(cr, registry):
|
|||||||
with api.Environment.manage():
|
with api.Environment.manage():
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
m_contract = env['account.analytic.account']
|
m_contract = env['account.analytic.account']
|
||||||
contracts = m_contract.search([('type', '=', 'contract')])
|
contracts = m_contract.search([
|
||||||
|
('type', '=', 'contract'),
|
||||||
|
('payment_mode_id', '=', False),
|
||||||
|
])
|
||||||
if contracts:
|
if contracts:
|
||||||
_logger.info('Setting payment mode: %d contracts' %
|
_logger.info('Setting payment mode: %d contracts' %
|
||||||
len(contracts))
|
len(contracts))
|
||||||
|
|||||||
5
contract_payment_mode/tests/__init__.py
Normal file
5
contract_payment_mode/tests/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from . import test_contract_payment_init
|
||||||
40
contract_payment_mode/tests/test_contract_payment_init.py
Normal file
40
contract_payment_mode/tests/test_contract_payment_init.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from openerp.tests.common import TransactionCase
|
||||||
|
from ..hooks import post_init_hook
|
||||||
|
|
||||||
|
|
||||||
|
class TestContractPaymentInit(TransactionCase):
|
||||||
|
# Use case : Prepare some data for current test case
|
||||||
|
def setUp(self):
|
||||||
|
super(TestContractPaymentInit, self).setUp()
|
||||||
|
self.payment_mode = self.env.ref('account_payment.payment_mode_1')
|
||||||
|
self.partner = self.env['res.partner'].create({
|
||||||
|
'name': 'Test contract partner',
|
||||||
|
'customer_payment_mode': self.payment_mode.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
def _contract_payment_mode_id(self, contract_id):
|
||||||
|
contract = self.env['account.analytic.account'].search([
|
||||||
|
('id', '=', contract_id),
|
||||||
|
])
|
||||||
|
return contract.payment_mode_id.id
|
||||||
|
|
||||||
|
def test_post_init_hook(self):
|
||||||
|
contract = self.env['account.analytic.account'].create({
|
||||||
|
'name': 'Test contract',
|
||||||
|
'type': 'contract',
|
||||||
|
'partner_id': self.partner.id,
|
||||||
|
'payment_mode_id': self.payment_mode.id,
|
||||||
|
})
|
||||||
|
self.assertEqual(self._contract_payment_mode_id(contract.id),
|
||||||
|
self.payment_mode.id)
|
||||||
|
|
||||||
|
contract.payment_mode_id = False
|
||||||
|
self.assertEqual(self._contract_payment_mode_id(contract.id), False)
|
||||||
|
|
||||||
|
post_init_hook(self.cr, self.env)
|
||||||
|
self.assertEqual(self._contract_payment_mode_id(contract.id),
|
||||||
|
self.payment_mode.id)
|
||||||
Reference in New Issue
Block a user