[FIX]: further improvement in selection invoice in voucher
authorMantavya Gajjar <mga@tinyerp.com>
Thu, 29 Jul 2010 15:56:28 +0000 (21:26 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Thu, 29 Jul 2010 15:56:28 +0000 (21:26 +0530)
bzr revid: mga@tinyerp.com-20100729155628-ek5eyvsycwg3y31r

addons/account_voucher/voucher.py
addons/account_voucher_payment/account_voucher_payment.py

index 0b1b9b0..e100551 100644 (file)
@@ -203,7 +203,7 @@ class account_voucher(osv.osv):
             }
             self.write(cr, uid, ids, res)
         else:
-            raise osv.except_osv('Invalid action !', 'You cannot post to Pro-Forma a voucher with Total amount = 0 !')
+            raise osv.except_osv(_('Invalid action !'), _('You can not post to Pro-Forma a voucher with Total amount = 0 !'))
         return True
 
     def proforma_voucher(self, cr, uid, ids, context={}):
index dca7eeb..2bae0e6 100755 (executable)
@@ -45,7 +45,10 @@ class account_invoice(osv.osv):
             args += [('type','in', ['out_invoice', 'in_refund'])]
         elif ttype and ttype in ('pay_voucher', 'bank_pay_voucher'):
             args += [('type','in', ['in_invoice', 'out_refund'])]
-        
+        elif ttype and ttype in('journal_sale_vou', 'journal_pur_voucher', 'journal_voucher'):
+            raise osv.except_osv(_('Invalid action !'), _('You can not reconcile sales, purchase, or journal entry with invoice !'))
+            args += [('type','=', 'do_not_allow_search')]
+
         res = super(account_invoice, self).search(cr, user, args, offset, limit, order, context, count)
         return res
     
@@ -187,11 +190,12 @@ class account_voucher(osv.osv):
                 move_line_id = move_line_pool.create(cr, uid, move_line)
                 line_ids += [move_line_id]
                 
-                if line.invoice_id:
+                if line.invoice_id and inv.type in ('pay_voucher', 'bank_pay_voucher', 'rec_voucher', 'bank_rec_voucher'):
                     rec_ids += [move_line_id]
                     for move_line in line.invoice_id.move_id.line_id:
                         if line.account_id.id == move_line.account_id.id:
-                            rec_ids += [move_line.id]            
+                            rec_ids += [move_line.id]
+
             if rec_ids:
                 move_line_pool.reconcile_partial(cr, uid, rec_ids)