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)),
|
||||
|
|
4976
tests/book.py
4976
tests/book.py
File diff suppressed because it is too large
Load diff
|
@ -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,44 +23,45 @@ class ReconTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product=self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product=self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
'date_from': date(2022, 5, 1),
|
||||
'date_to': date(2022, 5, 31),
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Asset-Book')
|
||||
self.assertEqual(book.reconciliations[0].feature, 'asset')
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] ' +
|
||||
'| 0.0000 u - 0.0000 u')
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
'date_from': date(2022, 5, 1),
|
||||
'date_to': date(2022, 5, 31),
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Asset-Book')
|
||||
self.assertEqual(book.reconciliations[0].feature, 'asset')
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] ' +
|
||||
'| 0.0000 u - 0.0000 u')
|
||||
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] ' +
|
||||
'| 0.0000 u - 0.0000 u')
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] ' +
|
||||
'| 0.0000 u - 0.0000 u')
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_set_start_quantity_by_predecessor(self):
|
||||
|
@ -72,91 +74,92 @@ class ReconTestCase(object):
|
|||
BType = pool.get('cashbook.type')
|
||||
|
||||
company = self.prep_company()
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product=self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
with Transaction().set_context({'company': company.id}):
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product=self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
|
||||
category = self.prep_category(cattype='in')
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'quantity_digits': 3,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
'date_from': date(2022, 5, 1),
|
||||
'date_to': date(2022, 5, 31),
|
||||
}])],
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 5),
|
||||
'bookingtype': 'in',
|
||||
'category': category.id,
|
||||
'description': 'Line 1',
|
||||
'amount': Decimal('5.0'),
|
||||
'quantity': Decimal('1.5'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 6),
|
||||
'bookingtype': 'in',
|
||||
'category': category.id,
|
||||
'description': 'Line 2',
|
||||
'party': party.id,
|
||||
'amount': Decimal('7.0'),
|
||||
'quantity': Decimal('2.5'),
|
||||
},])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Asset-Book')
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | ' +
|
||||
'0.000 u - 0.000 u')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
category = self.prep_category(cattype='in')
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'quantity_digits': 3,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 5, 28),
|
||||
'date_from': date(2022, 5, 1),
|
||||
'date_to': date(2022, 5, 31),
|
||||
}])],
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 5),
|
||||
'bookingtype': 'in',
|
||||
'category': category.id,
|
||||
'description': 'Line 1',
|
||||
'amount': Decimal('5.0'),
|
||||
'quantity': Decimal('1.5'),
|
||||
'party': party.id,
|
||||
}, {
|
||||
'date': date(2022, 5, 6),
|
||||
'bookingtype': 'in',
|
||||
'category': category.id,
|
||||
'description': 'Line 2',
|
||||
'party': party.id,
|
||||
'amount': Decimal('7.0'),
|
||||
'quantity': Decimal('2.5'),
|
||||
},])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Asset-Book')
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | ' +
|
||||
'0.000 u - 0.000 u')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
|
||||
Lines.wfcheck(list(book.lines))
|
||||
Lines.wfcheck(list(book.lines))
|
||||
|
||||
self.assertEqual(book.lines[0].quantity_balance, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[1].quantity_balance, Decimal('4.0'))
|
||||
self.assertEqual(book.lines[0].quantity_balance, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[1].quantity_balance, Decimal('4.0'))
|
||||
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
|
||||
self.assertEqual(book.lines[0].quantity_balance, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[1].quantity_balance, Decimal('4.0'))
|
||||
self.assertEqual(book.lines[0].quantity_balance, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[1].quantity_balance, Decimal('4.0'))
|
||||
|
||||
self.assertEqual(book.reconciliations[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2] ' +
|
||||
'| 0.000 u - 4.000 u')
|
||||
Reconciliation.wfdone(list(book.reconciliations))
|
||||
self.assertEqual(book.reconciliations[0].state, 'done')
|
||||
self.assertEqual(book.reconciliations[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2] ' +
|
||||
'| 0.000 u - 4.000 u')
|
||||
Reconciliation.wfdone(list(book.reconciliations))
|
||||
self.assertEqual(book.reconciliations[0].state, 'done')
|
||||
|
||||
recons = Reconciliation.create([{
|
||||
'cashbook': book.id,
|
||||
'date_from': date(2022, 5, 31),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])
|
||||
self.assertEqual(
|
||||
recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0] | ' +
|
||||
'0.000 u - 0.000 u')
|
||||
Reconciliation.wfcheck(recons)
|
||||
self.assertEqual(
|
||||
recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0] | ' +
|
||||
'4.000 u - 4.000 u')
|
||||
recons = Reconciliation.create([{
|
||||
'cashbook': book.id,
|
||||
'date_from': date(2022, 5, 31),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])
|
||||
self.assertEqual(
|
||||
recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0] | ' +
|
||||
'0.000 u - 0.000 u')
|
||||
Reconciliation.wfcheck(recons)
|
||||
self.assertEqual(
|
||||
recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0] | ' +
|
||||
'4.000 u - 4.000 u')
|
||||
|
||||
# end ReconTestCase
|
||||
|
|
Loading…
Reference in a new issue