Skip to Content
Menu
This question has been flagged
1 Reply
3593 Views

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
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

Avatar
Discard
Author

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

Related Posts Replies Views Activity
0
Jun 21
1795
0
Apr 20
3285
1
Sep 17
4271
1
Jul 19
3047
0
Oct 17
2292