Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3444 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ส.ค. 18
4343
0
ก.ค. 16
3198
2
ก.ย. 20
11142
1
พ.ย. 19
7895
1
พ.ย. 19
4460