← Back to team overview

openerp-community-reviewer team mailing list archive

lp:~camptocamp/ocb-addons/opening_entry_foreign_currency_fix_mdh into lp:ocb-addons

 

Matthieu Dietrich @ camptocamp has proposed merging lp:~camptocamp/ocb-addons/opening_entry_foreign_currency_fix_mdh into lp:ocb-addons.

Commit message:
[FIX] correct amount for opening entry in foreign currency

Requested reviews:
  OpenERP Community Backports Team (ocb)

For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/opening_entry_foreign_currency_fix_mdh/+merge/197526

Found this issue: when computing an opening entry, the move lines' domains differ between the amount in system currency (all move lines in the latest FY before the current one, for example FY2012) and the amount in foreign currency (all move lines in previous FY, for example FY2012, 2011, 2010...).

I removed the old method to retrieve the sum of foreign amounts, which used a domain of multiple FYs, and retrieved the correct sum by using the function field "foreign_balance" in the account (since a single FY is specified in the browse() context, only the balance for this FY is retrieved; this is how the correct "account.balance" works).
-- 
https://code.launchpad.net/~camptocamp/ocb-addons/opening_entry_foreign_currency_fix_mdh/+merge/197526
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~camptocamp/ocb-addons/opening_entry_foreign_currency_fix_mdh into lp:ocb-addons.
=== modified file 'account/wizard/account_fiscalyear_close.py'
--- account/wizard/account_fiscalyear_close.py	2012-10-23 16:05:04 +0000
+++ account/wizard/account_fiscalyear_close.py	2013-12-03 14:04:04 +0000
@@ -224,14 +224,6 @@
         query_2nd_part = ""
         query_2nd_part_args = []
         for account in obj_acc_account.browse(cr, uid, account_ids, context={'fiscalyear': fy_id}):
-            balance_in_currency = 0.0
-            if account.currency_id:
-                cr.execute('SELECT sum(COALESCE(amount_currency,0.0)) as balance_in_currency FROM account_move_line ' \
-                        'WHERE account_id = %s ' \
-                            'AND ' + query_line + ' ' \
-                            'AND currency_id = %s', (account.id, account.currency_id.id))
-                balance_in_currency = cr.dictfetchone()['balance_in_currency']
-
             company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id
             if not currency_obj.is_zero(cr, uid, company_currency_id, abs(account.balance)):
                 if query_2nd_part:
@@ -246,7 +238,7 @@
                        period.id,
                        account.id,
                        account.currency_id and account.currency_id.id or None,
-                       balance_in_currency,
+                       account.foreign_balance if account.currency_id else 0.0,
                        account.company_id.id,
                        'draft')
         if query_2nd_part:


Follow ups