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
82b26169
Commit
82b26169
authored
Jan 20, 2025
by
夏超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] 子母任务修正
parent
7a97a33e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
sdddl_project/models/inherit_production_task.py
+13
-25
No files found.
sdddl_project/models/inherit_production_task.py
View file @
82b26169
...
@@ -11,7 +11,7 @@ from odoo.exceptions import ValidationError
...
@@ -11,7 +11,7 @@ from odoo.exceptions import ValidationError
class
InheritProductionTask
(
models
.
Model
):
class
InheritProductionTask
(
models
.
Model
):
_inherit
=
"roke.production.task"
_inherit
=
"roke.production.task"
_order
=
"main_task_code desc,
id
"
_order
=
"main_task_code desc,
code asc
"
file_ids
=
fields
.
Many2many
(
"ir.attachment"
,
"roke_production_task_ir_attachment"
,
"pro_id"
,
"att_id"
)
file_ids
=
fields
.
Many2many
(
"ir.attachment"
,
"roke_production_task_ir_attachment"
,
"pro_id"
,
"att_id"
)
...
@@ -19,41 +19,29 @@ class InheritProductionTask(models.Model):
...
@@ -19,41 +19,29 @@ class InheritProductionTask(models.Model):
task_type
=
fields
.
Selection
([
task_type
=
fields
.
Selection
([
(
'main'
,
'主任务'
),
(
'main'
,
'主任务'
),
(
'sub'
,
'子任务'
),
(
'sub'
,
'子任务'
)
(
'repair'
,
'返修任务'
),
],
string
=
'任务类型'
,
compute
=
'_compute_task_type'
)
(
'replenish'
,
'补件任务'
)
],
string
=
'任务类型'
,
compute
=
'_compute_task_type'
,
store
=
True
)
main_task_code
=
fields
.
Char
(
string
=
'主任务编号'
,
compute
=
'_compute_main_task_code'
,
store
=
True
,
index
=
True
)
main_task_code
=
fields
.
Char
(
string
=
'主任务编号'
,
compute
=
'_compute_main_task_code'
,
index
=
True
)
@api.depends
(
'work_order_ids'
)
@api.depends
(
'work_order_ids'
)
def
_compute_work_order_hours
(
self
):
def
_compute_work_order_hours
(
self
):
for
record
in
self
:
for
record
in
self
:
record
.
work_order_hours
=
sum
(
record
.
work_order_ids
.
mapped
(
"work_hours"
))
record
.
work_order_hours
=
sum
(
record
.
work_order_ids
.
mapped
(
"work_hours"
))
@api.depends
(
'
parent_id'
,
'typ
e'
)
@api.depends
(
'
cod
e'
)
def
_compute_task_type
(
self
):
def
_compute_task_type
(
self
):
for
record
in
self
:
for
record
in
self
:
if
record
.
type
==
'返修'
:
if
'-'
in
(
record
.
code
or
""
):
record
.
task_type
=
'repair'
task_str
=
record
.
code
.
split
(
'-'
)
elif
record
.
type
==
'补件'
:
if
task_str
[
-
1
]
==
"1"
:
record
.
task_type
=
'replenish'
record
.
task_type
=
'main'
elif
record
.
parent_id
:
record
.
main_task_code
=
task_str
[
0
]
record
.
task_type
=
'sub'
else
:
record
.
task_type
=
'sub'
record
.
main_task_code
=
task_str
[
0
]
else
:
else
:
record
.
task_type
=
'main'
record
.
task_type
=
'main'
@api.depends
(
'task_type'
,
'code'
,
'parent_id'
)
def
_compute_main_task_code
(
self
):
for
record
in
self
:
# 对于子任务、返修任务和补件任务,获取主任务的编号
if
record
.
type
==
"返修"
:
record
.
main_task_code
=
record
.
repair_order_id
.
wr_id
.
work_order_id
.
task_id
.
code
elif
record
.
type
==
'补件'
:
record
.
main_task_code
=
record
.
scrap_order_id
.
wr_id
.
work_order_id
.
task_id
.
code
elif
record
.
parent_id
:
record
.
main_task_code
=
record
.
parent_id
.
code
else
:
record
.
main_task_code
=
record
.
code
record
.
main_task_code
=
record
.
code
def
write
(
self
,
vals
):
def
write
(
self
,
vals
):
...
...
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