Skip to content

Commit

Permalink
Merge fd9c58a into 950bbc8
Browse files Browse the repository at this point in the history
  • Loading branch information
grindtildeath committed Apr 4, 2019
2 parents 950bbc8 + fd9c58a commit 922932a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 43 deletions.
1 change: 0 additions & 1 deletion account_multicurrency_revaluation/model/__init__.py
@@ -1,4 +1,3 @@
from . import res_company
from . import account
from . import res_currency
from . import res_config
30 changes: 0 additions & 30 deletions account_multicurrency_revaluation/model/res_currency.py

This file was deleted.

Expand Up @@ -160,7 +160,7 @@ def test_uk_revaluation(self):
'revaluation_date': '%s-03-15' % fields.Date.from_string(
fields.Date.today()).strftime('%Y'),
'journal_id': self.reval_journal.id,
'label': '[%(account)s] wiz_test',
'label': '[%(account)s,%(rate)s] wiz_test',
}
wiz = wizard.create(data)
result = wiz.revaluate_currency()
Expand All @@ -175,6 +175,11 @@ def test_uk_revaluation(self):
self.assertEqual(len(reval_move_lines), 8)

for reval_line in reval_move_lines:

label = reval_line.name
rate = label[label.find(',') + 1:label.find(']')].strip()
self.assertEqual(rate, '2.5')

if reval_line.account_id.name == 'Account Liquidity USD':
self.assertFalse(reval_line.partner_id)
self.assertEqual(reval_line.credit, 0.0)
Expand Down
Expand Up @@ -108,8 +108,8 @@ def _create_move_and_lines(
created_move.post()
return [x.id for x in created_move.line_ids]

@api.model
def _compute_unrealized_currency_gl(self, currency_id, balances, form):
@api.multi
def _compute_unrealized_currency_gl(self, currency_id, balances):
"""
Update data dict with the unrealized currency gain and loss
plus add 'currency_rate' which is the value used for rate in
Expand All @@ -126,22 +126,18 @@ def _compute_unrealized_currency_gl(self, currency_id, balances, form):

# Compute unrealized gain loss
ctx_rate = context.copy()
ctx_rate['date'] = form.revaluation_date
cp_currency = form.journal_id.company_id.currency_id
ctx_rate['date'] = self.revaluation_date
cp_currency = self.journal_id.company_id.currency_id

currency = currency_obj.browse(currency_id)
currency = currency_obj.browse(currency_id).with_context(ctx_rate)

foreign_balance = adjusted_balance = balances.get(
'foreign_balance', 0.0)
balance = balances.get('balance', 0.0)
unrealized_gain_loss = 0.0
if foreign_balance:
ctx_rate['revaluation'] = True
adjusted_balance = currency.with_context(ctx_rate).compute(
foreign_balance, cp_currency
)
adjusted_balance = currency.compute(foreign_balance, cp_currency)
unrealized_gain_loss = adjusted_balance - balance
# revaluated_balance = balance + unrealized_gain_loss
else:
if balance:
if currency_id != cp_currency.id:
Expand Down Expand Up @@ -310,7 +306,8 @@ def revaluate_currency(self):
# Update sums with compute amount currency balance
diff_balances = self._compute_unrealized_currency_gl(
currency_id,
sums, self)
sums
)
account_sums[account_id][currency_id][partner_id].\
update(diff_balances)

Expand Down

0 comments on commit 922932a

Please sign in to comment.