mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[ADD] Add test for account banking payment blocking
This commit is contained in:
committed by
Adrien Peiffer (ACSONE)
parent
9e76faa478
commit
6a78c9d72d
@@ -21,3 +21,4 @@
|
||||
##############################################################################
|
||||
|
||||
import model
|
||||
import tests
|
||||
|
||||
34
account_banking_payment_blocking/tests/__init__.py
Normal file
34
account_banking_payment_blocking/tests/__init__.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
#
|
||||
# Authors: Adrien Peiffer
|
||||
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
|
||||
# All Rights Reserved
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsibility of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs.
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# guarantees and support are strongly advised to contact a Free Software
|
||||
# Service Company.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
from . import test_account_banking_payment_blocking
|
||||
|
||||
checks = [
|
||||
test_account_banking_payment_blocking,
|
||||
]
|
||||
@@ -0,0 +1,88 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
#
|
||||
# Authors: Adrien Peiffer
|
||||
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
|
||||
# All Rights Reserved
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsibility of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs.
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# guarantees and support are strongly advised to contact a Free Software
|
||||
# Service Company.
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
import openerp.tests.common as common
|
||||
from openerp import netsvc
|
||||
|
||||
DB = common.DB
|
||||
ADMIN_USER_ID = common.ADMIN_USER_ID
|
||||
|
||||
|
||||
def create_simple_invoice(self, cr, uid, context=None):
|
||||
partner_id = self.ref('base.res_partner_2')
|
||||
product_id = self.ref('product.product_product_4')
|
||||
return self.registry('account.invoice')\
|
||||
.create(cr, uid, {'partner_id': partner_id,
|
||||
'account_id':
|
||||
self.ref('account.a_recv'),
|
||||
'journal_id':
|
||||
self.ref('account.expenses_journal'),
|
||||
'invoice_line': [(0, 0, {'name': 'test',
|
||||
'account_id':
|
||||
self.ref('account.a_sale'),
|
||||
'price_unit': 2000.00,
|
||||
'quantity': 1,
|
||||
'product_id': product_id,
|
||||
}
|
||||
)
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
class TestAccountBankingPaymentBlocking(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountBankingPaymentBlocking, self).setUp()
|
||||
self.context = self.registry("res.users").context_get(self.cr,
|
||||
self.uid)
|
||||
|
||||
def test_invoice(self):
|
||||
invoice_obj = self.registry('account.invoice')
|
||||
move_line_obj = self.registry('account.move.line')
|
||||
invoice_id = create_simple_invoice(self, self.cr, self.uid,
|
||||
context=self.context)
|
||||
netsvc.LocalService("workflow")\
|
||||
.trg_validate(self.uid, 'account.invoice', invoice_id,
|
||||
'invoice_open', self.cr)
|
||||
invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id],
|
||||
context=self.context)[0]
|
||||
move_line_ids = move_line_obj\
|
||||
.search(self.cr, self.uid, [('account_id.type', 'in',
|
||||
['payable', 'receivable']),
|
||||
('invoice.id', '=', invoice.id)])
|
||||
move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0]
|
||||
self.assertEqual(invoice.move_blocked, move_line.blocked,
|
||||
'Blocked values are not equals')
|
||||
move_line_obj.write(self.cr, self.uid, move_line_ids,
|
||||
{'blocked': True})
|
||||
invoice = invoice_obj.browse(self.cr, self.uid, [invoice_id],
|
||||
context=self.context)[0]
|
||||
move_line = move_line_obj.browse(self.cr, self.uid, move_line_ids)[0]
|
||||
self.assertEqual(invoice.move_blocked, move_line.blocked,
|
||||
'Blocked values are not equals')
|
||||
Reference in New Issue
Block a user