test: add context to product-create

This commit is contained in:
Frederik Jaeckel 2023-06-07 19:24:43 +02:00
parent 8f12741d76
commit ebb6d71be3
3 changed files with 55 additions and 42 deletions

View file

@ -80,9 +80,10 @@ class AssetTestCase(object):
Asset = Pool().get('investment.asset') Asset = Pool().get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset = self.prep_asset_item( asset = self.prep_asset_item(
company=company, company=company,
@ -111,9 +112,10 @@ class AssetTestCase(object):
Asset = Pool().get('investment.asset') Asset = Pool().get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset = self.prep_asset_item( asset = self.prep_asset_item(
company=company, company=company,
@ -141,12 +143,13 @@ class AssetTestCase(object):
Asset = Pool().get('investment.asset') Asset = Pool().get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product1 = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product1 = self.prep_asset_product(
description='some asset') name='Product 1',
product2 = self.prep_asset_product( description='some asset')
name='Product 2', product2 = self.prep_asset_product(
description='some asset') name='Product 2',
description='some asset')
asset1 = self.prep_asset_item( asset1 = self.prep_asset_item(
company=company, company=company,
@ -223,9 +226,10 @@ class AssetTestCase(object):
cursor = Transaction().connection.cursor() cursor = Transaction().connection.cursor()
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset1 = self.prep_asset_item( asset1 = self.prep_asset_item(
company=company, company=company,
@ -289,9 +293,10 @@ class AssetTestCase(object):
Asset = Pool().get('investment.asset') Asset = Pool().get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset1 = self.prep_asset_item( asset1 = self.prep_asset_item(
company=company, company=company,
@ -399,9 +404,10 @@ class AssetTestCase(object):
Asset = Pool().get('investment.asset') Asset = Pool().get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset1 = self.prep_asset_item( asset1 = self.prep_asset_item(
company=company, company=company,
@ -484,9 +490,10 @@ class AssetTestCase(object):
OnlineSource = pool.get('investment.source') OnlineSource = pool.get('investment.source')
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset = self.prep_asset_item( asset = self.prep_asset_item(
company=company, company=company,
@ -521,9 +528,10 @@ class AssetTestCase(object):
Asset = pool.get('investment.asset') Asset = pool.get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset = self.prep_asset_item( asset = self.prep_asset_item(
company=company, company=company,
@ -626,10 +634,11 @@ class AssetTestCase(object):
Asset = pool.get('investment.asset') Asset = pool.get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product1 = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product unit', unit='u') product1 = self.prep_asset_product(
product2 = self.prep_asset_product( name='Product unit', unit='u')
name='Product gram', unit='g') product2 = self.prep_asset_product(
name='Product gram', unit='g')
asset1 = self.prep_asset_item(company=company, product=product1) asset1 = self.prep_asset_item(company=company, product=product1)
asset2 = self.prep_asset_item(company=company, product=product2) asset2 = self.prep_asset_item(company=company, product=product2)
@ -733,11 +742,12 @@ class AssetTestCase(object):
""" check update of product on asset """ check update of product on asset
""" """
company = self.prep_asset_company() company = self.prep_asset_company()
product1 = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product unit', unit='u') product1 = self.prep_asset_product(
product2 = self.prep_asset_product( name='Product unit', unit='u')
name='Product gram', unit='g') product2 = self.prep_asset_product(
self.assertEqual(product2.default_uom.digits, 2) name='Product gram', unit='g')
self.assertEqual(product2.default_uom.digits, 2)
asset = self.prep_asset_item(company=company, product=product1) asset = self.prep_asset_item(company=company, product=product1)

View file

@ -4,6 +4,7 @@
# full copyright notices and license terms. # full copyright notices and license terms.
from trytond.tests.test_tryton import with_transaction from trytond.tests.test_tryton import with_transaction
from trytond.transaction import Transaction
from trytond.pool import Pool from trytond.pool import Pool
from decimal import Decimal from decimal import Decimal
from datetime import date from datetime import date
@ -19,9 +20,10 @@ class RateTestCase(object):
Asset = Pool().get('investment.asset') Asset = Pool().get('investment.asset')
company = self.prep_asset_company() company = self.prep_asset_company()
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
asset = self.prep_asset_item( asset = self.prep_asset_item(
company=company, company=company,

View file

@ -36,9 +36,10 @@ class SourceTestCase(object):
}]) }])
self.assertEqual(osource.rec_name, 'Source 1') self.assertEqual(osource.rec_name, 'Source 1')
product = self.prep_asset_product( with Transaction().set_context({'company': company.id}):
name='Product 1', product = self.prep_asset_product(
description='some asset') name='Product 1',
description='some asset')
Product.write(*[ Product.write(*[
[product], [product],