Reputation: 1
I´m recovering data from a third party service using SoapPY and I keep it in a dictionary structure. Data recovered has the one2many structure, similar as a sale order structure (header-lines). I do that when clicking a custom button after filling some key values. I disabled Create and Save buttons because I want a different form behaviour. I just need to get the data and by hand save it in the corresponding tables (the header and the lines). I don't want the custom button performs the create method automatically as any button does it by default. Any sugestion, please?
def custom_button(self): # Get the info from third party using SOAPPy WSDLFile = "http://www.expedientes.poderjudicial.gub.uy/wsConsultaIUE.php?wsdl" proxy = WSDL.Proxy(WSDLFile) UIE = str(self.int_sede) + '-' + str(self.int_nro_registro) + '/' + str(self.int_ano) soap_exp = proxy.consultaIUE(UIE) # Set variables str_origen = soap_exp[1] str_caratula = soap_exp[3] str_abogado_actor = soap_exp[4] str_abogado_demandado = soap_exp[5] movimientos = soap_exp[6] mov_exp = [] for mov in movimientos: mov_exp.append ((0, 0, {'str_sede': mov['sede'], 'date_venc': mov['vencimiento'], 'str_decreto': mov['decreto'], 'date_mov': mov['fecha'], 'str_movimiento': mov['tipo']})) expediente = {'int_sede': self.int_sede, 'int_nro_registro': self.int_nro_registro, 'int_ano': self.int_ano, 'str_origen': str_origen, 'str_caratula': str_caratula, 'str_abogado_actor': str_abogado_actor, 'str_abogado_demandado': str_abogado_demandado, 'movimiento_ids': mov_exp } return write(expediente)
Upvotes: 0
Views: 307
Reputation: 3747
If you want to avoid Odoo's ORM then just go ahead and use sql. By creating and saving a record we mean the same thing. The write method operates on a recordset that already has been created. I see that:
return write(expediente)
What is this? Are you defining a write
callable somewhere? Are you importing the method write? The write method is usually invoked like self.write({'my_field':its_value})
where self is a recordset
So, on the click of your button you can:
1) use self.create({field1:value1, field2:value2, ...})
2) use self.env.cr.execute(r"insert raw sql here")
to create records in the table that you want (that is if you do not want to actually use Odoo's ORM
Upvotes: 0