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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Laurent S
erp5
Commits
b7e644e4
Commit
b7e644e4
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
958c3b87
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
62 deletions
+82
-62
bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Resource_zGetInventoryList.sql
...al_skins/erp5_banking_core/Resource_zGetInventoryList.sql
+4
-8
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
+47
-22
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
...tem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
+7
-7
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.xml
...tem/portal_skins/erp5_core/Resource_zGetInventoryList.xml
+3
-2
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.sql
...rtal_skins/erp5_core/Resource_zGetMovementHistoryList.sql
+6
-7
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
...rtal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
+3
-2
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetTrackingList.sql
...Item/portal_skins/erp5_core/Resource_zGetTrackingList.sql
+7
-10
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetTrackingList.xml
...Item/portal_skins/erp5_core/Resource_zGetTrackingList.xml
+3
-2
No files found.
bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Resource_zGetInventoryList.sql
View file @
b7e644e4
...
...
@@ -76,12 +76,11 @@ FROM
AND
quantity_unit_conversion
.
quantity_unit_uid
=
<
dtml
-
sqlvar
quantity_unit_uid
type
=
int
>
)
</
dtml
-
if
>
<
dtml
-
in
prefix
=
"table"
expr
=
"from_table_list"
>
<
dtml
-
if
expr
=
"table_key not in ('catalog', stock_table_id)"
>
<
dtml
-
if
expr
=
"table_key not in ('catalog',
'node',
stock_table_id)"
>
,
<
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 @
b7e644e4
...
...
@@ -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 @
b7e644e4
...
...
@@ -504,7 +504,17 @@ class SimulationTool(BaseTool):
# catalog
new_kw
.
pop
(
'ignore_group_by'
,
None
)
sql_kw
.
update
(
ctool
.
buildSQLQuery
(
**
new_kw
))
catalog_sql_kw
=
ctool
.
buildSQLQuery
(
**
new_kw
)
from_table_dict
=
dict
(
sql_kw
.
pop
(
'from_table_list'
,
[]))
for
alias
,
table
in
catalog_sql_kw
.
pop
(
'from_table_list'
,
None
)
or
[]:
assert
from_table_dict
.
get
(
alias
)
in
(
None
,
table
),
(
alias
,
table
,
from_table_dict
[
alias
],
)
from_table_dict
[
alias
]
=
table
sql_kw
.
update
(
catalog_sql_kw
)
sql_kw
[
'from_table_list'
]
=
from_table_dict
.
items
()
return
sql_kw
def
_generateKeywordDict
(
self
,
...
...
@@ -592,6 +602,9 @@ class SimulationTool(BaseTool):
# sort_on
sort_on
=
None
,
group_by
=
None
,
# selection
selection_domain
=
None
,
selection_report
=
None
,
# keywords for related keys
**
kw
):
"""
...
...
@@ -601,11 +614,36 @@ class SimulationTool(BaseTool):
column. If 0, it also used the mirror_date column.
"""
new_kw
=
{}
sql_kw
=
{}
sql_kw
=
{
'from_table_list'
:
[],
# Set of catalog aliases that must be joined in the ZSQLMethod ('foo'
# meaning something along the lines of 'foo.uid = stock.foo_uid')
'selection_domain_catalog_alias_set'
:
[],
# input and output are used by getTrackingList
'input'
:
input
,
'output'
:
output
,
# BBB
'selection_domain'
:
None
,
'selection_report'
:
None
,
}
if
selection_domain
is
None
:
sql_kw
[
'selection_domain_from_expression'
]
=
None
sql_kw
[
'selection_domain_where_expression'
]
=
None
else
:
# Pre-render selection_domain, as it is easier done here than in DTML.
query_table_alias
=
'node'
# XXX: To be eventually made configurable
selection_domain_sql_dict
=
self
.
getPortalObject
().
portal_catalog
.
buildSQLQuery
(
selection_domain
=
selection_domain
,
query_table_alias
=
query_table_alias
,
)
sql_kw
[
'selection_domain_from_expression'
]
=
selection_domain_sql_dict
[
'from_expression'
]
sql_kw
[
'from_table_list'
].
extend
(
selection_domain_sql_dict
[
'from_table_list'
])
sql_kw
[
'selection_domain_where_expression'
]
=
selection_domain_sql_dict
[
'where_expression'
]
sql_kw
[
'selection_domain_catalog_alias_set'
].
append
(
query_table_alias
)
if
selection_report
is
not
None
:
new_kw
[
'selection_report'
]
=
selection_report
# input and output are used by getTrackingList
sql_kw
[
'input'
]
=
input
sql_kw
[
'output'
]
=
output
# Add sort_on parameter if defined
if
sort_on
is
not
None
:
new_kw
[
'sort_on'
]
=
sort_on
...
...
@@ -1178,7 +1216,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
):
...
...
@@ -1259,8 +1296,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
,
...
...
@@ -1883,8 +1918,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
...
...
@@ -1900,8 +1934,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
,
...
...
@@ -1910,8 +1943,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
...
...
@@ -1926,8 +1958,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
,
...
...
@@ -1937,7 +1968,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
):
...
...
@@ -1965,8 +1995,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
=
...
...
@@ -2065,7 +2093,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
...
...
@@ -2171,8 +2198,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 @
b7e644e4
...
...
@@ -75,8 +75,8 @@ 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_from_expression"
>
,
<
dtml
-
var
"selection_domain_from_expression"
>
</
dtml
-
if
>
<
dtml
-
if
transformed_uid
>
,
transformation
,
catalog
as
transformed_resource
</
dtml
-
if
>
WHERE
...
...
@@ -102,11 +102,11 @@ 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"
>
<
dtml
-
in
selection_domain_catalog_alias_set
>
AND
<
dtml
-
var
stock_table_id
>
.
<
dtml
-
var
sequence
-
item
>
_uid
=
<
dtml
-
var
sequence
-
item
>
.
uid
</
dtml
-
in
>
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 @
b7e644e4
...
...
@@ -27,9 +27,10 @@ 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
selection_domain_catalog_alias_set\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 @
b7e644e4
...
...
@@ -55,8 +55,7 @@ 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_from_expression"
>
,
<
dtml
-
var
"selection_domain_from_expression"
>
</
dtml
-
if
>
WHERE
stock
.
uid
=
catalog
.
uid
...
...
@@ -132,11 +131,11 @@ 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"
>
<
dtml
-
in
selection_domain_catalog_alias_set
>
AND
stock
.
<
dtml
-
var
sequence
-
item
>
_uid
=
<
dtml
-
var
sequence
-
item
>
.
uid
</
dtml
-
in
>
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 @
b7e644e4
...
...
@@ -424,8 +424,9 @@ 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
selection_domain_catalog_alias_set\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 @
b7e644e4
...
...
@@ -14,11 +14,9 @@ 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_from_expression"
>
,
<
dtml
-
var
"selection_domain_from_expression"
>
</
dtml
-
if
>
,
item
<
dtml
-
if
join_on_item
>
LEFT
JOIN
item
AS
next_item
...
...
@@ -65,12 +63,11 @@ 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"
>
<
dtml
-
in
selection_domain_catalog_alias_set
>
AND
<
dtml
-
var
stock_table_id
>
.
<
dtml
-
var
sequence
-
item
>
_uid
=
<
dtml
-
var
sequence
-
item
>
.
uid
</
dtml
-
in
>
AND
<
dtml
-
var
"selection_domain_where_expression"
>
</
dtml
-
if
>
<
dtml
-
if
group_by_expression
>
...
...
@@ -82,4 +79,4 @@ ORDER BY
<
dtml
-
var
order_by_expression
>
<
dtml
-
else
>
ORDER
BY
item
.
date
DESC
</
dtml
-
if
>
\ No newline at end of file
</
dtml
-
if
>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetTrackingList.xml
View file @
b7e644e4
...
...
@@ -198,8 +198,9 @@ 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
selection_domain_catalog_alias_set\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