Commit 7fb1f750 by guibin

Merge branch 'tht-project' of https://git.rokedata.com/dws/dwsproject into tht-project

parents 3e5c45a5 5a8d630e
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# from odoo import http from odoo import http
from odoo.http import request
from odoo.addons.roke_mes_three_colour_light.controller.main import RokeMesThreeColourLight
# class ThtProject(http.Controller): import os
# @http.route('/tht_project/tht_project/', auth='public') from jinja2 import Environment, FileSystemLoader
# def index(self, **kw): BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# return "Hello, world" templateloader = FileSystemLoader(searchpath=BASE_DIR + "/static/src/view")
env = Environment(loader=templateloader)
# @http.route('/tht_project/tht_project/objects/', auth='public') class RokeMesThreeColourLightExt(RokeMesThreeColourLight):
# def list(self, **kw): #重写
# return http.request.render('tht_project.listing', { @http.route("/roke/three_color_light/device_state_list", type="http", auth='none', cors='*', csrf=False)
# 'root': '/tht_project/tht_project', def device_state_list(self, **kwargs):
# 'objects': http.request.env['tht_project.tht_project'].search([]), # 自定义逻辑
# }) _self = request
factory_code = "custom_factory_code_123" # 自定义 factory_code
# @http.route('/tht_project/tht_project/objects/<model("tht_project.tht_project"):obj>/', auth='public') data = {
# def object(self, obj, **kw): "code": 1,
# return http.request.render('tht_project.object', { "message": "请求通过",
# 'object': obj "data": {
# }) "factory_code": factory_code,
"override": True # 添加额外字段
}
}
template = env.get_template('equipment_status.html')
return template.render(data)
@http.route('/roke/equipment/search', type='json', methods=['POST', 'OPTIONS'], auth="none", csrf=False,
cors='*')
def search_equipment(self):
"""
根据 plant_id category_id 查询设备(JSON POST)
请求示例:
{
"plant_name": ,
"category_name":
}
"""
# 获取请求数据
data = http.request.jsonrequest
plant_name = data.get('plant_name')
category_name = data.get('category_name')
data_acquisition_code = data.get('data_acquisition_code')
domain = []
if data_acquisition_code:
domain.append(('data_acquisition_code', 'in', data_acquisition_code))
# 构建查询条件
if plant_name:
domain.append(('plant_id.name', '=', plant_name))
if category_name:
domain.append(('category_id.name', '=', category_name))
if not domain:
return {
"state": "error",
"msgs": "参数不全;车间和 设备类别不能同时为空",
"data": []
}
# 查询设备
equipments = http.request.env['roke.mes.equipment'].sudo().search(domain)
# 构造响应数据
equipment_list = [{
'id': eq.id,
'device_name': eq.name,
'device_code': eq.code,
'data_acquisition_code': eq.data_acquisition_code,
'category': eq.category_id.name if eq.category_id else '',
'plant_name': eq.plant_id.name if eq.plant_id else '',
} for eq in equipments]
return {
'status': 'success',
'code': 200,
'data': equipment_list
}
<odoo> <odoo>
<data> <data>
<!-- explicit list view definition --> <record id="view_dws_inherit_roke_mes_equipment_tht_form" model="ir.ui.view">
<!-- <field name="name">view_dws_inherit_roke_mes_equipment_tht_form</field>
<record model="ir.ui.view" id="tht_project.list"> <field name="model">roke.mes.equipment</field>
<field name="name">tht_project list</field> <field name="inherit_id" ref="roke_workstation_api.view_dws_inherit_roke_mes_equipment_form"/>
<field name="model">tht_project.tht_project</field> <field name="arch" type="xml">
<field name="arch" type="xml"> <xpath expr="//field[@name='workshop_id']" position="after">
<tree> <field name="data_acquisition_code"/>
<field name="name"/> </xpath>
<field name="value"/> </field>
<field name="value2"/> </record>
</tree> <record id="view_roke_mes_equipment_tree_tht" model="ir.ui.view">
</field> <field name="name">view_roke_mes_equipment_tree_tht</field>
</record> <field name="model">roke.mes.equipment</field>
--> <field name="inherit_id" ref="roke_mes_equipment.view_roke_mes_equipment_tree"/>
<field name="arch" type="xml">
<!-- actions opening views on models --> <xpath expr="//field[@name='name']" position="after">
<!-- <field name="data_acquisition_code"/>
<record model="ir.actions.act_window" id="tht_project.action_window"> </xpath>
<field name="name">tht_project window</field> <xpath expr="//field[@name='code']" position="attributes">
<field name="res_model">tht_project.tht_project</field> <attribute name="string">三色灯编号</attribute>
<field name="view_mode">tree,form</field> </xpath>
</record> </field>
--> </record>
<!-- server action to the one above -->
<!--
<record model="ir.actions.server" id="tht_project.action_server">
<field name="name">tht_project server</field>
<field name="model_id" ref="model_tht_project_tht_project"/>
<field name="state">code</field>
<field name="code">
action = {
"type": "ir.actions.act_window",
"view_mode": "tree,form",
"res_model": model._name,
}
</field>
</record>
-->
<!-- Top menu item -->
<!--
<menuitem name="tht_project" id="tht_project.menu_root"/>
-->
<!-- menu categories -->
<!--
<menuitem name="Menu 1" id="tht_project.menu_1" parent="tht_project.menu_root"/>
<menuitem name="Menu 2" id="tht_project.menu_2" parent="tht_project.menu_root"/>
-->
<!-- actions -->
<!--
<menuitem name="List" id="tht_project.menu_1_list" parent="tht_project.menu_1"
action="tht_project.action_window"/>
<menuitem name="Server to list" id="tht_project" parent="tht_project.menu_2"
action="tht_project.action_server"/>
-->
</data> </data>
</odoo> </odoo>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment