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.

48 lines
1.5 KiB

  1. import odoo.tests.common as common
  2. from odoo import exceptions
  3. class TestPosRequireCustomer(common.TransactionCase):
  4. def setUp(self):
  5. super(TestPosRequireCustomer, self).setUp()
  6. self.pos_config = self.env.ref('point_of_sale.pos_config_main').copy()
  7. def test_customer_not_required(self):
  8. self.pos_config.require_customer = 'no'
  9. # Now Create new session and create a
  10. # pos order in this session
  11. pos_session = self.env['pos.session'].create({
  12. 'user_id': 1,
  13. 'config_id': self.pos_config.id
  14. })
  15. # should not raise any exception
  16. self.env['pos.order'].create({
  17. 'session_id': pos_session.id,
  18. 'partner_id': False,
  19. 'amount_tax': 0.0,
  20. 'amount_total': 0.0,
  21. 'amount_paid': 0.0,
  22. 'amount_return': 0.0
  23. })
  24. def test_customer_is_required(self):
  25. self.pos_config.require_customer = 'order'
  26. # Now Create new session and create a
  27. # pos order in this session
  28. pos_session = self.env['pos.session'].create({
  29. 'user_id': 1,
  30. 'config_id': self.pos_config.id
  31. })
  32. # should raise exceptions.ValidationError
  33. with self.assertRaises(exceptions.ValidationError):
  34. self.env['pos.order'].create({
  35. 'session_id': pos_session.id,
  36. 'partner_id': False,
  37. 'amount_tax': 0.0,
  38. 'amount_total': 0.0,
  39. 'amount_paid': 0.0,
  40. 'amount_return': 0.0
  41. })