| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
from odoo.addons.account.tests.common import AccountTestInvoicingCommon |
| 4 |
from odoo.tests.common import tagged |
| 5 |
from odoo import Command |
| 6 |
|
| 7 |
|
| 8 |
@tagged('post_install_l10n', 'post_install', '-at_install') |
| 9 |
class L10nLatamCheckTest(AccountTestInvoicingCommon): |
| 10 |
|
| 11 |
@classmethod |
| 12 |
def setUpClass(cls): |
| 13 |
super().setUpClass() |
| 14 |
|
| 15 |
cls.chart_template = cls.company_data['company'].chart_template |
| 16 |
cls.company_data_3 = cls.setup_other_company(name='company_3_data', country_id=cls.env.ref('base.ar').id) |
| 17 |
|
| 18 |
cls.bank_journal = cls.company_data_3['default_journal_bank'] |
| 19 |
cls.bank_journal.outbound_payment_method_line_ids = [ |
| 20 |
Command.create({'payment_method_id': cls.env.ref('l10n_latam_check.account_payment_method_own_checks').id, 'name': 'Own Checks'}), |
| 21 |
Command.create({'payment_method_id': cls.env.ref('l10n_latam_check.account_payment_method_out_third_party_checks').id, 'name': 'Rejected Check'}), |
| 22 |
] |
| 23 |
# enable use electronic/deferred checks on bank journal |
| 24 |
third_party_checks_journals = cls.env['account.journal'].search([ |
| 25 |
('inbound_payment_method_line_ids.code', '=', 'in_third_party_checks'), |
| 26 |
('inbound_payment_method_line_ids.code', '=', 'new_third_party_checks'), |
| 27 |
('outbound_payment_method_line_ids.code', 'in', ('out_third_party_checks', 'return_third_party_checks')), |
| 28 |
]) |
| 29 |
cls.third_party_check_journal = third_party_checks_journals[0] |
| 30 |
cls.rejected_check_journal = third_party_checks_journals[1] |
| 31 |
|
| 32 |
cls.assertTrue(cls.third_party_check_journal, 'Third party check journal was not created so we can run the tests') |
| 33 |
cls.assertTrue(cls.rejected_check_journal, 'Rejected check journal was not created so we can run the tests') |
| 34 |
|
| 35 |
for company in third_party_checks_journals.grouped('company_id'): |
| 36 |
outstanding_account = cls.outbound_payment_method_line.payment_account_id.copy({'company_ids': [Command.set(company.ids)]}) |
| 37 |
cls.bank_journal.outbound_payment_method_line_ids.filtered(lambda m: m.company_id == company).payment_account_id = outstanding_account |