55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
import json
|
|
import os
|
|
|
|
from jinja2 import Environment, FileSystemLoader
|
|
|
|
from odoo import http
|
|
from odoo.http import request, Response
|
|
|
|
|
|
class MaintenanceEquipment(http.Controller):
|
|
|
|
def __init__(self):
|
|
template_path = os.path.join(os.path.dirname(__file__), '../static/')
|
|
self.jinja_env = Environment(loader=FileSystemLoader(template_path),
|
|
autoescape=True)
|
|
|
|
@http.route('/h5_equipment', type='http', auth='public', methods=['GET'], csrf=False)
|
|
def index(self):
|
|
t = self.jinja_env.get_template('h5/index.html')
|
|
return Response(t.render(), mimetype='text/html')
|
|
|
|
@http.route(['/api_h5/equipment/<int:id>'], type="http", auth="none", method=['GET'],
|
|
csrf=False)
|
|
def h5_equ(self, id):
|
|
'''
|
|
接口数据
|
|
'''
|
|
equipment = request.env['maintenance.equipment'].sudo().browse(id)
|
|
if equipment:
|
|
return request.make_json_response({
|
|
'code': 200,
|
|
'data': {
|
|
'id': equipment.id,
|
|
'name': equipment.name,
|
|
'company_id': equipment.company_id.id,
|
|
'company_name': equipment.company_id.name,
|
|
'maintenance_team_name': equipment.maintenance_team_id.name,
|
|
'technician_user_name': equipment.technician_user_id.name,
|
|
'assign_date': equipment.assign_date,
|
|
'location': equipment.location,
|
|
'department_name': equipment.department_id.name,
|
|
'employee_name': equipment.employee_id.name,
|
|
'equipment_assign_to': equipment.equipment_assign_to,
|
|
'note': equipment.note,
|
|
'serial_no': equipment.serial_no,
|
|
'cost':equipment.cost,
|
|
'warranty_dater': equipment.warranty_date,
|
|
'image_1920':equipment.image_1920,
|
|
}
|
|
})
|
|
return {
|
|
'code':400,
|
|
'message':'未找到该设备'
|
|
}
|