2
votes

I would like to update form fields "on-fly" after button press that triggers python function.
Something like onchange that allows to return field values, but I need to do it after button press. The situation is, to create module, that will allow to search for company information in public company register based on entered company registration ID. The best would be, to show up some popup window with updated fields list and user has to confirm, wether to update fields values or not.

Thank you.

1
Well your solution is Prefect for now, Else you need to create web addons for it.ifixthat

1 Answers

0
votes

You can create a wizard (osv.osv_memory class) to simulate a dynamic popup window. To populate this wizard, you can use the returned action descriptor of your python function, like this :

return {'res_model':'your.osv.memory',
'view_mode':'form',
'view_type':'form',
'target':'new',
'context':{...},
}

Thanks to your algorythm that get public company information, you just have to put you're fields values on the context, like you would do in a write() method. Override your default_get() method of your osv_memory, which receives your context, and populate your wizard like you want.

I think a simple text fields on your wizard will be efficient to display fields updated values, and 2 buttons : cancel and OK (which will call the write method to apply fields values, always using your context).