From 4f458063b1755c872014bca659a05bbf1b6f4606 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Thu, 19 Aug 2010 05:13:52 +0530 Subject: [PATCH] [IMP]: improvement in voucher bzr revid: mga@tinyerp.com-20100818234352-wh52b01gs09ldfth --- addons/account/account_view.xml | 1 + addons/account_voucher/voucher.py | 17 +++++++----- .../voucher_payment_receipt_view.xml | 8 +++--- .../account_voucher_payment.py | 7 +++-- .../account_voucher_payment_view.xml | 27 ++----------------- 5 files changed, 20 insertions(+), 40 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 137297e9b3f..bb0e96a8380 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -676,6 +676,7 @@ + diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 6a8bae5a5e5..11829815bb8 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -60,14 +60,13 @@ class account_move(osv.osv): rs.update({ 'reconcile_id': line.reconcile_id.id }) + break res[move.id] = rs return res _columns = { - 'reconcile_id': fields.function(_amount_all, method=True, type="many2one", relation="account.move.line", string='Reconcile', - store={ - 'account.move.line': (_get_line_ids, [], 20), - }, + 'reconcile_id': fields.function(_amount_all, method=True, type="many2one", relation="account.move.reconcile", select=True, string='Reconcile', + store=True, multi='all'), } @@ -101,7 +100,7 @@ class account_move(osv.osv): elif ttype and ttype in('sale', 'purchase'): raise osv.except_osv(_('Invalid action !'), _('You can not reconcile sales, purchase, or journal voucher with invoice !')) args += [('journal_id.type','=', 'do_not_allow_search')] - res = super(account_move, self).search(cr, user, args, offset, limit, order, context, count) + res = super(account_move, self).search(cr, user, args, offset, limit, order, {}, count) return res account_move() @@ -239,7 +238,7 @@ class account_voucher(osv.osv): res = [] context.update({ - 'ttype':ttype, + 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) @@ -249,6 +248,10 @@ class account_voucher(osv.osv): 'context':context, } if not partner_id or not ttype: + if ids: + line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) + if line_ids: + line_pool.unlink(cr, uid, line_ids) return default if ttype not in ('payment', 'receipt'): @@ -262,7 +265,7 @@ class account_voucher(osv.osv): line_pool.unlink(cr, uid, line_ids) voucher_id = ids[0] - ids = move_pool.search(cr, uid, [('state','=','posted'), ('partner_id','=',partner_id), ('reconcile_id','=', False)], context=context) + ids = move_pool.search(cr, uid, [('reconcile_id','=', False), ('state','=','posted'), ('partner_id','=',partner_id)], context=context) for move in move_pool.browse(cr, uid, ids): rs = { 'ref':move.ref or '/', diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 5c5660d42bd..b63897d6507 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -10,8 +10,8 @@ - - + + @@ -79,8 +79,8 @@ - - + + diff --git a/addons/account_voucher_payment/account_voucher_payment.py b/addons/account_voucher_payment/account_voucher_payment.py index 9b50fc98059..6e57e0efc12 100755 --- a/addons/account_voucher_payment/account_voucher_payment.py +++ b/addons/account_voucher_payment/account_voucher_payment.py @@ -133,6 +133,7 @@ class account_voucher(osv.osv): line_ids += [move_line_pool.create(cr, uid, move_line)] else: for line in inv.payment_ids: + amount=0.0 if inv.type in ('payment'): @@ -169,13 +170,11 @@ class account_voucher(osv.osv): move_line.update({ 'debit': line.amount or False }) - amount = line.amount elif line.type == 'cr': move_line.update({ 'credit': line.amount or False }) - amount = line.amount move_line_id = move_line_pool.create(cr, uid, move_line) line_ids += [move_line_id] @@ -185,10 +184,10 @@ class account_voucher(osv.osv): for move_line in line.move_id.line_id: if line.account_id.id == move_line.account_id.id: rec_ids += [move_line.id] - + if rec_ids: move_line_pool.reconcile_partial(cr, uid, rec_ids) - + rec = { 'move_id': move_id } diff --git a/addons/account_voucher_payment/account_voucher_payment_view.xml b/addons/account_voucher_payment/account_voucher_payment_view.xml index 8dcdb50a25e..b634f3534e9 100755 --- a/addons/account_voucher_payment/account_voucher_payment_view.xml +++ b/addons/account_voucher_payment/account_voucher_payment_view.xml @@ -1,6 +1,7 @@ + account.voucher.form.inherit account.voucher @@ -32,7 +33,7 @@ - + @@ -43,30 +44,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - account.voucher.form.payment.unreconcile account.voucher