diff --git a/shopinvader_customer_price/models/shopinvader_backend.py b/shopinvader_customer_price/models/shopinvader_backend.py index 143122e5f3..5ead944470 100644 --- a/shopinvader_customer_price/models/shopinvader_backend.py +++ b/shopinvader_customer_price/models/shopinvader_backend.py @@ -40,7 +40,7 @@ def _get_cart_pricelist(self, partner=None): def _get_partner_pricelist(self, partner): pricelist = super()._get_partner_pricelist(partner) - if pricelist is None: + if pricelist is None and self.cart_pricelist_partner_field_id: pricelist = partner.property_product_pricelist return pricelist diff --git a/shopinvader_customer_price/tests/test_cart.py b/shopinvader_customer_price/tests/test_cart.py index 17b177c3a4..b94ebb3a2f 100644 --- a/shopinvader_customer_price/tests/test_cart.py +++ b/shopinvader_customer_price/tests/test_cart.py @@ -11,6 +11,7 @@ class ConnectedItemCase(ItemCaseMixin, CommonCase): def setUpClass(cls): super().setUpClass() cls._setup_products() + cls.cart = cls.env.ref("shopinvader.sale_order_2") cls.partner = cls.env.ref("shopinvader.partner_1") cls.custom_pricelist = cls.env["product.pricelist"].create( {"name": "Test Pricelist"} @@ -26,11 +27,13 @@ def setUp(self): self.service = work.component(usage="cart") def test_default_pricelist(self): + self.cart.unlink() self.assertFalse(self.backend.cart_pricelist_partner_field_id) cart = self.service._get() - self.assertEqual(cart.pricelist_id, self.partner.property_product_pricelist) + self.assertEqual(cart.pricelist_id, self.backend.pricelist_id) def test_custom_pricelist(self): + self.cart.unlink() self.backend.cart_pricelist_partner_field_id = self.pricelist_field cart = self.service._get() self.assertEqual(cart.pricelist_id, self.custom_pricelist)