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
47dd3e8c
Commit
47dd3e8c
authored
Dec 05, 2024
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_production_planning: Move rendering and applying to skin folder for customization per project
parent
32daa656
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
249 additions
and
111 deletions
+249
-111
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_applyProductionPlanning.py
...on_planning/ProductionPlanning_applyProductionPlanning.py
+68
-0
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_applyProductionPlanning.xml
...n_planning/ProductionPlanning_applyProductionPlanning.xml
+62
-0
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_renderProductionPlanning.py
...n_planning/ProductionPlanning_renderProductionPlanning.py
+43
-0
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_renderProductionPlanning.xml
..._planning/ProductionPlanning_renderProductionPlanning.xml
+62
-0
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_applyProductionPlanningChanges.py
...ript_ProductionPlanning_applyProductionPlanningChanges.py
+1
-68
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_applyProductionPlanningChanges.xml
...ipt_ProductionPlanning_applyProductionPlanningChanges.xml
+6
-0
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_renderProductionPlanningStatus.py
...ript_ProductionPlanning_renderProductionPlanningStatus.py
+1
-43
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_renderProductionPlanningStatus.xml
...ipt_ProductionPlanning_renderProductionPlanningStatus.xml
+6
-0
No files found.
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_applyProductionPlanning.py
0 → 100644
View file @
47dd3e8c
from
DateTime
import
DateTime
from
erp5.component.module.DateUtils
import
addToDate
production_planning
=
context
portal
=
production_planning
.
getPortalObject
()
created_production_order_dict
=
{}
keyToId
=
production_planning
.
keyToId
get_cell
=
production_planning
.
get
relative_url
=
production_planning
.
getRelativeUrl
()
catalog_method
=
portal
.
portal_catalog
for
cell_keys
in
production_planning
.
getCellKeys
():
cell_id
=
keyToId
(
cell_keys
)
if
cell_id
is
not
None
:
cell
=
get_cell
(
cell_id
)
if
cell
is
not
None
:
cell_quantity
=
cell
.
getQuantity
()
production_order_line
=
cell
.
getSpecialiseValue
()
if
production_order_line
:
if
production_order_line
.
getQuantity
()
!=
cell_quantity
:
production_order_line
.
edit
(
quantity
=
cell_quantity
)
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Modified by production planning %s'
%
relative_url
)
elif
cell_quantity
:
# 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'
},
'simulation_state'
:
(
'planned'
,
'auto_planned'
)
}
production_order_list
=
catalog_method
(
**
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/psa_jv'
,
destination_section
=
'organisation_module/psa_jv'
)
production_order
.
plan
()
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_quantity
)
cell
.
edit
(
specialise_value
=
production_order_line
,
related_url
=
production_order
.
getAbsoluteUrl
()
)
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Added by production planning %s'
%
relative_url
)
if
portal
.
portal_workflow
.
isTransitionPossible
(
production_planning
,
'apply'
):
production_planning
.
apply
()
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_applyProductionPlanning.xml
0 → 100644
View file @
47dd3e8c
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ProductionPlanning_applyProductionPlanning
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_renderProductionPlanning.py
0 → 100644
View file @
47dd3e8c
from
DateTime
import
DateTime
from
erp5.component.module.DateUtils
import
addToDate
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
ComplexQuery
production_planning
=
context
portal
=
production_planning
.
getPortalObject
()
line_list
,
column_list
=
production_planning
.
ProductionPlanning_getCellRange
()
line_ids
=
map
(
lambda
x
:
x
[
0
],
line_list
)
column_ids
=
map
(
lambda
x
:
x
[
0
],
column_list
)
production_planning
.
setCellRange
(
line_ids
,
column_ids
,
base_id
=
'cell'
)
start_date
=
DateTime
(
column_list
[
0
][
0
])
stop_date
=
addToDate
(
DateTime
(
column_list
[
-
1
][
0
]),
{
'day'
:
1
})
for
product
in
portal
.
portal_catalog
(
portal_type
=
'Product'
,
product_line_relative_url
=
'product_line/car'
):
product_uid
=
product
.
getUid
()
query_list
=
[
Query
(
portal_type
=
'Production Order'
),
Query
(
simulation_state
=
(
'planned'
,
'auto_planned'
)),
Query
(
child_resource_uid
=
product_uid
),
ComplexQuery
(
Query
(
**
{
'delivery.start_date'
:
{
'query'
:
stop_date
,
'range'
:
'<='
}}),
Query
(
**
{
'delivery.start_date'
:
{
'query'
:
start_date
,
'range'
:
'>='
}}),
logical_operator
=
'AND'
)
]
production_order_list
=
portal
.
portal_catalog
(
query
=
ComplexQuery
(
logical_operator
=
'AND'
,
*
query_list
))
line
=
int
(
product_uid
)
kd
=
{
'portal_type'
:
'Production Planning Cell'
,
'base_id'
:
'cell'
}
for
production_order
in
production_order_list
:
column
=
'%s'
%
production_order
.
getStartDate
().
Date
()
related_url
=
production_order
.
getAbsoluteUrl
()
for
production_order_line
in
production_order
.
searchFolder
(
portal_type
=
'Production Order Line'
,
strict_resource_uid
=
product_uid
):
k
=
(
line
,
column
)
if
not
production_planning
.
hasInRange
(
*
k
,
**
kd
):
production_planning
.
log
(
'Waring: Production order date %s is not in range which should not be, need to check'
%
start_date
)
if
not
production_planning
.
hasCell
(
*
k
,
**
kd
):
new_cell
=
production_planning
.
newCell
(
*
k
,
**
kd
)
quantity
=
production_order_line
.
getQuantity
()
new_cell
.
edit
(
quantity
=
quantity
,
default_quantity
=
quantity
,
related_url
=
related_url
,
specialise_value
=
production_order_line
)
production_planning
.
record
()
bt5/erp5_production_planning/SkinTemplateItem/portal_skins/erp5_production_planning/ProductionPlanning_renderProductionPlanning.xml
0 → 100644
View file @
47dd3e8c
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ProductionPlanning_renderProductionPlanning
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_applyProductionPlanningChanges.py
View file @
47dd3e8c
from
DateTime
import
DateTime
state_change
[
'object'
].
ProductionPlanning_applyProductionPlanning
()
from
erp5.component.module.DateUtils
import
addToDate
production_planning
=
state_change
[
'object'
]
portal
=
production_planning
.
getPortalObject
()
created_production_order_dict
=
{}
keyToId
=
production_planning
.
keyToId
get_cell
=
production_planning
.
get
relative_url
=
production_planning
.
getRelativeUrl
()
catalog_method
=
portal
.
portal_catalog
for
cell_keys
in
production_planning
.
getCellKeys
():
cell_id
=
keyToId
(
cell_keys
)
if
cell_id
is
not
None
:
cell
=
get_cell
(
cell_id
)
if
cell
is
not
None
:
cell_quantity
=
cell
.
getQuantity
()
production_order_line
=
cell
.
getSpecialiseValue
()
if
production_order_line
:
if
production_order_line
.
getQuantity
()
!=
cell_quantity
:
production_order_line
.
edit
(
quantity
=
cell_quantity
)
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Modified by production planning %s'
%
relative_url
)
elif
cell_quantity
:
# 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'
},
'simulation_state'
:
(
'planned'
,
'auto_planned'
)
}
production_order_list
=
catalog_method
(
**
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/psa_jv'
,
destination_section
=
'organisation_module/psa_jv'
)
production_order
.
plan
()
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_quantity
)
cell
.
edit
(
specialise_value
=
production_order_line
,
related_url
=
production_order
.
getAbsoluteUrl
()
)
portal
.
portal_workflow
.
doActionFor
(
production_order_line
,
"edit_action"
,
comment
=
'Added by production planning %s'
%
relative_url
)
if
portal
.
portal_workflow
.
isTransitionPossible
(
production_planning
,
'apply'
):
production_planning
.
apply
()
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_applyProductionPlanningChanges.xml
View file @
47dd3e8c
...
@@ -60,6 +60,12 @@
...
@@ -60,6 +60,12 @@
</tuple>
</tuple>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
script_ProductionPlanning_applyProductionPlanningChanges
</string>
</value>
<value>
<string>
script_ProductionPlanning_applyProductionPlanningChanges
</string>
</value>
...
...
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_renderProductionPlanningStatus.py
View file @
47dd3e8c
from
DateTime
import
DateTime
state_change
[
'object'
].
ProductionPlanning_renderProductionPlanning
()
from
erp5.component.module.DateUtils
import
addToDate
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
ComplexQuery
production_planning
=
state_change
[
'object'
]
portal
=
production_planning
.
getPortalObject
()
line_list
,
column_list
=
production_planning
.
ProductionPlanning_getCellRange
()
line_ids
=
map
(
lambda
x
:
x
[
0
],
line_list
)
column_ids
=
map
(
lambda
x
:
x
[
0
],
column_list
)
production_planning
.
setCellRange
(
line_ids
,
column_ids
,
base_id
=
'cell'
)
start_date
=
DateTime
(
column_list
[
0
][
0
])
stop_date
=
addToDate
(
DateTime
(
column_list
[
-
1
][
0
]),
{
'day'
:
1
})
for
product
in
portal
.
portal_catalog
(
portal_type
=
'Product'
,
product_line_relative_url
=
'product_line/car'
):
product_uid
=
product
.
getUid
()
query_list
=
[
Query
(
portal_type
=
'Production Order'
),
Query
(
simulation_state
=
(
'planned'
,
'auto_planned'
)),
Query
(
child_resource_uid
=
product_uid
),
ComplexQuery
(
Query
(
**
{
'delivery.start_date'
:
{
'query'
:
stop_date
,
'range'
:
'<='
}}),
Query
(
**
{
'delivery.start_date'
:
{
'query'
:
start_date
,
'range'
:
'>='
}}),
logical_operator
=
'AND'
)
]
production_order_list
=
portal
.
portal_catalog
(
query
=
ComplexQuery
(
logical_operator
=
'AND'
,
*
query_list
))
line
=
int
(
product_uid
)
kd
=
{
'portal_type'
:
'Production Planning Cell'
,
'base_id'
:
'cell'
}
for
production_order
in
production_order_list
:
column
=
'%s'
%
production_order
.
getStartDate
().
Date
()
related_url
=
production_order
.
getAbsoluteUrl
()
for
production_order_line
in
production_order
.
searchFolder
(
portal_type
=
'Production Order Line'
,
strict_resource_uid
=
product_uid
):
k
=
(
line
,
column
)
if
not
production_planning
.
hasInRange
(
*
k
,
**
kd
):
production_planning
.
log
(
'Waring: Production order date %s is not in range which should not be, need to check'
%
start_date
)
if
not
production_planning
.
hasCell
(
*
k
,
**
kd
):
new_cell
=
production_planning
.
newCell
(
*
k
,
**
kd
)
quantity
=
production_order_line
.
getQuantity
()
new_cell
.
edit
(
quantity
=
quantity
,
default_quantity
=
quantity
,
related_url
=
related_url
,
specialise_value
=
production_order_line
)
production_planning
.
record
()
bt5/erp5_production_planning/WorkflowTemplateItem/portal_workflow/production_planning_interaction_workflow/script_ProductionPlanning_renderProductionPlanningStatus.xml
View file @
47dd3e8c
...
@@ -60,6 +60,12 @@
...
@@ -60,6 +60,12 @@
</tuple>
</tuple>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
script_ProductionPlanning_renderProductionPlanningStatus
</string>
</value>
<value>
<string>
script_ProductionPlanning_renderProductionPlanningStatus
</string>
</value>
...
...
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