From c5946d6c5e3ca9114aeffba07f6e8c52d76cc538 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 11 Jun 2018 12:21:13 +0200 Subject: [PATCH] [IMP] product: add test To make sure the changes made at #24905 are tested --- addons/product/tests/__init__.py | 2 +- addons/product/tests/test_seller.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 addons/product/tests/test_seller.py diff --git a/addons/product/tests/__init__.py b/addons/product/tests/__init__.py index cb24f04241d..c07bca51701 100644 --- a/addons/product/tests/__init__.py +++ b/addons/product/tests/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import test_variants, test_uom, test_pricelist, test_product_pricelist +from . import test_seller, test_variants, test_uom, test_pricelist, test_product_pricelist diff --git a/addons/product/tests/test_seller.py b/addons/product/tests/test_seller.py new file mode 100644 index 00000000000..36693317c34 --- /dev/null +++ b/addons/product/tests/test_seller.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests.common import TransactionCase + + +class TestSeller(TransactionCase): + + def setUp(self): + super(TestSeller, self).setUp() + self.product_service = self.env.ref('product.product_product_2') + self.product_service.default_code = 'DEFCODE' + self.asustec = self.env.ref('base.res_partner_1') + self.camptocamp = self.env.ref('base.res_partner_12') + + def test_10_sellers(self): + self.product_service.write({'seller_ids': [ + (0, 0, {'name': self.asustec.id, 'product_code': 'ASUCODE'}), + (0, 0, {'name': self.camptocamp.id, 'product_code': 'C2CCODE'}), + ]}) + + default_code = self.product_service.code + self.assertEqual("DEFCODE", default_code, "Default code not used in product name") + + context_code = self.product_service\ + .with_context(partner_id=self.camptocamp.id)\ + .code + self.assertEqual('C2CCODE', context_code, "Partner's code not used in product name with context set")