Merge lp:~pedro.baeza/account-payment/7.0-invoice-name into lp:~account-payment-team/account-payment/7.0

Proposed by Pedro Manuel Baeza
Status: Merged
Merged at revision: 103
Proposed branch: lp:~pedro.baeza/account-payment/7.0-invoice-name
Merge into: lp:~account-payment-team/account-payment/7.0
Diff against target: 29 lines (+18/-1)
1 file modified
account_payment_extension/account_move_line.py (+18/-1)
To merge this branch: bzr merge lp:~pedro.baeza/account-payment/7.0-invoice-name
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Raphaël Valyi - http://www.akretion.com Approve
Review via email: mp+183240@code.launchpad.net

Description of the change

As made on 6.1 branch, _invoice method of account_move_line has been improved for get correct invoice name.

To post a comment you must log in.
102. By Pedro Manuel Baeza

[FIX] account_payment_extension: bug in account_move_line.py

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Indeed simple port of what been approved on 6.1 already. Looks good.

review: Approve
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM, thanks !

review: Approve (code review, no tests)

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-01-02 17:48:45 +0000
3+++ account_payment_extension/account_move_line.py 2013-09-02 13:29:12 +0000
4@@ -31,7 +31,24 @@
5 _inherit = 'account.move.line'
6
7 def _invoice(self, cr, uid, ids, name, arg, context=None):
8- return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)
9+ invoice_obj = self.pool.get('account.invoice')
10+ res = {}
11+ for line_id in ids:
12+ res[line_id] = False
13+
14+ cursor.execute('SELECT l.id, i.id ' \
15+ 'FROM account_invoice i,account_move_line l ' \
16+ 'left join account_move_line r on l.reconcile_id=r.reconcile_id and l.id<>r.id ' \
17+ 'left join account_move_line p on l.reconcile_partial_id=p.reconcile_partial_id and l.id<>p.id ' \
18+ 'where (i.move_id = l.move_id or i.move_id = r.move_id or i.move_id = p.move_id) ' \
19+ 'AND l.id IN %s',
20+ (tuple(ids),))
21+ invoice_ids = []
22+
23+ for line_id, invoice_id in cursor.fetchall():
24+ name = invoice_obj.name_get(cursor, user, [invoice_id], context=context)
25+ res[line_id] = name and name[0] or False
26+ return res
27
28 def _invoice_search(self, cr, uid, obj, name, args, context={}):
29 """ Redefinition for searching account move lines without any invoice related ('invoice.id','=',False)"""