Merge lp:~camptocamp/openobject-addons/6.1-opening-entry-fix-mdh into lp:~camptocamp/openobject-addons/6.1-c2c-official

Proposed by Matthieu Dietrich @ camptocamp
Status: Merged
Merged at revision: 6640
Proposed branch: lp:~camptocamp/openobject-addons/6.1-opening-entry-fix-mdh
Merge into: lp:~camptocamp/openobject-addons/6.1-c2c-official
Diff against target: 27 lines (+1/-9)
1 file modified
account/wizard/ (+1/-9)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/6.1-opening-entry-fix-mdh
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Yannick Vaucher @ Camptocamp Approve
Leonardo Pistone Approve
Romain Deheele - Camptocamp (community) code review Approve
Review via email:

Commit message

[FIX] lp:1257288 - fixed amount in foreign currency for opening entries

Description of the change

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).

New 6.1 branch, after another commit was "stored" in this one (I'll make a separate MP to keep XA and c2c-official consistent).

To post a comment you must log in.
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :



review: Approve (code review)
Revision history for this message
Leonardo Pistone (lepistone) wrote :

I have a doubt about """if else 0.0"""

If the currency_id field is empty, then if I remember correctly, account.currency_id is a browse_null
object, something that should be False when cast to boolean. On the other hand, I am not sure that will work.

I suggest changing that line to """if account.currency_id else 0.0"""


review: Needs Information
6641. By Matthieu Dietrich @ camptocamp on 2014-04-17

[FIX] remove .id from boolean test

Revision history for this message
Matthieu Dietrich @ camptocamp (mdietrich-c2c) wrote :

@Leonardo : good point, I missed this and it is now corrected.

Revision history for this message
Leonardo Pistone (lepistone) wrote :


review: Approve
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

Remark : if currency_id is null, returns False (in 7.0, I don't know in 6.1).
but I'm ok with this change.


Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

In 6.1 and 7.0 browse_null should act the same. Thus returning None when __getattr__ is called:

However for 6.1 there are very few use of this mechanism so it is fine that way.

review: Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/wizard/'
2--- account/wizard/ 2012-02-09 17:03:33 +0000
3+++ account/wizard/ 2014-04-17 07:54:37 +0000
4@@ -224,14 +224,6 @@
5 query_2nd_part = ""
6 query_2nd_part_args = []
7 for account in obj_acc_account.browse(cr, uid, account_ids, context={'fiscalyear': fy_id}):
8- balance_in_currency = 0.0
9- if account.currency_id:
10- cr.execute('SELECT sum(amount_currency) as balance_in_currency FROM account_move_line ' \
11- 'WHERE account_id = %s ' \
12- 'AND ' + query_line + ' ' \
13- 'AND currency_id = %s', (,
14- balance_in_currency = cr.dictfetchone()['balance_in_currency']
16 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id
17 if not currency_obj.is_zero(cr, uid, company_currency_id, abs(account.balance)):
18 if query_2nd_part:
19@@ -246,7 +238,7 @@
22 account.currency_id and or None,
23- balance_in_currency,
24+ account.foreign_balance if account.currency_id else 0.0,
26 'draft')
27 if query_2nd_part:


People subscribed via source and target branches

to all changes: