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.

38 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. import openerp.tests.common as common
  3. from openerp import exceptions
  4. class TestPosRequireCustomer(common.TransactionCase):
  5. def setUp(self):
  6. super(TestPosRequireCustomer, self).setUp()
  7. def test_customer_not_required(self):
  8. posconfig = self.env.ref('point_of_sale.pos_config_main')
  9. posconfig.require_customer = 'no'
  10. # Now Create new session and create a
  11. # pos order in this session
  12. pos_session = self.env['pos.session'].create(
  13. {'config_id': posconfig.id})
  14. # should not raise any exception
  15. self.env['pos.order'].create({
  16. 'session_id': pos_session.id,
  17. 'partner_id': False,
  18. })
  19. def test_customer_is_required(self):
  20. posconfig = self.env.ref('point_of_sale.pos_config_main')
  21. posconfig.require_customer = 'order'
  22. # Now Create new session and create a
  23. # pos order in this session
  24. pos_session = self.env['pos.session'].create(
  25. {'config_id': posconfig.id})
  26. # should raise exceptions.ValidationError
  27. with self.assertRaises(exceptions.ValidationError):
  28. self.env['pos.order'].create({
  29. 'session_id': pos_session.id,
  30. 'partner_id': False,
  31. })