line: valid handling of 2nd-currency + test
This commit is contained in:
parent
50c3ef04bc
commit
04fdd9dc9e
3 changed files with 303 additions and 5 deletions
|
@ -9,6 +9,7 @@ from trytond.transaction import Transaction
|
|||
from trytond.exceptions import UserError
|
||||
from trytond.modules.company.tests import create_company
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class ConfigTestCase(ModuleTestCase):
|
||||
|
@ -53,6 +54,51 @@ class ConfigTestCase(ModuleTestCase):
|
|||
}])
|
||||
return party
|
||||
|
||||
def prep_2nd_currency(self, company):
|
||||
""" add EUR as 2nd currency
|
||||
"""
|
||||
pool = Pool()
|
||||
Currency = pool.get('currency.currency')
|
||||
CurrencyRate = pool.get('currency.currency.rate')
|
||||
Company = pool.get('company.company')
|
||||
|
||||
usd, = Currency.search([('name', '=', 'usd')])
|
||||
euros = Currency.search([('code', '=', 'EUR')])
|
||||
if len(euros) == 0:
|
||||
euro, = Currency.create([{
|
||||
'name': 'Euro',
|
||||
'symbol': '€',
|
||||
'code': 'EUR',
|
||||
'numeric_code': '978',
|
||||
'rounding': Decimal('0.01'),
|
||||
'digits': 2,
|
||||
}])
|
||||
else :
|
||||
euro = euros[0]
|
||||
|
||||
# set company-currency to euro
|
||||
self.assertEqual(company.currency.name, 'usd')
|
||||
Company.write(*[
|
||||
[company],
|
||||
{
|
||||
'currency': euro.id,
|
||||
}])
|
||||
self.assertEqual(company.currency.name, 'Euro')
|
||||
|
||||
# add rate for euro/usd @ 05/02/2022
|
||||
# EUR is base-currency
|
||||
CurrencyRate.create([{
|
||||
'date': date(2022, 5, 2),
|
||||
'currency': euro.id,
|
||||
'rate': Decimal('1.0'),
|
||||
}, {
|
||||
'date': date(2022, 5, 2),
|
||||
'currency': usd.id,
|
||||
'rate': Decimal('1.05'),
|
||||
}])
|
||||
|
||||
return (usd, euro)
|
||||
|
||||
@with_transaction()
|
||||
def test_config_create(self):
|
||||
""" create config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue