43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import base64
|
|
import json
|
|
|
|
from odoo import http, fields
|
|
from odoo.http import request
|
|
|
|
|
|
class YuthonNotice(http.Controller):
|
|
|
|
@http.route('/yuthon/yuthon/notice', methods=['POST'], type='http', auth='none', csrf=False)
|
|
def index(self, **kwargs):
|
|
id = kwargs.get('id')
|
|
|
|
data = request.env['yuthon.notice'].sudo().search([("id", "=", int(id))])
|
|
documents = []
|
|
for document in data.documents_ids:
|
|
documents.append({
|
|
'id': document.id,
|
|
'name': document.name,
|
|
'url': document.url,
|
|
'type': document.type,
|
|
'file_size': document.file_size,
|
|
'file_size_display':document.file_size_display,
|
|
'mimetype': document.mimetype,
|
|
'datas': document.datas.decode('utf-8') if document.datas else None,
|
|
})
|
|
|
|
result = {
|
|
'id': data.id,
|
|
'title': data.name,
|
|
'code': data.code,
|
|
'create_date1': fields.Date.to_string(data.create_date1),
|
|
'notice_text': data.notice_text,
|
|
'documents':documents,
|
|
'user_name':data.users_id.name,
|
|
'read_number': data.read_number,
|
|
}
|
|
return json.dumps({
|
|
'data':result,
|
|
'code':200,
|
|
'message':'success'
|
|
})
|