跳至内容
菜单
此问题已终结
1 回复
2060 查看

Hello, 


I´ve tried to create an simple http controller to get email addresses by write_date from res.partner

I´m using odoo12 and in 11 it seems to work that way but I only get a 500 internal server error if the logic finds an entry. 


if not the return works "nothing found"


any help would be very appreciated. 


Thanks

Philipp


from odoo.tools.translate import _
from odoo import http
from odoo.http import Response, request
import json
import sys



class get_contact_date(http.Controller):
@http.route('/get/contact_date/<field>/<value>', type='http', auth="public", website=True)
def get_contact_by_date(self, field, value, **kw):
assert field in ('write_date', 'email' )
prod = request.env['res.partner'].sudo().search([(field, '>=', value)])
if prod:
return json.dumps(prod.read(['write_date', 'email']))
else:
return "nothing found"
形象
丢弃
编写者 最佳答案

I found in the log: 

TypeError: Object of type res.partner is not JSON serializable 


形象
丢弃