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