Help

0

Is it possible to load a window action on onchange?

Avatar
Samo Arko

I have a form view(model1) with a list for the One2many field that is related to model2. On the related model (model2) that is shown as list I have a field that has an onchange method. That method creates a record in model3.

Models:  model1: task, model2: timesheet, model3: anwsers

Relation

model1 One2many model2

model2 Many2one model3

With this onchange on a field in model2 I can create a record in model3. Now I would like to return an window action of the model3 created record to show a popup in the form view of model1.

The model2 method:


answer_id = fields.Many2one('tabla.customer.answers')


# FIXME Test za vnos odgovorov za stranko
@api.onchange('tabla_timesheet_type_id')
@api.multi
def change_timesheet_type(self):
for rec in self:
if rec.tabla_timesheet_type_id:
try:
rec.answer_id.sudo().create({'timesheet_name': rec.name})
except Exception as e:
_logger.error(u'Error on creating answer: {}'.format(e))

try:
action = self.env.ref('tabla_project_ticket.action_show_answer_form').read()[0]
action['res_id'] = rec.answer_id.id
return action
except Exception as e:
_logger.error(u'Error on getting answer action: {}!'.format(e))


I really don't know how to describe well what I want. Hope that this is possible.

Avatar
Discard
1 Answer
1
Avatar
Avinash Nk
Best Answer

Hello Samo Arko,

The onchange method can return only a dictionary for changing field domains and pop up a warning message

It is not possible to return actions.


Thanks & Regards

Avinash N K

1 Comment
Avatar
Discard
Avatar
Samo Arko
-

thanks... so I need to find a different way to do this.