Hi
I just created a custom module to add Invoices on customer Payments form, I am using onchange_partner_id event in my custom module so that when I change customer It has to fetch related Invoices for that particular customer.....
Able to display the Invoice field as a dropdown with all the Invoices on payment from, but the Onchange_partner_id event is not functioning it is not filtering Invoice custom field
Here is my code
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context=None):
res = super(account_voucher, self).onchange_partner_id(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context=None)
res['value'].update({'invoice_id': False})
commercial = False
if partner_id:
partner = self.pool.get('account.invoice').search(cr, uid, [('partner_id','=',partner_id)])
res.update({'value': {'invoice_id' : partner}})
return res
can anyone help me regarding the above criteria
Thanks in Advance
Hi actually I dont have enough karma to comment on your answer but Iam getting a server error as I can't start the odoo server itself it says return^ res Invalid syntax whn I am using below code @IT Libertas
I updated my answer to the full code function. Try it
Hey thanks a lot its working but in the dropdown it is showing all invoices default,,as of now its filtering only one latest invoice...
can we display as the drop down shows invoices only related to him like if he has two open invoices then.... by default it select the latest one and in dropdown list it should display another one only not all
how can it be
Didn't really understand what you meant. But I guess, you should add 'domain' to the field 'invoice_id'. Read the section 'Domains' here: https://www.odoo.com/documentation/8.0/reference/orm.html