From 0d630f72ad4b3c4b6daebc5056eaff48c3297f8e Mon Sep 17 00:00:00 2001 From: Mmequignon Date: Fri, 8 Dec 2023 18:26:14 +0100 Subject: [PATCH] product_supplierinfo_for_customer: Add supplier+customer test --- .../test_product_supplierinfo_for_customer.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/product_supplierinfo_for_customer/tests/test_product_supplierinfo_for_customer.py b/product_supplierinfo_for_customer/tests/test_product_supplierinfo_for_customer.py index 1f6665e334f..1cad5244ae0 100644 --- a/product_supplierinfo_for_customer/tests/test_product_supplierinfo_for_customer.py +++ b/product_supplierinfo_for_customer/tests/test_product_supplierinfo_for_customer.py @@ -57,6 +57,39 @@ def _create_partnerinfo(cls, supplierinfo_type, partner, product): } ) + def test_partner_customer_and_seller(self): + product = self.env["product.product"].create( + {"name": "Product Name", "default_code": "Product Code"} + ) + custseller = self.env["res.partner"].create({"name": "Custseller"}) + self.env["product.supplierinfo"].create( + { + "product_id": product.id, + "product_tmpl_id": product.product_tmpl_id.id, + "partner_id": custseller.id, + "product_code": "seller code", + "product_name": "seller name", + } + ) + self.env["product.customerinfo"].create( + { + "product_id": product.id, + "product_tmpl_id": product.product_tmpl_id.id, + "partner_id": custseller.id, + "product_code": "customer code", + "product_name": "customer name", + } + ) + self.assertEqual(product.display_name, "[Product Code] Product Name") + product.invalidate_cache(["display_name"]) + self.assertEqual( + product.with_context(partner_id=custseller.id).display_name, + "[seller code] seller name", + ) + product.invalidate_cache(["display_name"]) + product = product.with_context(partner_id=custseller.id, customerinfo=True) + self.assertEqual(product.display_name, "[customer code] customer name") + def test_default_get(self): """checking values returned by default_get()""" fields = ["name"]