tests: add company to context
This commit is contained in:
parent
1047345ae8
commit
1f47dfe6b1
3 changed files with 2618 additions and 2593 deletions
2
mixin.py
2
mixin.py
|
@ -21,6 +21,8 @@ DEPENDSQ.extend(DEPENDS)
|
|||
class SecondUomMixin(object):
|
||||
""" two fields for second uom: quantity, rate
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
quantity_2nd_uom = fields.Numeric(
|
||||
string='Quantity Second UOM',
|
||||
digits=(16, Eval('quantity2nd_digits', 4)),
|
||||
|
|
|
@ -23,6 +23,7 @@ class CbInvTestCase(object):
|
|||
|
||||
types = self.prep_type()
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -38,7 +39,8 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.rec_name, 'Book 1 | 0.00 usd | Open | 0.0000 -')
|
||||
self.assertEqual(
|
||||
book.rec_name, 'Book 1 | 0.00 usd | Open | 0.0000 -')
|
||||
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(book.state_string, 'Open')
|
||||
|
@ -57,6 +59,7 @@ class CbInvTestCase(object):
|
|||
Asset = pool.get('investment.asset')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
type_cash = self.prep_type('Cash', 'C')
|
||||
category_in = self.prep_category(cattype='in')
|
||||
|
@ -89,8 +92,6 @@ class CbInvTestCase(object):
|
|||
'feature': 'asset',
|
||||
}])
|
||||
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
books = Book.create([{
|
||||
'name': 'L0-Euro-None',
|
||||
'btype': None,
|
||||
|
@ -231,6 +232,8 @@ class CbInvTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
Asset = pool.get('investment.asset')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -239,7 +242,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -328,8 +330,7 @@ class CbInvTestCase(object):
|
|||
|
||||
# check quantities at cashbook
|
||||
with Transaction().set_context({
|
||||
'qdate': date(2022, 5, 5),
|
||||
'company': company.id}):
|
||||
'qdate': date(2022, 5, 5)}):
|
||||
book2, = Book.browse([book])
|
||||
self.assertEqual(book.asset.rate, Decimal('2.8')) # usd
|
||||
self.assertEqual(book2.quantity, Decimal('1.453'))
|
||||
|
@ -339,8 +340,7 @@ class CbInvTestCase(object):
|
|||
self.assertEqual(book2.current_value_ref, Decimal('3.87'))
|
||||
|
||||
with Transaction().set_context({
|
||||
'qdate': date(2022, 5, 12),
|
||||
'company': company.id}):
|
||||
'qdate': date(2022, 5, 12)}):
|
||||
book2, = Book.browse([book])
|
||||
self.assertEqual(book2.quantity, Decimal('4.753'))
|
||||
self.assertEqual(book2.quantity_all, Decimal('4.753'))
|
||||
|
@ -359,6 +359,8 @@ class CbInvTestCase(object):
|
|||
ProdTempl = pool.get('product.template')
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -367,7 +369,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -440,8 +441,7 @@ class CbInvTestCase(object):
|
|||
|
||||
# check quantities at cashbook
|
||||
with Transaction().set_context({
|
||||
'qdate': date(2022, 5, 1),
|
||||
'company': company.id}):
|
||||
'qdate': date(2022, 5, 1)}):
|
||||
book2, = Book.browse([book])
|
||||
self.assertEqual(book.asset.rate, Decimal('1750.0')) # usd
|
||||
self.assertEqual(book2.quantity, Decimal('20.0'))
|
||||
|
@ -468,6 +468,8 @@ class CbInvTestCase(object):
|
|||
Uom = pool.get('product.uom')
|
||||
Currency = pool.get('currency.currency')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -476,7 +478,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -561,8 +562,7 @@ class CbInvTestCase(object):
|
|||
|
||||
# check quantities at cashbook
|
||||
with Transaction().set_context({
|
||||
'qdate': date(2022, 5, 1),
|
||||
'company': company.id}):
|
||||
'qdate': date(2022, 5, 1)}):
|
||||
book2, = Book.browse([book])
|
||||
self.assertEqual(book.asset.rate, Decimal('1750.0')) # usd
|
||||
self.assertEqual(book2.quantity, Decimal('20.0'))
|
||||
|
@ -585,6 +585,7 @@ class CbInvTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -613,6 +614,7 @@ class CbInvTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
category = self.prep_category(cattype='in')
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
type_cash = self.prep_type('Cash', 'C')
|
||||
|
@ -708,6 +710,7 @@ class CbInvTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -760,6 +763,8 @@ class CbInvTestCase(object):
|
|||
Book = pool.get('cashbook.book')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
|
@ -768,7 +773,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
|
||||
category_in = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
|
||||
asset = self.prep_asset_item(
|
||||
|
@ -830,6 +834,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_cash = self.prep_type()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
|
@ -840,7 +846,6 @@ class CbInvTestCase(object):
|
|||
|
||||
self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
|
||||
asset = self.prep_asset_item(
|
||||
|
@ -993,6 +998,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_cash = self.prep_type()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
|
@ -1002,7 +1009,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
|
||||
asset = self.prep_asset_item(
|
||||
|
@ -1082,6 +1088,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_cash = self.prep_type()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
|
@ -1092,7 +1100,6 @@ class CbInvTestCase(object):
|
|||
|
||||
self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
|
||||
asset = self.prep_asset_item(
|
||||
|
@ -1221,6 +1228,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
self.prep_type()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
|
@ -1231,7 +1240,6 @@ class CbInvTestCase(object):
|
|||
|
||||
self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
|
||||
asset = self.prep_asset_item(
|
||||
|
@ -1365,6 +1373,8 @@ class CbInvTestCase(object):
|
|||
ProdTempl = pool.get('product.template')
|
||||
Asset = pool.get('investment.asset')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
self.prep_type()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
|
@ -1375,7 +1385,6 @@ class CbInvTestCase(object):
|
|||
|
||||
self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
|
||||
asset1 = self.prep_asset_item(
|
||||
|
@ -1552,6 +1561,8 @@ class CbInvTestCase(object):
|
|||
ProdTempl = pool.get('product.template')
|
||||
Asset = pool.get('investment.asset')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
self.prep_type()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
|
@ -1562,7 +1573,6 @@ class CbInvTestCase(object):
|
|||
|
||||
self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
|
||||
asset1 = self.prep_asset_item(
|
||||
|
@ -1647,6 +1657,8 @@ class CbInvTestCase(object):
|
|||
Book = pool.get('cashbook.book')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -1655,7 +1667,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -1726,6 +1737,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -1734,7 +1747,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -1886,6 +1898,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -1894,7 +1908,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -2031,6 +2044,8 @@ class CbInvTestCase(object):
|
|||
ProdTempl = pool.get('product.template')
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -2039,7 +2054,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -2198,6 +2212,8 @@ class CbInvTestCase(object):
|
|||
ProdTempl = pool.get('product.template')
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -2206,7 +2222,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='in')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset1 = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -2327,6 +2342,8 @@ class CbInvTestCase(object):
|
|||
Book = pool.get('cashbook.book')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -2335,7 +2352,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='out')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -2402,6 +2418,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -2410,7 +2428,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='out')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -2545,6 +2562,8 @@ class CbInvTestCase(object):
|
|||
Line = pool.get('cashbook.line')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types_asset = self.prep_type()
|
||||
BType.write(*[
|
||||
[types_asset],
|
||||
|
@ -2558,7 +2577,6 @@ class CbInvTestCase(object):
|
|||
self.assertEqual(types_asset.rec_name, 'as - Asset')
|
||||
category = self.prep_category(cattype='out')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -2707,6 +2725,8 @@ class CbInvTestCase(object):
|
|||
ProdTempl = pool.get('product.template')
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -2715,7 +2735,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='out')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
|
@ -2874,6 +2893,8 @@ class CbInvTestCase(object):
|
|||
ProdTempl = pool.get('product.template')
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
types = self.prep_type()
|
||||
BType.write(*[
|
||||
[types],
|
||||
|
@ -2882,7 +2903,6 @@ class CbInvTestCase(object):
|
|||
}])
|
||||
category = self.prep_category(cattype='out')
|
||||
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
asset1 = self.prep_asset_item(
|
||||
company=company,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
from trytond.tests.test_tryton import with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -22,6 +23,7 @@ class ReconTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
|
@ -72,6 +74,7 @@ class ReconTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
|
|
Loading…
Reference in a new issue