Merge lp:~camptocamp/account-financial-tools/fix-1189922 into lp:~account-core-editors/account-financial-tools/7.0

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Merged at revision: 115
Proposed branch: lp:~camptocamp/account-financial-tools/fix-1189922
Merge into: lp:~account-core-editors/account-financial-tools/7.0
Diff against target: 15 lines (+4/-2)
1 file modified
account_constraints/account_constraints.py (+4/-2)
To merge this branch: bzr merge lp:~camptocamp/account-financial-tools/fix-1189922
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code Approve
Guewen Baconnier @ Camptocamp code review, no test Approve
Review via email: mp+168678@code.launchpad.net

Description of the change

fix bug 1189922 that prevents validation of invoices with 0% export tax. Because it creates zero amount move line(s).

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Why do you cast bool for the first condition?
This condition leads to confusion especially when we have to deal with the precedence (+ has a higher precedence than 'not', while 'and' has a lower precedence than 'not').

Seems simpler to me:

    if not (l.debit and l.credit):
        continue
    if bool(l.currency_id) != bool(l.amount_currency):
        return False

review: Needs Fixing
115. By Nicolas Bessi - Camptocamp

[IMP] code styling

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Fix commited

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

Thanks for the changes.
LGTM

review: Approve (code review, no test)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_constraints/account_constraints.py'
2--- account_constraints/account_constraints.py 2013-02-06 09:42:14 +0000
3+++ account_constraints/account_constraints.py 2013-07-11 08:35:33 +0000
4@@ -122,8 +122,10 @@
5
6 def _check_currency_and_amount(self, cr, uid, ids, context=None):
7 for l in self.browse(cr, uid, ids, context=context):
8- if ((l.currency_id and not l.amount_currency) or
9- (not l.currency_id and l.amount_currency)):
10+ # we check zero amount line
11+ if not (l.debit and l.credit):
12+ continue
13+ if bool(l.currency_id) != bool(l.amount_currency):
14 return False
15 return True
16

Subscribers

People subscribed via source and target branches