LaOsaCoop/Odoo16#14 migration pos_customer_required

This commit is contained in:
Luis 2025-05-11 18:40:33 +02:00
parent b062c383d5
commit 08fca37c6d
27 changed files with 1438 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import test_pos_customer_required

View file

@ -0,0 +1,49 @@
import odoo.tests.common as common
from odoo import exceptions
class TestPosCustomerRequired(common.TransactionCase):
def setUp(self):
super().setUp()
self.pos_config = self.env.ref("point_of_sale.pos_config_main").copy()
def test_customer_not_required(self):
self.pos_config.require_customer = "no"
# Now Create new session and create a
# pos order in this session
pos_session = self.env["pos.session"].create(
{"user_id": 1, "config_id": self.pos_config.id}
)
# should not raise any exception
self.env["pos.order"].create(
{
"session_id": pos_session.id,
"partner_id": False,
"amount_tax": 0.0,
"amount_total": 0.0,
"amount_paid": 0.0,
"amount_return": 0.0,
}
)
def test_customer_is_required(self):
self.pos_config.require_customer = "order"
# Now Create new session and create a
# pos order in this session
pos_session = self.env["pos.session"].create(
{"user_id": 1, "config_id": self.pos_config.id}
)
# should raise exceptions.ValidationError
with self.assertRaises(exceptions.ValidationError):
self.env["pos.order"].create(
{
"session_id": pos_session.id,
"partner_id": False,
"amount_tax": 0.0,
"amount_total": 0.0,
"amount_paid": 0.0,
"amount_return": 0.0,
}
)