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
Paul Graydon
erp5
Commits
9ee93048
Commit
9ee93048
authored
Jul 01, 2020
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_trade: customise sale order report
parent
7cb707a2
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
245 additions
and
49 deletions
+245
-49
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderReportSectionList.py
...skins/erp5_trade/OrderModule_getOrderReportSectionList.py
+100
-2
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderStatList.py
...m/portal_skins/erp5_trade/OrderModule_getOrderStatList.py
+145
-47
No files found.
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderReportSectionList.py
View file @
9ee93048
from
Products.ERP5Form.Report
import
ReportSection
from
Products.ERP5Form.Report
import
ReportSection
from
Products.ERP5Type.DateUtils
import
getIntervalListBetweenDates
from
DateTime
import
DateTime
from
DateTime
import
DateTime
params
,
stat_columns
,
selection_columns
=
context
.
OrderModule_getOrderReportParameterDict
()
context
.
REQUEST
.
set
(
'stat_columns'
,
stat_columns
)
result
=
[]
result
=
[]
request
=
container
.
REQUEST
# list only if user has a login defined
aggregation_level
=
request
.
get
(
'aggregation_level'
)
from_date
=
request
.
get
(
'from_date'
)
to_date
=
request
.
get
(
'at_date'
)
group_by
=
request
.
get
(
'group_by'
)
quantity_unit
=
request
.
get
(
'quantity_unit'
)
simulation_state
=
request
.
get
(
'simulation_state'
,
())
# define some parameter dependings on module
if
"Sale"
in
context
.
getPortalType
():
report_type
=
"sale"
line_portal_type
=
"Sale Order Line"
doc_portal_type
=
"Sale Order"
elif
"Purchase"
in
context
.
getPortalType
():
report_type
=
"purchase"
line_portal_type
=
"Purchase Order Line"
doc_portal_type
=
"Purchase Order"
elif
request
.
get
(
'order_report_document_portal_type'
):
doc_portal_type
=
request
.
get
(
'order_report_document_portal_type'
)
if
doc_portal_type
==
'Purchase Invoice Transaction'
:
line_portal_type
=
'Invoice Line'
report_type
=
'purchase'
elif
doc_portal_type
==
'Sale Invoice Transaction'
:
line_portal_type
=
'Invoice Line'
report_type
=
'sale'
else
:
raise
ValueError
,
"unknown document portal type for report %s"
%
doc_portal_type
else
:
raise
ValueError
,
"unknown type for report"
selection_columns
=
[(
'group_by'
,
"Group by"
)]
if
from_date
is
None
:
# get the minimum start date in catalog
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
NegatedQuery
kw
=
{
"delivery.start_date"
:
None
,
"key"
:
"DefaultKey"
}
q
=
NegatedQuery
(
Query
(
**
kw
))
select_expression
=
"MIN(delivery.start_date)"
group_by
=
"delivery.start_date"
from_date
=
DateTime
()
result_list
=
context
.
portal_catalog
(
select_expression
=
select_expression
,
group_by_expression
=
group_by
,
simulation_state
=
simulation_state
,
portal_type
=
doc_portal_type
,
query
=
q
,
limit
=
1
)
if
result_list
:
from_date
=
DateTime
(
result_list
[
0
][
2
])
# get period list between given date
interval_list_dict
=
getIntervalListBetweenDates
(
from_date
=
from_date
,
to_date
=
to_date
,
keys
=
{
'year'
:
aggregation_level
==
"year"
,
'month'
:
aggregation_level
==
"month"
,
'week'
:
aggregation_level
==
"week"
,
'day'
:
aggregation_level
==
"day"
})
interval_list
=
interval_list_dict
[
aggregation_level
]
# FIXME: translate column names
# list columns of the listbox
interval_column_list
=
[]
if
group_by
==
"client"
:
interval_column_list
.
extend
([(
"Amount %s"
%
x
,
"Amount %s"
%
x
)
for
x
in
interval_list
])
selection_columns
=
[(
'client'
,
"Client"
)]
stat_columns
=
[(
'client'
,
"client"
)]
total_column_list
=
[(
'total amount'
,
'Total Amount'
),]
total_stat_list
=
[(
'total amount'
,
'total amount'
),]
else
:
if
group_by
==
"product"
:
selection_columns
=
[(
'product_reference'
,
"Product Reference"
,
),
(
'product'
,
"Product"
)]
stat_columns
=
[(
'product'
,
"product"
)]
elif
group_by
==
"function"
:
function_title
=
context
.
AccountingTransactionLine_getFunctionBaseCategoryTitle
()
selection_columns
=
[(
'product'
,
function_title
)]
stat_columns
=
[(
'product'
,
"product"
)]
else
:
selection_columns
=
[(
'client'
,
"Client"
),
(
'product_reference'
,
"Product Reference"
,
),
(
'product'
,
"Product"
)]
stat_columns
=
[(
'client'
,
"client"
),
(
'product'
,
"product"
)]
for
x
in
interval_list
:
interval_column_list
.
extend
([(
"Amount %s"
%
x
,
"Amount %s"
%
x
),
(
"Quantity %s"
%
x
,
"Quantity %s"
%
x
)])
if
not
quantity_unit
:
interval_column_list
.
extend
([(
"Quantity Unit %s"
%
x
,
"Quantity Unit %s"
%
x
)])
total_column_list
=
[(
'total amount'
,
'Total Amount'
),(
'total quantity'
,
'Total Quantity'
)]
total_stat_list
=
[(
'total amount'
,
'total amount'
),(
'total quantity'
,
'total quantity'
)]
selection_columns
.
extend
(
interval_column_list
)
selection_columns
.
extend
(
total_column_list
)
params
=
dict
(
period_list
=
interval_list
,
report_type
=
report_type
,
doc_portal_type
=
doc_portal_type
,
line_portal_type
=
line_portal_type
,
simulation_state
=
simulation_state
)
# stat columns of the listbox
stat_columns
=
stat_columns
+
interval_column_list
+
total_stat_list
context
.
REQUEST
.
set
(
'stat_columns'
,
stat_columns
)
result
.
append
(
ReportSection
(
result
.
append
(
ReportSection
(
path
=
context
.
getPhysicalPath
(),
path
=
context
.
getPhysicalPath
(),
selection_columns
=
selection_columns
,
selection_columns
=
selection_columns
,
listbox_display_mode
=
'FlatListMode'
,
listbox_display_mode
=
'FlatListMode'
,
selection_params
=
params
,
selection_params
=
params
,
form_id
=
'OrderModule_viewOrderStatList'
))
form_id
=
'OrderModule_viewOrderStatList'
))
return
result
return
result
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderStatList.py
View file @
9ee93048
This diff is collapsed.
Click to expand it.
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