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
842418b8
Commit
842418b8
authored
May 23, 2025
by
柏宁宁
Browse files
Options
Browse Files
Download
Plain Diff
合并分支 'tht' 到 'tht-project'
添加筛选以及接口 查看合并请求
!11
parents
73acc600
3a0cf43b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
73 deletions
+101
-73
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
+18
-52
No files found.
tht_project/__manifest__.py
View file @
842418b8
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
'version'
:
'0.1'
,
'version'
:
'0.1'
,
# any module necessary for this one to work correctly
# any module necessary for this one to work correctly
'depends'
:
[
'
base
'
],
'depends'
:
[
'
roke_mes_three_colour_light
'
],
# always loaded
# always loaded
'data'
:
[
'data'
:
[
...
...
tht_project/controllers/controllers.py
View file @
842418b8
# -*- 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
}
tht_project/static/src/view/equipment_status.html
0 → 100644
View file @
842418b8
This diff is collapsed.
Click to expand it.
tht_project/views/views.xml
View file @
842418b8
<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"
>
<tree>
<xpath
expr=
"//field[@name='workshop_id']"
position=
"after"
>
<field name="name"/>
<field
name=
"data_acquisition_code"
/>
<field name="value"/>
</xpath>
<field name="value2"/>
</tree>
</field>
</field>
</record>
</record>
-->
<record
id=
"view_roke_mes_equipment_tree_tht"
model=
"ir.ui.view"
>
<field
name=
"name"
>
view_roke_mes_equipment_tree_tht
</field>
<!-- actions opening views on models -->
<field
name=
"model"
>
roke.mes.equipment
</field>
<!--
<field
name=
"inherit_id"
ref=
"roke_mes_equipment.view_roke_mes_equipment_tree"
/>
<record model="ir.actions.act_window" id="tht_project.action_window">
<field
name=
"arch"
type=
"xml"
>
<field name="name">tht_project window</field>
<xpath
expr=
"//field[@name='name']"
position=
"after"
>
<field name="res_model">tht_project.tht_project</field>
<field
name=
"data_acquisition_code"
/>
<field name="view_mode">tree,form</field>
</xpath>
</record>
<xpath
expr=
"//field[@name='code']"
position=
"attributes"
>
-->
<attribute
name=
"string"
>
三色灯编号
</attribute>
</xpath>
<!-- 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>
</field>
</record>
</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
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