summaryrefslogtreecommitdiff
path: root/addons/account_check_printing/tests
diff options
context:
space:
mode:
authorArthur Maniet <arthurmaniet@me.com>2015-06-29 11:54:58 +0200
committerArthur Maniet <arthurmaniet@me.com>2015-08-10 13:48:55 +0200
commit5ff410d01a9e4d3f52583edd8c58c307e5376a45 (patch)
tree1a8a71be997062a6559e2bd839717c3d72f25d49 /addons/account_check_printing/tests
parent2328fa655e3165d961de4083adf0903c3eb54173 (diff)
[REF] account check printing: base module is a hidden dependency
The account_check_writing module offers the structure for other modules to add check printing facilities (like l10n_us_check_printing), in and of itself it brings no functionality.
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_check_printing.py59
2 files changed, 60 insertions, 0 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..b56a0289950
--- /dev/null
+++ b/addons/account_check_printing/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_check_printing
diff --git a/addons/account_check_printing/tests/test_check_printing.py b/addons/account_check_printing/tests/test_check_printing.py
new file mode 100644
index 00000000000..36f969c53c7
--- /dev/null
+++ b/addons/account_check_printing/tests/test_check_printing.py
@@ -0,0 +1,59 @@
+from openerp.addons.account.tests.account_test_classes import AccountingTestCase
+import time
+
+class TestCheckPrinting(AccountingTestCase):
+
+ def setUp(self):
+ super(TestCheckWriting, self).setUp()
+ 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.partner_axelor = self.env.ref("base.res_partner_13")
+ self.product = self.env.ref("product.product_product_4")
+ self.payment_method_check = self.env.ref("account_check_printing.account_payment_method_check")
+
+ self.account_payable = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1)
+ self.account_expenses = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1)
+
+ self.bank = self.env['res.partner.bank'].create({'acc_number': '0123456789', 'bank_name': 'Test Bank', 'company_id': self.env.user.company_id.id})
+ self.bank_journal = self.bank.journal_id
+ self.bank_journal.check_manual_sequencing = True
+
+ def create_invoice(self, amount=100, is_refund=False):
+ invoice = self.invoice_model.create({
+ 'partner_id': self.partner_axelor.id,
+ 'reference_type': 'none',
+ 'name': is_refund and "Vendor Refund" or "Vendor Invoice",
+ 'type': is_refund and "in_refund" or "in_invoice",
+ 'account_id': self.account_payable.id,
+ 'date_invoice': time.strftime('%Y') + '-06-26',
+ })
+ self.invoice_line_model.create({
+ 'product_id': self.product.id,
+ 'quantity': 1,
+ 'price_unit': is_refund and amount/4 or amount,
+ 'invoice_id': invoice.id,
+ 'name': 'something',
+ 'account_id': self.account_expenses.id,
+ })
+ invoice.signal_workflow('invoice_open')
+ 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_payment()
+ return self.env['account.payment'].search([], order="id desc", limit=1)
+
+ def test_send_check(self):
+ # Create a payment and 'send' the check
+ payment = self.create_payment(self.create_invoice())
+ payment.print_checks()
+ self.assertEqual(payment.state, 'sent')