Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
b042c5df
Commit
b042c5df
authored
Sep 18, 2019
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_production_planning: use cell id to get resource,date is wrong
parent
f13738a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
48 deletions
+49
-48
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_applyChange.py
...rp5_production_planning/ProductionPlanning_applyChange.py
+49
-48
No files found.
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_applyChange.py
View file @
b042c5df
...
...
@@ -2,55 +2,56 @@ from DateTime import DateTime
from
Products.ERP5Type.DateUtils
import
addToDate
portal
=
context
.
getPortalObject
()
line_list
,
column_list
=
context
.
ProductionPlanning_getCellRange
()
line_id_list
=
[
x
[
0
]
for
x
in
line_list
]
column_id_list
=
[
x
[
0
]
for
x
in
column_list
]
created_production_order_dict
=
{}
for
cell
in
context
.
getCellValueList
():
production_order_line
=
cell
.
getSpecialiseValue
()
if
production_order_line
:
if
production_order_line
.
getQuantity
()
!=
cell
.
getQuantity
():
production_order_line
.
edit
(
quantity
=
cell
.
getQuantity
())
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Modified by production planning %s'
%
context
.
getRelativeUrl
())
else
:
# It's a new cell, create producton order&production order line
[
_
,
line_index
,
column_index
]
=
cell
.
getId
().
split
(
'_'
)
resource_uid
=
line_id_list
[
int
(
line_index
)]
start_date
=
column_id_list
[
int
(
column_index
)]
# Check if it existes a production order for the date
kw
=
{
'portal_type'
:
'Production Order'
,
'delivery.start_date'
:
{
'query'
:
start_date
,
'type'
:
'date'
}
}
production_order_list
=
portal
.
portal_catalog
(
**
kw
)
if
len
(
production_order_list
):
production_order
=
production_order_list
[
0
]
else
:
# Search in the new created dict
if
start_date
in
created_production_order_dict
:
production_order
=
created_production_order_dict
[
start_date
]
for
cell_keys
in
context
.
getCellKeys
():
cell_id
=
context
.
keyToId
(
cell_keys
)
if
cell_id
is
not
None
:
cell
=
context
.
get
(
cell_id
)
if
cell
is
not
None
:
production_order_line
=
cell
.
getSpecialiseValue
()
if
production_order_line
:
if
production_order_line
.
getQuantity
()
!=
cell
.
getQuantity
():
production_order_line
.
edit
(
quantity
=
cell
.
getQuantity
())
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Modified by production planning %s'
%
context
.
getRelativeUrl
())
else
:
production_order
=
portal
.
production_order_module
.
newContent
(
portal_type
=
'Production Order'
,
start_date
=
DateTime
(
start_date
),
stop_date
=
addToDate
(
DateTime
(
start_date
),
{
'day'
:
2
}),
destination
=
'organisation_module/test_psa_jv'
,
destination_section
=
'organisation_module/test_psa_jv'
)
production_order
.
autoPlan
()
created_production_order_dict
[
start_date
]
=
production_order
# Add new production order line for resource
production_order_line
=
production_order
.
newContent
(
portal_type
=
'Production Order Line'
,
resource_uid
=
resource_uid
,
quantity
=
cell
.
getQuantity
())
cell
.
edit
(
specialise_value
=
production_order_line
)
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Added by production planning %s'
%
context
.
getRelativeUrl
())
# It's a new cell, create producton order&production order line
[
resource_uid
,
start_date
]
=
cell_keys
# Check if it existes a production order for the date
kw
=
{
'portal_type'
:
'Production Order'
,
'delivery.start_date'
:
{
'query'
:
start_date
,
'type'
:
'date'
}
}
production_order_list
=
portal
.
portal_catalog
(
**
kw
)
if
len
(
production_order_list
):
production_order
=
production_order_list
[
0
]
else
:
# Search in the new created dict
if
start_date
in
created_production_order_dict
:
production_order
=
created_production_order_dict
[
start_date
]
else
:
production_order
=
portal
.
production_order_module
.
newContent
(
portal_type
=
'Production Order'
,
start_date
=
DateTime
(
start_date
),
stop_date
=
addToDate
(
DateTime
(
start_date
),
{
'day'
:
2
}),
destination
=
'organisation_module/test_psa_jv'
,
destination_section
=
'organisation_module/test_psa_jv'
)
production_order
.
autoPlan
()
created_production_order_dict
[
start_date
]
=
production_order
# Add new production order line for resource
production_order_line
=
production_order
.
newContent
(
portal_type
=
'Production Order Line'
,
resource_uid
=
resource_uid
,
quantity
=
cell
.
getQuantity
())
cell
.
edit
(
specialise_value
=
production_order_line
)
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Added by production planning %s'
%
context
.
getRelativeUrl
())
if
portal
.
portal_workflow
.
isTransitionPossible
(
context
,
'record'
):
context
.
record
()
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