コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
3643 ビュー

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


アバター
破棄
著作者 最善の回答

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 ?


アバター
破棄

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

著作者

var1 = ' '

var2 = ' '

etc etc

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

Like that ? with empty variable at the beginning ?

著作者

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)

最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
0
8月 18
4606
0
7月 16
3639
2
9月 20
11677
1
11月 19
8446
1
11月 19
4865