Odoo Help


[V8] One wizard, multiple models

Aurélien Rivet
on 3/21/16, 9:29 AM 292 views


I would like to perform an operation on two differents models. Models have different fields, so programmatically operation won't be the same but from user's end, it is. That's why I would like to use only one wizard with one function per different target model.

But if I put many2many fields with defaults function to retrieve the current session objects, like the doc says it has to be, I have an error message because I have no message because the fields of the other model is not filled.

Is it mandatory to make one model per target model ?

What I have:

class do_stuff_on_model1(models.TransientModel):

     _name = 'do.stuff_on_model1')

     def _defaut_model1(self):

         return self.env['some.model1'].browse(self._context.get('active_ids'))

     def do_stuff(self):

         #do stuff on model 1


    model1_ids = fields.Many2Many('some.model1', default=_default_model1)

class do_stuff_on_model2(models.TransientModel):

     _name = 'do.stuff_on_model2')

     def _defaut_model1self):

         return self.env['some.model2'].browse(self._context.get('active_ids'))

     def do_stuff(self):

         #do stuff on model 2


    model2_ids = fields.Many2Many('some.model2', default=_default_model2)


What I want:

class do_stuff(models.TransientModel):

     _name ='do.stuff'    

     def _default_model1(self):

         return self.env['some.model1'].browse(self._context.get('active_ids'))


         return self.env['some.model2].browse(self._context.get('active_ids'))



     def do_some_stuff_on_model1(self):

         #do some stuff



     def do_some_stuff_on_model2(self):

         #do some stuff


     model1_ids = fields.Many2Many('some.model1', default=_default_model1)

     model2_ids = fields.Many2Many('some.model2', default=_default_model2)

it'll be helpful if you paste part of the code ..

Ahmed M.Elmubarak
on 3/21/16, 9:56 AM

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.


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)


Asked: 3/21/16, 9:29 AM
Seen: 292 times
Last updated: 3/21/16, 10:34 AM