Files
bank-payment/account_payment_order/tests/test_payment_mode.py
2018-12-13 17:02:13 +01:00

66 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2017 Creu Blanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
from odoo.exceptions import ValidationError
class TestPaymentMode(TransactionCase):
def setUp(self):
super(TestPaymentMode, self).setUp()
# Company
self.company = self.env.ref('base.main_company')
self.journal_c1 = self.env['account.journal'].create({
'name': 'Journal 1',
'code': 'J1',
'type': 'bank',
'company_id': self.company.id,
})
self.account = self.env['account.account'].search([
('reconcile', '=', True),
('company_id', '=', self.company.id)
], limit=1)
self.manual_out = self.env.ref(
'account.account_payment_method_manual_out')
self.payment_mode_c1 = self.env['account.payment.mode'].create({
'name': 'Direct Debit of suppliers from Bank 1',
'bank_account_link': 'variable',
'payment_method_id': self.manual_out.id,
'company_id': self.company.id,
'fixed_journal_id': self.journal_c1.id,
'variable_journal_ids': [(6, 0, [self.journal_c1.id])]
})
def test_constrains(self):
with self.assertRaises(ValidationError):
self.payment_mode_c1.write({
'generate_move': True,
'offsetting_account': False
})
with self.assertRaises(ValidationError):
self.payment_mode_c1.write({
'generate_move': True,
'offsetting_account': 'bank_account',
'move_option': False
})
with self.assertRaises(ValidationError):
self.payment_mode_c1.write({
'generate_move': True,
'offsetting_account': 'transfer_account',
'transfer_account_id': False
})
with self.assertRaises(ValidationError):
self.payment_mode_c1.write({
'generate_move': True,
'offsetting_account': 'transfer_account',
'transfer_account_id': self.account.id,
'transfer_journal_id': False
})