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/account_fiscalyear_close.py (+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: mp+216093@code.launchpad.net

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 :

LGTM,

Romain

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

I have a doubt about """if account.currency_id.id 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 account.currency_id.id will work.

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

Thanks

review: Needs Information
6641. By Matthieu Dietrich @ camptocamp

[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 :

thanks!

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

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

Romain

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:

http://bazaar.launchpad.net/~openerp/openobject-server/6.1/view/head:/openerp/osv/orm.py#L257
http://bazaar.launchpad.net/~openerp/openobject-server/7.0/view/head:/openerp/osv/orm.py#L266

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
=== modified file 'account/wizard/account_fiscalyear_close.py'
--- account/wizard/account_fiscalyear_close.py 2012-02-09 17:03:33 +0000
+++ account/wizard/account_fiscalyear_close.py 2014-04-17 07:54:37 +0000
@@ -224,14 +224,6 @@
224 query_2nd_part = ""224 query_2nd_part = ""
225 query_2nd_part_args = []225 query_2nd_part_args = []
226 for account in obj_acc_account.browse(cr, uid, account_ids, context={'fiscalyear': fy_id}):226 for account in obj_acc_account.browse(cr, uid, account_ids, context={'fiscalyear': fy_id}):
227 balance_in_currency = 0.0
228 if account.currency_id:
229 cr.execute('SELECT sum(amount_currency) as balance_in_currency FROM account_move_line ' \
230 'WHERE account_id = %s ' \
231 'AND ' + query_line + ' ' \
232 'AND currency_id = %s', (account.id, account.currency_id.id))
233 balance_in_currency = cr.dictfetchone()['balance_in_currency']
234
235 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id227 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id
236 if not currency_obj.is_zero(cr, uid, company_currency_id, abs(account.balance)):228 if not currency_obj.is_zero(cr, uid, company_currency_id, abs(account.balance)):
237 if query_2nd_part:229 if query_2nd_part:
@@ -246,7 +238,7 @@
246 period.id,238 period.id,
247 account.id,239 account.id,
248 account.currency_id and account.currency_id.id or None,240 account.currency_id and account.currency_id.id or None,
249 balance_in_currency,241 account.foreign_balance if account.currency_id else 0.0,
250 account.company_id.id,242 account.company_id.id,
251 'draft')243 'draft')
252 if query_2nd_part:244 if query_2nd_part:

Subscribers

People subscribed via source and target branches

to all changes: