Skip to content

Commit

Permalink
[FIX] shopinvader_customer_price: Fix partner pricelist
Browse files Browse the repository at this point in the history
Keep default pricelist behavior if `cart_pricelist_partner_field_id`  has not been configured on this backend
  • Loading branch information
paradoxxxzero committed Sep 25, 2023
1 parent 24db291 commit b749f3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shopinvader_customer_price/models/shopinvader_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion shopinvader_customer_price/tests/test_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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)

0 comments on commit b749f3c

Please sign in to comment.