Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
3448 Vistas

Hi guyz, 

I try to record my custom' form but i don't how to create a dictionnary ? 

Can i do sommething like that : 


@http.route('/coopaname_helpdesk/post_form_ticket/<string:model_name>',  methods=['POST'], type = 'http', auth='public',  website= True )
def website_form(self, model_name, **kwargs):

data =

 { 'my_first_input' : '%s', 'my_second_input' : '%s' }

and record with : 

return request.env.cr['my_data_table_name'].create(data) 


Thanks for yours helps my friends, 

Best regards


Avatar
Descartar
Autor Mejor respuesta

Yes but i want a dynamic value, not a static value written into the code, i want the value' input from the customer. 

So i can't define my variable before user submit the form, do you see what i mean bro ?


Avatar
Descartar

This is not a static value, you can assign the values you receiving from the form to the variables, i just have shown a sample for understanding, if you print **kwargs you will get the values from the form, from that you can get the values and assign in dictionary

Autor

var1 = ' '

var2 = ' '

etc etc

data = { 'my_first_input' : ' var1' , 'my_second_input' : ' var2' }

Like that ? with empty variable at the beginning ?

Autor

or like that :

var_x_objet_consultation = kwargs.get('x_objet_consultation')

etc etc

data = { 'x_objet_consultation' : ' var_x_objet_consultation ' }

return request.env.cr['my table database']. create(data)

Mejor respuesta

Hi,

You can easily create a dictionary like this,

variable_1 = 'Niyas'

varibale_2 = 'Test'

data =

 { 'my_first_input' :  variable_1,

'my_second_input' : variable_2

 }


Thanks

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
ago 18
4363
0
jul 16
3214
2
sept 20
11157
1
nov 19
7916
1
nov 19
4472