Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
6439 Lượt xem

hi ,

I got a json file and the python code for parsing the data in that file , but i dont know how to use that for making the database entry for corresponding fields with odoo . What i need is to create a set of records using the data from json when i click the menu.


@api.multi
def json_parse(self):
filename = 'C:\Users\Dev\Desktop\data.json'
with open(filename) as call_log:
call_details = json.load(call_log)

while i < len(call_details[0]['objects']):
# if call_details[0]['objects'][i]['id'] not in model.id
# fields mapping
customer_number = call_details[0]['objects'][i]['caller_id']
call_duration = call_details[0]['objects'][i]['call_duration']
start_time = call_details[0]['objects'][i]['start_time']
call_type = call_details[0]['objects'][i]['Call_Type']

self.env['model.call'].write({'customer_number': self.customer_number})
self.env["model.call"].write({"agent_number": self.agent_number})

i += 1
Ảnh đại diện
Huỷ bỏ

you can use create method to enter data into database:

self.env['model.call'].create({'customer_number': self.customer_number})

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 17
3027
2
thg 12 16
9033
3
thg 2 25
2367
0
thg 5 24
46
1
thg 4 24
2586