summaryrefslogtreecommitdiff
path: root/addons/account_check_printing/tests
diff options
context:
space:
mode:
authorwan <wan@odoo.com>2019-02-20 14:51:34 +0000
committerwan <wan@odoo.com>2019-04-04 10:42:41 +0000
commit3c2e3b8c5a7d073fe8f0f6d781b1ccdbc320edd0 (patch)
treede7891241dfa92f9cfc03d25428e26aff80450c6 /addons/account_check_printing/tests
parent2190568d9e6fda200db6e28bf13e24fa5d3bc634 (diff)
[REF] account: simplification of payments objects
simplification of payments objects and refactoring of the code * registering payment(s) from the list of invoice now generate a single payment per invoice selected * no more abstract object for payments/payment wizard as the logic is now really simple: - group_invoices option is now removed and we never try to group payments based on the currency/customer of whatsoever (see above), - the payment amount is the full residual amount of invoice and users cannot change it anymore * partner_bank_account_id not required as soon as visible (depends on the payment method) * refactoring to name tags and allow easier inheritance via xpath part of task #1918423
Diffstat (limited to 'addons/account_check_printing/tests')
-rw-r--r--addons/account_check_printing/tests/__init__.py1
-rw-r--r--addons/account_check_printing/tests/test_print_check.py44
2 files changed, 30 insertions, 15 deletions
diff --git a/addons/account_check_printing/tests/__init__.py b/addons/account_check_printing/tests/__init__.py
new file mode 100644
index 00000000000..e7cb6f95910
--- /dev/null
+++ b/addons/account_check_printing/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_print_check
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')