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
b01aa992
Commit
b01aa992
authored
Jan 10, 2025
by
夏超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] 修改工位机获取工单数据接口
parent
c033816b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
2 deletions
+134
-2
sdddl_project/controllers/inherit_production_task.py
+134
-2
No files found.
sdddl_project/controllers/inherit_production_task.py
View file @
b01aa992
import
logging
import
pytz
from
odoo
import
models
,
fields
,
api
,
http
,
SUPERUSER_ID
,
_
from
odoo.addons.roke_workstation_api.controllers.product_task
import
RokeWorkstationProductionTask
from
odoo.addons.roke_workstation_api.controllers.work_order
import
RokeWorkstationWorkOrder
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -185,4 +187,135 @@ class InheritRokeWorkstationProductionTask(RokeWorkstationProductionTask):
if
not
work_data
:
continue
data
.
append
(
work_data
)
return
{
"code"
:
0
,
"message"
:
"获取成功!"
,
"data"
:
data
,
"process_ids"
:
process_list
,
"count"
:
task_count
}
\ No newline at end of file
return
{
"code"
:
0
,
"message"
:
"获取成功!"
,
"data"
:
data
,
"process_ids"
:
process_list
,
"count"
:
task_count
}
class
InheritRokeWorkstationWorkOrder
(
RokeWorkstationWorkOrder
):
@http.route
(
'/roke/workstation/work_order/workstation_work_order'
,
type
=
'json'
,
auth
=
'user'
,
csrf
=
False
,
cors
=
"*"
)
def
workstation_work_order
(
self
):
"""
获取当前任务下对应工序的未完成的第一位列的工单的数据
workstation_id: int 工位ID
limit: int 条数
page: int 页数
"""
_self
=
http
.
request
task_id
=
_self
.
jsonrequest
.
get
(
"task_id"
,
False
)
work_order_id
=
_self
.
jsonrequest
.
get
(
"work_order_id"
,
False
)
work_center_id
=
_self
.
jsonrequest
.
get
(
"work_center_id"
,
False
)
process_ids
=
_self
.
jsonrequest
.
get
(
"process_ids"
,
[])
if
not
task_id
:
return
{
"code"
:
1
,
"message"
:
f
"入参错误! “任务ID”为必传数据。"
,
"data"
:
{}}
if
not
process_ids
:
return
{
"code"
:
1
,
"message"
:
f
"入参错误! “工序列表”为必传数据。"
,
"data"
:
{}}
if
not
work_center_id
:
return
{
"code"
:
1
,
"message"
:
f
"入参错误! “工位ID”为必传数据。"
,
"data"
:
{}}
domain
=
[
"|"
,
"&"
,
"&"
,
"&"
,
(
"task_id"
,
"="
,
task_id
),
(
"process_id"
,
"in"
,
process_ids
),
(
"state"
,
"in"
,
[
"未完工"
,
"暂停"
]),
(
"work_center_id"
,
"="
,
False
),
(
"work_center_id"
,
"="
,
work_center_id
)
]
if
work_order_id
:
domain
=
[(
"id"
,
"="
,
work_order_id
)]
work_order
=
_self
.
env
[
"roke.work.order"
]
.
search
(
domain
,
order
=
f
"sequence asc, process_id asc, id asc"
,
limit
=
1
)
if
not
work_order
:
return
{
"code"
:
1
,
"message"
:
"数据获取失败!"
,
"data"
:
{}}
allow_qty
,
_
=
work_order
.
_get_wo_allow_qty
()
user_tz
=
pytz
.
timezone
(
_self
.
env
.
context
.
get
(
'tz'
,
"Asia/Shanghai"
))
operation_after_completion
=
_self
.
env
(
user
=
SUPERUSER_ID
)[
'ir.config_parameter'
]
.
get_param
(
'operation.after.completion'
,
default
=
"无操作"
)
print_code
=
False
if
operation_after_completion
==
"打印批次条码"
:
print_code
=
True
data
=
{
"id"
:
work_order
.
id
,
"task_id"
:
work_order
.
task_id
.
id
,
"code"
:
work_order
.
code
,
"type"
:
work_order
.
type
or
""
,
"state"
:
work_order
.
state
,
"allow_qty"
:
allow_qty
,
"wo_start_state"
:
work_order
.
wo_start_state
,
"process_id"
:
work_order
.
process_id
.
id
,
"process"
:
{
"id"
:
work_order
.
process_id
.
id
or
0
,
"name"
:
work_order
.
process_id
.
name
or
""
},
"partner"
:
{
"id"
:
work_order
.
customer_id
.
id
or
None
,
"name"
:
work_order
.
customer_id
.
name
or
""
},
"plan_qty"
:
work_order
.
plan_qty
or
0
,
"product"
:
{
"id"
:
work_order
.
product_id
.
id
or
None
,
"name"
:
work_order
.
product_id
.
name
or
""
},
"priority"
:
work_order
.
priority
,
"finish_qty"
:
work_order
.
finish_qty
,
"unqualified_qty"
:
work_order
.
unqualified_qty
,
"routing_id"
:
work_order
.
task_id
.
routing_id
.
id
or
work_order
.
product_id
.
routing_id
.
id
,
"routing_line_id"
:
work_order
.
routing_line_id
.
id
or
0
,
"planned_start_time"
:
pytz
.
utc
.
localize
(
work_order
.
planned_start_time
)
.
astimezone
(
user_tz
)
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
if
work_order
.
planned_start_time
else
""
,
"plan_date"
:
pytz
.
utc
.
localize
(
work_order
.
plan_date
)
.
astimezone
(
user_tz
)
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
if
work_order
.
plan_date
else
""
,
# UI 判断信息
"track_type"
:
work_order
.
task_id
.
track_type
,
"enable_traceability"
:
work_order
.
product_id
.
enable_traceability
,
"traceability_strategy"
:
work_order
.
product_id
.
traceability_strategy
,
"is_passing_report"
:
work_order
.
workshop_id
.
is_passing_report
,
"print_code"
:
print_code
,
# 补充信息
"specification"
:
work_order
.
product_id
.
specification
or
""
,
"complete_basis"
:
http
.
request
.
env
.
company
.
complete_basis
or
""
,
# 物料批次码
"lot_code_id"
:
work_order
.
task_id
.
code_ids
[
0
]
.
id
if
work_order
.
task_id
.
code_ids
else
False
,
}
if
work_order
.
product_id
.
traceability_strategy
==
"物料防错"
:
data
[
"material_demands"
]
=
[
{
"id"
:
line
.
material_id
.
id
,
"name"
:
line
.
material_id
.
name
,
"code"
:
line
.
material_id
.
code
,
"demand_qty"
:
line
.
demand_qty
,
"finished_qty"
:
line
.
finished_qty
,
"protection_code"
:
line
.
protection_code
or
""
,
}
for
line
in
work_order
.
material_demand_ids
]
if
not
work_order_id
or
not
work_order
:
return
{
"code"
:
0
,
"message"
:
"获取成功!"
,
"data"
:
data
}
if
work_order
.
type
==
"返修"
:
repair_order_line
=
_self
.
env
[
"roke.repair.order.line"
]
.
search
([
(
"repair_work_order_id"
,
"="
,
work_order
.
id
)
],
limit
=
1
)
if
repair_order_line
:
repair_work_order
=
work_order
.
repair_wr_id
.
work_order_id
data
.
update
({
"routing_id"
:
repair_work_order
.
task_id
.
routing_id
.
id
,
"routing_line_id"
:
repair_work_order
.
routing_line_id
.
id
,
"partner"
:
{
"id"
:
repair_work_order
.
task_id
.
customer_id
.
id
or
None
,
"name"
:
repair_work_order
.
task_id
.
customer_id
.
name
or
""
},
"lot_code_id"
:
repair_work_order
.
task_id
.
code_ids
[
0
]
.
id
if
repair_work_order
.
task_id
.
code_ids
else
False
})
elif
work_order
.
type
==
"补件"
:
scrap_order_line
=
_self
.
env
[
"roke.scrap.order.line"
]
.
search
([(
"scrap_work_order_ids"
,
"="
,
work_order
.
id
)],
limit
=
1
)
if
scrap_order_line
:
task_id
=
scrap_order_line
.
order_id
.
wr_id
.
work_order_id
.
task_id
or
\
scrap_order_line
.
order_id
.
wr_id
.
work_order_id
.
repair_task_id
routing_id
=
task_id
.
routing_id
line_id
=
0
for
v
in
routing_id
.
line_ids
:
if
work_order
.
process_id
.
id
!=
v
.
process_id
.
id
:
continue
line_id
=
v
.
id
break
data
.
update
({
"routing_id"
:
routing_id
.
id
,
"routing_line_id"
:
line_id
,
"partner"
:
{
"id"
:
task_id
.
customer_id
.
id
or
None
,
"name"
:
task_id
.
customer_id
.
name
or
""
},
"lot_code_id"
:
task_id
.
code_ids
[
0
]
.
id
if
task_id
.
code_ids
else
False
})
return
{
"code"
:
0
,
"message"
:
"获取成功!"
,
"data"
:
data
}
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