Skip to Content
Menu
This question has been flagged
1 Reply
2418 Views

Good morning what happens is that I am developing a controller to bring some data from the field service module since I am developing a mobile application, the drawback is that when I call a many2many table I get the following error


"Expected singleton: fsm.person(865, 867)"


My code

class Reports(http.Controller): @http.route('/get_reports', type="json", auth='user') 

def get_all_reports(self): 

# Get all reports 

reports_rec = request.env['fsm.order'].search([]) 

reports = [] 

tabla = [] 

for x in reports_rec: 

Inicio = { 

'name': x.name, 

'id': x.id, 

'type': x.type.name, 

'template_id': x.template_id.name, 

'project_id': x.project_id.name, 

'project_task_id': x.project_task_id.name,

'priority': x.priority, 

'tag_ids': x.tag_ids.name, 

'centro_costos': x.centro_costos.name, 

'cajero': x.cajero, 

'person_id': x.person_id.name, 

'anotaciones': x.anotaciones, 

'tipo_unidad': x.tipo_unidad, 

'tdv': x.tdv } 

Descripcion = { 

'description': x.description, 

Planificacion = {

 'Requisitos': [ { 

'category_ids': x.category_ids.name, 

'request_early': x.request_early, 

'request_late': x.request_late }], 

'Detalles del Horario': [ { 

'sheduled_date_start': x.scheduled_date_start, 

'sheduled_duration': x.scheduled_duration,

 'sheduled_date_end': x.scheduled_date_end }], } 

for y in x.person_ids.name: 

var = { 

'Solicitar Trabajadores': [ 

'name': y.name, 

'category_ids': y.category_ids.name,

 'phone': y.phone,

 'email': y.email } ] }

tabla.append(var)

reports.append(Inicio) 

reports.append(Descripcion) 

reports.append(Planificacion) 

reports.append(tabla)
data = {'status': 200, 'response': reports, 'message': 'Success', } 

return data

Avatar
Discard
Best Answer

You have this incorrect loop for y in x.person_ids.name: and it should be
for y in x.person_ids:

Avatar
Discard
Author

You were right but I still get the error what happens is that I want to bring these two fields or if more are added to a json-type controller
https://postimg.cc/njpWLcdj
because when I add that second field to the table I get the error of
"Expected singleton: fsm.person(865, 867)"

maybe the error showing by another code

Related Posts Replies Views Activity
2
Jun 24
9709
1
Jun 23
1697
0
Jul 17
13730
0
Jan 16
3481
2
Apr 22
8942