from osv import fields, osv
from tools.translate import _
+class account_invoice(osv.osv):
+ _inherit = 'account.invoice'
+
+ def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
+ """
+ Returns a list of ids based on search domain {args}
+
+ @param cr: A database cursor
+ @param user: ID of the user currently logged in
+ @param args: list of conditions to be applied in search opertion
+ @param offset: default from first record, you can start from nth record
+ @param limit: number of records to be obtained as a result of search opertion
+ @param order: ordering on any field(s)
+ @param context: context arguments, like lang, time zone
+ @param count:
+
+ @return: Returns a list of ids based on search domain
+ """
+ ttype = context.get('ttype', False)
+ if ttype and ttype in ('rec_voucher', 'bank_rec_voucher'):
+ args += [('type','in', ['out_invoice', 'in_refund'])]
+ elif ttype and ttype in ('pay_voucher', 'bank_pay_voucher'):
+ args += [('type','in', ['in_invoice', 'out_refund'])]
+
+ res = super(account_invoice, self).search(cr, user, args, offset, limit, order, context, count)
+ return res
+
+account_invoice()
+
class account_move_line(osv.osv):
_inherit = "account.move.line"
_columns = {
res = super(account_voucher_line, self).move_line_get_item(cr, uid, line, context)
res['invoice'] = line.invoice_id or False
return res
-
+
def onchange_invoice_id(self, cr, uid, ids, invoice_id, currency_id):
currency_pool = self.pool.get('res.currency')
invoice_pool = self.pool.get('account.invoice')
<field name="payment_ids" position="replace">
<field name="voucher_line_ids" default_get="{'lines': voucher_line_ids}" colspan="4" nolabel="1" height="275">
<tree string="Voucher Lines" editable="top">
- <field name="partner_id" on_change="onchange_partner(partner_id,type,parent.type, parent.currency_id)"/>
+ <field name="partner_id" on_change="onchange_partner(partner_id, type, parent.type, parent.currency_id)"/>
<field name="account_id" on_change="onchange_line_account(account_id, type, parent.type)"/>
<field name="name"/>
- <field name="invoice_id" on_change="onchange_invoice_id(invoice_id, parent.currency_id)" domain="[('partner_id','=',partner_id),('state','=','open'),('residual','>',0.0)]"/>
+ <field name="invoice_id" context="{'ttype':parent.type}" on_change="onchange_invoice_id(invoice_id, parent.currency_id)" domain="[('partner_id','=',partner_id),('state','=','open'),('residual','>',0.0)]"/>
<field name="type"/>
<field name="amount"/>
<field name="account_analytic_id"/>