Odoo Help

0

Execute on change to edit

By
Javier Batres Velásquez
on 3/10/15, 4:30 PM 578 views

Hello I have a form where one list object have a onchage that affect the domain in other list, and it works on create option, but if i select the edit option, this isn executed when the form is loaded, and if the user dont change the first list the second list dont get the domain, can someone help me. Here is my code.

    @api.onchange('client_id')
    def _validate_cliente(self):
        print('validation')
        if self.client_id:
            self.invoice_ids = self.env['account.invoice']
            return {
                'domain' : {
                    'invoice_ids' : [('partner_id', '=', self.client_id.id), ('type', '=', 'out_invoice')]
                }
            }

The type of the fields are:

    client_id = fields.Many2one('res.partner', string='Cliente', required=True, domain=[('customer', '=', True)])
    invoice_ids = fields.Many2many('account.invoice', string='Facturas', domain=[('type', '=', 'out_invoice')])

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 3/10/15, 4:30 PM
Seen: 578 times
Last updated: 3/27/15, 6:41 PM