Skip to Content
Menu
This question has been flagged

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
Discard
Author Best Answer

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
Discard

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

Author

var1 = ' '

var2 = ' '

etc etc

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

Like that ? with empty variable at the beginning ?

Author

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)

Best Answer

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
Discard
Related Posts Replies Views Activity
0
Aug 18
3940
0
Jul 16
2824
2
Sep 20
10298
1
Nov 19
7132
1
Nov 19
3891