diff options
Diffstat (limited to 'addons/account_check_printing/tests/test_print_check.py')
| -rw-r--r-- | addons/account_check_printing/tests/test_print_check.py | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/addons/account_check_printing/tests/test_print_check.py b/addons/account_check_printing/tests/test_print_check.py index 386ca39589c..8c41e2e6bd6 100644 --- a/addons/account_check_printing/tests/test_print_check.py +++ b/addons/account_check_printing/tests/test_print_check.py @@ -2,13 +2,14 @@ from __future__ import division from odoo.addons.account.tests.account_test_classes import AccountingTestCase -from odoo.addons.l10n_us_check_printing.report import print_check +from odoo.addons.account_check_printing.models.account_payment import INV_LINES_PER_STUB from odoo.tests import tagged +from odoo.tests.common import Form import time - import math + @tagged('post_install', '-at_install') class TestPrintCheck(AccountingTestCase): @@ -17,7 +18,7 @@ class TestPrintCheck(AccountingTestCase): self.invoice_model = self.env['account.invoice'] self.invoice_line_model = self.env['account.invoice.line'] - self.register_payments_model = self.env['account.register.payments'] + self.payment_model = self.env['account.payment'] self.partner_axelor = self.env.ref("base.res_partner_2") self.product = self.env.ref("product.product_product_4") @@ -49,28 +50,41 @@ class TestPrintCheck(AccountingTestCase): return invoice def create_payment(self, invoices): - register_payments = self.register_payments_model.with_context({ - 'active_model': 'account.invoice', - 'active_ids': invoices.ids - }).create({ - 'payment_date': time.strftime('%Y') + '-07-15', - 'journal_id': self.bank_journal.id, - 'payment_method_id': self.payment_method_check.id, - }) - register_payments.create_payments() - return self.env['account.payment'].search([], order="id desc", limit=1) + payment_register = Form(self.env['account.payment'].with_context(active_model='account.invoice', active_ids=invoices.ids)) + payment_register.payment_date = time.strftime('%Y') + '-07-15' + payment_register.journal_id = self.bank_journal + payment_register.payment_method_id = self.payment_method_check + payment = payment_register.save() + payment.post() + + return payment def test_print_check(self): # Make a payment for 10 invoices and 5 credit notes invoices = self.env['account.invoice'] - for i in range(0,15): + for i in range(0, 15): invoices |= self.create_invoice(is_refund=(i % 3 == 0)) payment = self.create_payment(invoices) + self.assertEqual(all(payment.mapped('check_amount_in_words')), True, 'The amount in words is not set on all the payments') + self.assertEqual(all(payment.mapped('check_number')), True, 'The check number is not set on all the payments') # Check the data generated for the report self.env.ref('base.main_company').write({'account_check_printing_multi_stub': True}) report_pages = payment._check_get_pages() - self.assertEqual(len(report_pages), int(math.ceil(len(invoices.ids) / print_check.INV_LINES_PER_STUB))) + self.assertEqual(len(report_pages), int(math.ceil(len(invoices.ids) / INV_LINES_PER_STUB))) self.env.ref('base.main_company').write({'account_check_printing_multi_stub': False}) report_pages = payment._check_get_pages() self.assertEqual(len(report_pages), 1) + + def test_from_register(self): + invoices = self.env['account.invoice'] + for i in range(0, 3): + invoices |= self.create_invoice(is_refund=(i % 3 == 0)) + payment_register = Form(self.env['account.payment.register'].with_context(active_model='account.invoice', active_ids=invoices.ids)) + payment_register.payment_date = time.strftime('%Y') + '-07-15' + payment_register.journal_id = self.bank_journal + payment_register.payment_method_id = self.payment_method_check + domain = payment_register.save().create_payments()['domain'] + payment = self.env['account.payment'].search(domain) + + self.assertEqual(all(payment.mapped('check_amount_in_words')), True, 'The amount in words is not set on all the payments') |
