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.

54 lines
2.0 KiB

  1. # © 2015 ACSONE SA/NV (<http://acsone.eu>)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo.tests import common
  4. class TestPosCashMoveReason(common.TransactionCase):
  5. def setUp(self):
  6. super(TestPosCashMoveReason, self).setUp()
  7. self.PosSession = self.env['pos.session']
  8. self.WizardReason = self.env['wizard.pos.move.reason']
  9. self.AccountMoveLine = self.env['account.move.line']
  10. self.config = self.env.ref('point_of_sale.pos_config_main').copy()
  11. self.cash_journal = self.env['account.journal'].search([
  12. ('type', '=', 'cash'),
  13. ('company_id', '=', self.env.ref('base.main_company').id),
  14. ])[0]
  15. self.deposit_reason = self.env.ref(
  16. 'pos_cash_move_reason.bank_out_reason')
  17. def test_take_money(self):
  18. # Open New Session
  19. self.config.open_session_cb()
  20. session = self.PosSession.search([
  21. ('state', '=', 'opened'),
  22. ('config_id', '=', self.config.id),
  23. ])
  24. # Get Cash Statement
  25. statement = session.statement_ids.filtered(
  26. lambda x: x.journal_id == self.cash_journal)
  27. # Take money to put in Bank
  28. wizard = self.WizardReason.with_context(
  29. active_id=session.id,
  30. default_move_type='expense').create({
  31. 'move_reason_id': self.deposit_reason.id,
  32. 'journal_id': self.cash_journal.id,
  33. 'statement_id': statement.id,
  34. 'amount': 500,
  35. 'name': 'Test Bank Deposit',
  36. })
  37. wizard.apply()
  38. session.action_pos_session_closing_control()
  39. # I get all move lines of this statement
  40. move_line = self.env['account.move.line'].search(
  41. [('account_id', '=', self.deposit_reason.expense_account_id.id),
  42. ('debit', '=', 500.0),
  43. ('id', 'in', statement.move_line_ids.ids)])
  44. # I check the created move line from the cash in
  45. self.assertEquals(len(move_line.ids), 1)