You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 Creu Blanca <https://creublanca.es/>
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  4. from odoo.tests import common
  5. class TestSessionPayInvoice(common.TransactionCase):
  6. def setUp(self):
  7. super(TestSessionPayInvoice, self).setUp()
  8. self.company = self.env.ref('base.main_company')
  9. partner = self.env.ref('base.partner_demo')
  10. self.invoice_out = self.env['account.invoice'].create({
  11. 'company_id': self.company.id,
  12. 'partner_id': partner.id,
  13. 'date_invoice': '2016-03-12',
  14. 'type': 'out_invoice',
  15. })
  16. account = self.env['account.account'].create({
  17. 'code': 'test_cash_pay_invoice',
  18. 'company_id': self.company.id,
  19. 'name': 'Test',
  20. 'user_type_id': self.env.ref(
  21. 'account.data_account_type_revenue').id
  22. })
  23. self.env['account.invoice.line'].create({
  24. 'product_id': self.env.ref('product.product_delivery_02').id,
  25. 'invoice_id': self.invoice_out.id,
  26. 'account_id': account.id,
  27. 'name': 'Producto de prueba',
  28. 'quantity': 1.0,
  29. 'price_unit': 100.0,
  30. })
  31. self.invoice_out._onchange_invoice_line_ids()
  32. self.invoice_out.action_invoice_open()
  33. self.invoice_out.number = '2999/99999'
  34. self.invoice_in = self.env['account.invoice'].create({
  35. 'partner_id': partner.id,
  36. 'company_id': self.company.id,
  37. 'type': 'in_invoice',
  38. 'date_invoice': '2016-03-12',
  39. })
  40. self.env['account.invoice.line'].create({
  41. 'product_id': self.env.ref('product.product_delivery_02').id,
  42. 'invoice_id': self.invoice_in.id,
  43. 'name': 'Producto de prueba',
  44. 'account_id': account.id,
  45. 'quantity': 1.0,
  46. 'price_unit': 100.0,
  47. })
  48. self.invoice_in._onchange_invoice_line_ids()
  49. self.invoice_in.action_invoice_open()
  50. self.invoice_in.number = '2999/99999'
  51. self.journal = self.env['account.journal'].search([
  52. ('company_id', '=', self.company.id),
  53. ('type', '=', 'cash')
  54. ], limit=1).ensure_one()
  55. def test_bank_statement(self):
  56. statement = self.env['account.bank.statement'].create({
  57. 'name': 'Statment',
  58. 'journal_id': self.journal.id
  59. })
  60. in_invoice = self.env['cash.invoice.in'].with_context(
  61. active_ids=statement.ids, active_model='account.bank.statement'
  62. ).create({
  63. 'invoice_id': self.invoice_in.id,
  64. 'amount': 100.0
  65. })
  66. in_invoice.run()
  67. out_invoice = self.env['cash.invoice.out'].with_context(
  68. active_ids=statement.ids, active_model='account.bank.statement'
  69. ).create({
  70. 'invoice_id': self.invoice_out.id,
  71. 'amount': 100.0
  72. })
  73. out_invoice.run()
  74. statement.balance_end_real = statement.balance_start
  75. statement.check_confirm_bank()
  76. self.assertEqual(self.invoice_out.residual, 0.)
  77. self.assertEqual(self.invoice_in.residual, 0.)