Hi,
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'))
def_default_model2(self):
return self.env['some.model2].browse(self._context.get('active_ids'))
@api.multi
@api.depends('model1_ids')
def do_some_stuff_on_model1(self):
#do some stuff
@api.multi
@api.depends('model2_ids')
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 ..