Merge lp:~mikel-martin/account-payment/6.1-fix-1199076 into lp:~account-payment-team/account-payment/6.1

Proposed by mikel
Status: Merged
Merged at revision: 105
Proposed branch: lp:~mikel-martin/account-payment/6.1-fix-1199076
Merge into: lp:~account-payment-team/account-payment/6.1
Diff against target: 65 lines (+10/-40)
1 file modified
account_payment_extension/account_move_line.py (+10/-40)
To merge this branch: bzr merge lp:~mikel-martin/account-payment/6.1-fix-1199076
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp code review, no test Approve
Pedro Manuel Baeza Approve
Review via email: mp+173833@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Mikel,

Indeed, this bug is very annoying, but I have found one problem in the SQL statement. In the line

left join account_move_line r on l.reconcile_id=r.reconcile_id and l.id<>l.id '

it compares l.id with l.id instead of l.id with r.id.

For the rest, I'm not sure what is the original purpose of this piece of code. Can you explain to me to be able to give a proper review?

Anyways, thanks for the patch :)

review: Needs Information
104. By mikel <mikel@hide>

[FIX] sql in account_move_line _invoice method

Revision history for this message
mikel (mikel-martin) wrote :

Thanks for your review Pedro, you are right.

This method populates the invoice field, putting there invoice names related wtih the move, directly or because this move pays the invoice partially or completly.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

OK, now I understand. Maybe avoid SQL code would be desirable, but I think here there will be a performance impact.

Let's wait for another review to proceed to be sure.

review: Approve
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Can anyone more review this MP so that it can be merged, because this bug is causing troubles to some people?

Thank you.

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

LGTM

review: Approve (code review, no test)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Is it also occurring in the module for the version 7?
I see the code is not the same but the query is more simple in V7.

Can you eventually propose a MP for v7 too please?

This one is merged. Thanks

Revision history for this message
mikel (mikel-martin) wrote :

Thanks for the Merge ;).

I'm not familiar with V7 yet. I can't MP for v7 in the short term.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I'll check it and do a similar MP to v7.

Regards.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I have made the MP to 7.0:

https://code.launchpad.net/~pedro.baeza/account-payment/7.0-invoice-name/+merge/183240

The question is that standard _invoice method doesn't retrieve correctly the invoice name in all the cases (for example, on partial reconciled entries), and this code is for repairing this behaviour. Maybe it can be merged on core, but for now this formula works.

Regards.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_payment_extension/account_move_line.py'
2--- account_payment_extension/account_move_line.py 2013-03-12 18:25:33 +0000
3+++ account_payment_extension/account_move_line.py 2013-07-15 10:25:31 +0000
4@@ -36,51 +36,21 @@
5 res = {}
6 for line_id in ids:
7 res[line_id] = False
8+
9 cursor.execute('SELECT l.id, i.id ' \
10- 'FROM account_move_line l, account_invoice i ' \
11- 'WHERE l.move_id = i.move_id ' \
12- 'AND l.id IN %s',
13+ 'FROM account_invoice i,account_move_line l ' \
14+ 'left join account_move_line r on l.reconcile_id=r.reconcile_id and l.id<>r.id ' \
15+ 'left join account_move_line p on l.reconcile_partial_id=p.reconcile_partial_id and l.id<>p.id ' \
16+ 'where (i.move_id = l.move_id or i.move_id = r.move_id or i.move_id = p.move_id) ' \
17+ 'AND l.id IN %s',
18 (tuple(ids),))
19- invoice_ids = []
20-
21+ invoice_ids = []
22
23 for line_id, invoice_id in cursor.fetchall():
24- res[line_id] = invoice_id
25- invoice_ids.append(invoice_id)
26- invoice_names = {False: ''}
27- for invoice_id, name in invoice_obj.name_get(cursor, user, invoice_ids, context=context):
28- invoice_names[invoice_id] = name
29- for line_id in res.keys():
30- invoice_id = res[line_id]
31- res[line_id] = (invoice_id, invoice_names[invoice_id])
32-
33- for key in res.keys():
34- if res[key][0] == False:
35- # if there is no a direct invoice related
36- move_line_obj = self.pool.get('account.move.line')
37- line1 = move_line_obj.browse(cursor, user, key)
38- move = self.pool.get('account.move').browse (cursor, user, line1.move_id.id)
39-
40- if move:
41- for line_in in move.line_id:
42- if line_in.id <> key and (line_in.reconcile_id or line_in.reconcile_partial_id):
43- if line_in.reconcile_id:
44- for line_in2 in line_in.reconcile_id.line_id:
45- if line_in2.id <> line_in.id:
46- dict = self._invoice (cursor, user, [line_in2.id], name, arg, context)
47- for item in dict.keys():
48- res[key] = dict[item]
49- else:
50- if line_in.reconcile_partial_id:
51- for line_in2 in line_in.reconcile_partial_id.line_partial_ids:
52- if line_in2.id <> line_in.id:
53- dict = self._invoice (cursor, user, [line_in2.id], name, arg, context)
54- for item in dict.keys():
55- res[key] = dict[item]
56-
57-
58+ name = invoice_obj.name_get(cursor, user, [invoice_id], context=context)
59+ res[line_id] = (invoice_id, len(name)>0 and name[0])
60 return res
61-
62+
63 #===========================================================================
64 # def _invoice(self, cr, uid, ids, name, arg, context=None):
65 # return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)

Subscribers

People subscribed via source and target branches