Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dwsproject
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dws
dwsproject
Commits
3a0cf43b
Commit
3a0cf43b
authored
May 23, 2025
by
nningxx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加筛选以及接口
parent
73acc600
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
77 deletions
+107
-77
tht_project/__manifest__.py
+1
-1
tht_project/controllers/controllers.py
+82
-20
tht_project/static/src/view/equipment_status.html
+0
-0
tht_project/views/views.xml
+24
-56
No files found.
tht_project/__manifest__.py
View file @
3a0cf43b
...
...
@@ -20,7 +20,7 @@
'version'
:
'0.1'
,
# any module necessary for this one to work correctly
'depends'
:
[
'
base
'
],
'depends'
:
[
'
roke_mes_three_colour_light
'
],
# always loaded
'data'
:
[
...
...
tht_project/controllers/controllers.py
View file @
3a0cf43b
# -*- coding: utf-8 -*-
# from odoo import http
# class ThtProject(http.Controller):
# @http.route('/tht_project/tht_project/', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/tht_project/tht_project/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('tht_project.listing', {
# 'root': '/tht_project/tht_project',
# 'objects': http.request.env['tht_project.tht_project'].search([]),
# })
# @http.route('/tht_project/tht_project/objects/<model("tht_project.tht_project"):obj>/', auth='public')
# def object(self, obj, **kw):
# return http.request.render('tht_project.object', {
# 'object': obj
# })
from
odoo
import
http
from
odoo.http
import
request
from
odoo.addons.roke_mes_three_colour_light.controller.main
import
RokeMesThreeColourLight
import
os
from
jinja2
import
Environment
,
FileSystemLoader
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
templateloader
=
FileSystemLoader
(
searchpath
=
BASE_DIR
+
"/static/src/view"
)
env
=
Environment
(
loader
=
templateloader
)
class
RokeMesThreeColourLightExt
(
RokeMesThreeColourLight
):
#重写
@http.route
(
"/roke/three_color_light/device_state_list"
,
type
=
"http"
,
auth
=
'none'
,
cors
=
'*'
,
csrf
=
False
)
def
device_state_list
(
self
,
**
kwargs
):
# 自定义逻辑
_self
=
request
factory_code
=
"custom_factory_code_123"
# 自定义 factory_code
data
=
{
"code"
:
1
,
"message"
:
"请求通过"
,
"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
}
tht_project/static/src/view/equipment_status.html
0 → 100644
View file @
3a0cf43b
This diff is collapsed.
Click to expand it.
tht_project/views/views.xml
View file @
3a0cf43b
<odoo>
<data>
<!-- explicit list view definition -->
<!--
<record model="ir.ui.view" id="tht_project.list">
<field name="name">tht_project list</field>
<field name="model">tht_project.tht_project</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="value"/>
<field name="value2"/>
</tree>
</field>
</record>
-->
<!-- actions opening views on models -->
<!--
<record model="ir.actions.act_window" id="tht_project.action_window">
<field name="name">tht_project window</field>
<field name="res_model">tht_project.tht_project</field>
<field name="view_mode">tree,form</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"/>
-->
<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>
<field
name=
"model"
>
roke.mes.equipment
</field>
<field
name=
"inherit_id"
ref=
"roke_workstation_api.view_dws_inherit_roke_mes_equipment_form"
/>
<field
name=
"arch"
type=
"xml"
>
<xpath
expr=
"//field[@name='workshop_id']"
position=
"after"
>
<field
name=
"data_acquisition_code"
/>
</xpath>
</field>
</record>
<record
id=
"view_roke_mes_equipment_tree_tht"
model=
"ir.ui.view"
>
<field
name=
"name"
>
view_roke_mes_equipment_tree_tht
</field>
<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"
>
<xpath
expr=
"//field[@name='name']"
position=
"after"
>
<field
name=
"data_acquisition_code"
/>
</xpath>
<xpath
expr=
"//field[@name='code']"
position=
"attributes"
>
<attribute
name=
"string"
>
三色灯编号
</attribute>
</xpath>
</field>
</record>
</data>
</odoo>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment