Reviewers: ,
Please review this at http://codereview.tryton.org/839002/ Affected files: M tests/test_product.py Index: tests/test_product.py =================================================================== --- a/tests/test_product.py +++ b/tests/test_product.py @@ -26,6 +26,8 @@ trytond.tests.test_tryton.install_module('product') self.uom = POOL.get('product.uom') self.uom_category = POOL.get('product.uom.category') + self.template = POOL.get('product.template') + self.product = POOL.get('product.product') def test0005views(self): ''' @@ -189,6 +191,42 @@ self.assertEqual(result, self.uom.compute_price(from_uom, price, to_uom)) + def test0060search(self): + with Transaction().start(DB_NAME, USER, context=CONTEXT): + kilogram, = self.uom.search([ + ('name', '=', 'Kilogram'), + ], limit=1) + millimeter, = self.uom.search([ + ('name', '=', 'Millimeter'), + ]) + pt1, pt2 = self.template.create([{ + 'name': 'P1', + 'type': 'goods', + 'list_price': Decimal(20), + 'cost_price': Decimal(10), + 'default_uom': kilogram.id, + 'products': [('create', [{ + 'code': '1', + }])] + }, { + 'name': 'P2', + 'type': 'goods', + 'list_price': Decimal(20), + 'cost_price': Decimal(10), + 'default_uom': millimeter.id, + 'products': [('create', [{ + 'code': '2', + }])] + }]) + p, = self.product.search([ + ('default_uom.name', '=', 'Kilogram'), + ]) + self.assertEqual(p, pt1.products[0]) + p, = self.product.search([ + ('default_uom.name', '=', 'Millimeter'), + ]) + self.assertEqual(p, pt2.products[0]) + def suite(): suite = trytond.tests.test_tryton.suite()
