test_pos.py 1.27 KB
Newer Older
François C. committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
# -*- coding: utf-8 -*-

import openerp.tests.common as common
from openerp import exceptions


class TestPosRequireCustomer(common.TransactionCase):
    def setUp(self):
        super(TestPosRequireCustomer, self).setUp()

    def test_customer_not_required(self):
        posconfig = self.env.ref('point_of_sale.pos_config_main')
        posconfig.require_customer = 'no'

        # Now Create new session and create a
        # pos order in this session
        pos_session = self.env['pos.session'].create(
            {'config_id': posconfig.id})
        # should not raise any exception
        self.env['pos.order'].create({
            'session_id': pos_session.id,
            'partner_id': False,
        })

    def test_customer_is_required(self):
        posconfig = self.env.ref('point_of_sale.pos_config_main')
        posconfig.require_customer = 'order'

        # Now Create new session and create a
        # pos order in this session
        pos_session = self.env['pos.session'].create(
            {'config_id': posconfig.id})
        # should raise exceptions.ValidationError
        with self.assertRaises(exceptions.ValidationError):
            self.env['pos.order'].create({
                'session_id': pos_session.id,
                'partner_id': False,
            })