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
0
Merge Requests
0
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
Noah Brackenbury
erp5
Commits
c609f284
Commit
c609f284
authored
Aug 22, 2017
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SimulationTool: Stop relying on portal_selections for SQL expression generation
parent
012908b4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
56 deletions
+65
-56
bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Resource_zGetInventoryList.sql
...al_skins/erp5_banking_core/Resource_zGetInventoryList.sql
+3
-7
bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Resource_zGetInventoryList.xml
...al_skins/erp5_banking_core/Resource_zGetInventoryList.xml
+2
-2
product/ERP5/Tool/SimulationTool.py
product/ERP5/Tool/SimulationTool.py
+31
-17
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
...tem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
+8
-7
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.xml
...tem/portal_skins/erp5_core/Resource_zGetInventoryList.xml
+2
-2
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.sql
...rtal_skins/erp5_core/Resource_zGetMovementHistoryList.sql
+7
-7
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
...rtal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
+2
-2
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetTrackingList.sql
...Item/portal_skins/erp5_core/Resource_zGetTrackingList.sql
+8
-10
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetTrackingList.xml
...Item/portal_skins/erp5_core/Resource_zGetTrackingList.xml
+2
-2
No files found.
bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Resource_zGetInventoryList.sql
View file @
c609f284
...
...
@@ -80,8 +80,7 @@ FROM
,
<
dtml
-
var
table_item
>
AS
<
dtml
-
var
table_key
>
</
dtml
-
if
>
</
dtml
-
in
>
<
dtml
-
if
selection_domain
>
,
<
dtml
-
var
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"
>
</
dtml
-
if
>
<
dtml
-
if
selection_report
>
,
<
dtml
-
var
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"
>
</
dtml
-
if
>
<
dtml
-
if
"selection_domain_from_expression"
>
,
<
dtml
-
var
"selection_domain_from_expression"
>
</
dtml
-
if
>
,
catalog
as
node
,
catalog
as
resource
<
dtml
-
if
transformed_uid
>
,
transformation
,
catalog
as
transformed_resource
</
dtml
-
if
>
WHERE
...
...
@@ -110,11 +109,8 @@ WHERE
AND
catalog
.
portal_type
!=
'Simulation Movement'
</
dtml
-
if
>
<
dtml
-
if
selection_domain
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_domain, join_table=stock_table_id, join_column='node_uid')"
>
</
dtml
-
if
>
<
dtml
-
if
selection_report
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_report, strict_membership=1)"
>
<
dtml
-
if
"selection_domain_where_expression"
>
AND
<
dtml
-
var
"selection_domain_where_expression"
>
</
dtml
-
if
>
<
dtml
-
if
convert_quantity_result
>
...
...
bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Resource_zGetInventoryList.xml
View file @
c609f284
...
...
@@ -26,9 +26,9 @@
where_expression\r\n
order_by_expression\r\n
group_by_expression\r\n
selection_domain\r\n
selection_domain_from_expression\r\n
selection_domain_where_expression\r\n
select_expression\r\n
selection_report\r\n
ignore_variation\r\n
standardize\r\n
omit_simulation\r\n
...
...
product/ERP5/Tool/SimulationTool.py
View file @
c609f284
...
...
@@ -599,6 +599,9 @@ class SimulationTool(BaseTool):
# sort_on
sort_on
=
None
,
group_by
=
None
,
# selection
selection_domain
=
None
,
selection_report
=
None
,
# keywords for related keys
**
kw
):
"""
...
...
@@ -613,6 +616,30 @@ class SimulationTool(BaseTool):
# input and output are used by getTrackingList
sql_kw
[
'input'
]
=
input
sql_kw
[
'output'
]
=
output
# selection_{domain,report}
portal
=
self
.
getPortalObject
()
if
selection_domain
is
None
:
# Short-circuit DTML missing parameter lookup by always providing these
selection_domain_sql_dict
=
{
'from_expression'
:
None
,
'where_expression'
:
None
,
}
else
:
# selection_domain has to be handled inside the ZSQLMethod as it does
# not apply to default query table (here, "stock") but to the catalog
# representing the "node". Hardcode table name to avoid calling from
# inside DTML.
selection_domain_sql_dict
=
portal
.
portal_catalog
.
buildSQLQuery
(
selection_domain
=
selection_domain
,
query_table_alias
=
'node'
,
# XXX: hard-coded value from ZSQLMethod
)
sql_kw
[
'selection_domain_from_expression'
]
=
selection_domain_sql_dict
[
'from_expression'
]
sql_kw
[
'selection_domain_where_expression'
]
=
selection_domain_sql_dict
[
'where_expression'
]
if
selection_report
is
not
None
:
new_kw
[
'selection_report'
]
=
selection_report
# BBB
sql_kw
[
'selection_domain'
]
=
sql_kw
[
'selection_report'
]
=
None
# Add sort_on parameter if defined
if
sort_on
is
not
None
:
new_kw
[
'sort_on'
]
=
sort_on
...
...
@@ -1185,7 +1212,6 @@ class SimulationTool(BaseTool):
omit_simulation
=
0
,
only_accountable
=
True
,
default_stock_table
=
'stock'
,
selection_domain
=
None
,
selection_report
=
None
,
statistic
=
0
,
inventory_list
=
1
,
precision
=
None
,
connection_id
=
None
,
**
kw
):
...
...
@@ -1266,8 +1292,6 @@ class SimulationTool(BaseTool):
'standardise'
:
standardise
,
'omit_simulation'
:
omit_simulation
,
'only_accountable'
:
only_accountable
,
'selection_domain'
:
selection_domain
,
'selection_report'
:
selection_report
,
'precision'
:
precision
,
'inventory_list'
:
inventory_list
,
'connection_id'
:
connection_id
,
...
...
@@ -1890,8 +1914,7 @@ class SimulationTool(BaseTool):
def
getInventoryHistoryList
(
self
,
src__
=
0
,
ignore_variation
=
0
,
standardise
=
0
,
omit_simulation
=
0
,
only_accountable
=
True
,
omit_input
=
0
,
omit_output
=
0
,
selection_domain
=
None
,
selection_report
=
None
,
precision
=
None
,
**
kw
):
omit_output
=
0
,
precision
=
None
,
**
kw
):
"""
Returns a time based serie of inventory values
for a single or a group of resource, node, section, etc. This is useful
...
...
@@ -1907,8 +1930,7 @@ class SimulationTool(BaseTool):
standardise
=
standardise
,
omit_simulation
=
omit_simulation
,
only_accountable
=
only_accountable
,
omit_input
=
omit_input
,
omit_output
=
omit_output
,
selection_domain
=
selection_domain
,
selection_report
=
selection_report
,
precision
=
precision
,
precision
=
precision
,
**
sql_kw
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
@@ -1917,8 +1939,7 @@ class SimulationTool(BaseTool):
standardise
=
0
,
omit_simulation
=
0
,
only_accountable
=
True
,
omit_input
=
0
,
omit_output
=
0
,
selection_domain
=
None
,
selection_report
=
None
,
precision
=
None
,
**
kw
):
precision
=
None
,
**
kw
):
"""
getInventoryHistoryChart is the pensing to getInventoryHistoryList
to ease the rendering of time based graphs which show the evolution
...
...
@@ -1933,8 +1954,7 @@ class SimulationTool(BaseTool):
standardise
=
standardise
,
omit_simulation
=
omit_simulation
,
only_accountable
=
only_accountable
,
omit_input
=
omit_input
,
omit_output
=
omit_output
,
selection_domain
=
selection_domain
,
selection_report
=
selection_report
,
precision
=
precision
,
precision
=
precision
,
**
sql_kw
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
@@ -1944,7 +1964,6 @@ class SimulationTool(BaseTool):
omit_input
=
0
,
omit_output
=
0
,
only_accountable
=
True
,
omit_asset_increase
=
0
,
omit_asset_decrease
=
0
,
selection_domain
=
None
,
selection_report
=
None
,
initial_running_total_quantity
=
0
,
initial_running_total_price
=
0
,
precision
=
None
,
**
kw
):
...
...
@@ -1972,8 +1991,6 @@ class SimulationTool(BaseTool):
omit_input
=
omit_input
,
omit_output
=
omit_output
,
omit_asset_increase
=
omit_asset_increase
,
omit_asset_decrease
=
omit_asset_decrease
,
selection_domain
=
selection_domain
,
selection_report
=
selection_report
,
initial_running_total_quantity
=
initial_running_total_quantity
,
initial_running_total_price
=
...
...
@@ -2072,7 +2089,6 @@ class SimulationTool(BaseTool):
# Traceability management
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getTrackingList'
)
def
getTrackingList
(
self
,
src__
=
0
,
selection_domain
=
None
,
selection_report
=
None
,
strict_simulation_state
=
1
,
history
=
0
,
**
kw
)
:
"""
Returns a list of items in the form
...
...
@@ -2178,8 +2194,6 @@ class SimulationTool(BaseTool):
new_kw
[
'simulation_state_list'
]
=
None
return
self
.
Resource_zGetTrackingList
(
src__
=
src__
,
selection_domain
=
selection_domain
,
selection_report
=
selection_report
,
**
new_kw
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getCurrentTrackingList'
)
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
View file @
c609f284
...
...
@@ -75,8 +75,11 @@ FROM
(
quantity_unit_conversion
.
resource_uid
=
<
dtml
-
var
stock_table_id
>
.
resource_uid
AND
quantity_unit_conversion
.
quantity_unit_uid
=
<
dtml
-
sqlvar
quantity_unit_uid
type
=
int
>
)
</
dtml
-
if
>
<
dtml
-
if
selection_domain
><
dtml
-
let
expression
=
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias='domain_category')"
><
dtml
-
if
expression
>
,
<
dtml
-
var
expression
></
dtml
-
if
></
dtml
-
let
></
dtml
-
if
>
<
dtml
-
if
selection_report
><
dtml
-
let
expression
=
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias='report_category')"
><
dtml
-
if
expression
>
,
<
dtml
-
var
expression
></
dtml
-
if
></
dtml
-
let
></
dtml
-
if
>
<
dtml
-
if
"selection_domain_where_expression"
>
<
dtml
-
if
"selection_domain_from_expression"
>
,
<
dtml
-
var
"selection_domain_from_expression"
>
</
dtml
-
if
>
,
catalog
AS
node
</
dtml
-
if
>
<
dtml
-
if
transformed_uid
>
,
transformation
,
catalog
as
transformed_resource
</
dtml
-
if
>
WHERE
...
...
@@ -102,11 +105,9 @@ WHERE
<
dtml
-
if
only_accountable
>
AND
<
dtml
-
var
stock_table_id
>
.
is_accountable
</
dtml
-
if
>
<
dtml
-
if
selection_domain
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_domain, category_table_alias='domain_category', join_table=stock_table_id, join_column='node_uid')"
>
</
dtml
-
if
>
<
dtml
-
if
selection_report
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_report, category_table_alias='report_category', strict_membership=1)"
>
<
dtml
-
if
"selection_domain_where_expression"
>
AND
<
dtml
-
var
stock_table_id
>
.
node_uid
=
node
.
uid
AND
<
dtml
-
var
"selection_domain_where_expression"
>
</
dtml
-
if
>
<
dtml
-
if
convert_quantity_result
>
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.xml
View file @
c609f284
...
...
@@ -27,9 +27,9 @@ from_expression\r\n
where_expression\r\n
order_by_expression\r\n
group_by_expression\r\n
selection_domain\r\n
selection_domain_from_expression\r\n
selection_domain_where_expression\r\n
select_expression\r\n
selection_report\r\n
ignore_variation\r\n
standardize\r\n
omit_simulation\r\n
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.sql
View file @
c609f284
...
...
@@ -55,8 +55,10 @@ FROM
</
dtml
-
if
>
</
dtml
-
in
>
</
dtml
-
if
>
<
dtml
-
if
selection_domain
><
dtml
-
let
expression
=
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias='domain_category')"
><
dtml
-
if
expression
>
,
<
dtml
-
var
expression
></
dtml
-
if
></
dtml
-
let
></
dtml
-
if
>
<
dtml
-
if
selection_report
><
dtml
-
let
expression
=
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias='report_category')"
><
dtml
-
if
expression
>
,
<
dtml
-
var
expression
></
dtml
-
if
></
dtml
-
let
></
dtml
-
if
>
<
dtml
-
if
"selection_domain_where_expression"
>
<
dtml
-
if
"selection_domain_from_expression"
>
,
<
dtml
-
var
"selection_domain_from_expression"
>
</
dtml
-
if
>
,
catalog
AS
node
</
dtml
-
if
>
WHERE
stock
.
uid
=
catalog
.
uid
...
...
@@ -132,11 +134,9 @@ WHERE
<
dtml
-
unless
sequence
-
end
>
OR
</
dtml
-
unless
></
dtml
-
in
>
)
</
dtml
-
if
>
<
dtml
-
if
selection_domain
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_domain, category_table_alias='domain_category', join_table='stock', join_column='node_uid')"
>
</
dtml
-
if
>
<
dtml
-
if
selection_report
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_report, category_table_alias='report_category', strict_membership=1)"
>
<
dtml
-
if
"selection_domain_where_expression"
>
AND
stock
.
node_uid
=
node
.
uid
AND
<
dtml
-
var
"selection_domain_where_expression"
>
</
dtml
-
if
>
<
dtml
-
if
group_by_expression
>
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
View file @
c609f284
...
...
@@ -424,8 +424,8 @@ where_expression\r\n
order_by_expression\r\n
group_by_expression\r\n
limit_expression\r\n
selection_domain\r\n
selection_
report
\r\n
selection_domain
_from_expression
\r\n
selection_
domain_where_expression
\r\n
ignore_variation\r\n
standardize\r\n
omit_simulation\r\n
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetTrackingList.sql
View file @
c609f284
...
...
@@ -14,11 +14,12 @@ FROM
<
dtml
-
if
expr
=
"table_key != 'item'"
>
,
<
dtml
-
var
table_item
>
AS
<
dtml
-
var
table_key
></
dtml
-
if
>
</
dtml
-
in
>
</
dtml
-
if
>
<
dtml
-
if
selection_domain
>
,
<
dtml
-
var
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"
>
</
dtml
-
if
>
<
dtml
-
if
selection_report
>
,
<
dtml
-
var
"portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"
>
</
dtml
-
if
>
<
dtml
-
if
"selection_domain_where_expression"
>
<
dtml
-
if
"selection_domain_from_expression"
>
,
<
dtml
-
var
"selection_domain_from_expression"
>
</
dtml
-
if
>
,
catalog
AS
node
</
dtml
-
if
>
,
item
<
dtml
-
if
join_on_item
>
LEFT
JOIN
item
AS
next_item
...
...
@@ -65,12 +66,9 @@ WHERE
AND
next_item
.
uid
IS
NULL
</
dtml
-
if
>
<
dtml
-
if
selection_domain
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_domain, join_table='item', join_column='node_uid')"
>
</
dtml
-
if
>
<
dtml
-
if
selection_report
>
AND
<
dtml
-
var
"portal_selections.buildSQLExpressionFromDomainSelection(selection_report, strict_membership=1)"
>
<
dtml
-
if
"selection_domain_where_expression"
>
AND
stock
.
node_uid
=
node
.
uid
AND
<
dtml
-
var
"selection_domain_where_expression"
>
</
dtml
-
if
>
<
dtml
-
if
group_by_expression
>
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetTrackingList.xml
View file @
c609f284
...
...
@@ -198,8 +198,8 @@ input\r\n
output\r\n
from_table_list:list\r\n
where_expression\r\n
selection_domain\r\n
selection_
report
\r\n
selection_domain
_from_expression
\r\n
selection_
domain_where_expression
\r\n
order_by_expression\r\n
group_by_expression\r\n
join_on_item\r\n
...
...
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