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
Carlos Ramos Carreño
erp5
Commits
ab0546f0
Commit
ab0546f0
authored
Jan 31, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: use key instead of cmp to sort
parent
88ea9030
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
62 additions
and
178 deletions
+62
-178
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingTransactionLineList.py
...AccountingTransaction_getAccountingTransactionLineList.py
+9
-6
bt5/erp5_calendar/SkinTemplateItem/portal_skins/erp5_calendar/PersonModule_getLeaveRequestReportLineList.py
...p5_calendar/PersonModule_getLeaveRequestReportLineList.py
+1
-4
bt5/erp5_configurator/DocumentTemplateItem/portal_components/document.erp5.BusinessConfiguration.py
.../portal_components/document.erp5.BusinessConfiguration.py
+3
-3
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_getActiveProcessFromSelectionList.py
...erp5_ooo_import/Base_getActiveProcessFromSelectionList.py
+1
-3
bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/AccountingTransactionModule_getNetSalaryReportSectionLineList.py
...ingTransactionModule_getNetSalaryReportSectionLineList.py
+4
-10
bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/AccountingTransactionModule_getPaySheetLineReportSectionLineList.py
...TransactionModule_getPaySheetLineReportSectionLineList.py
+9
-16
bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getMovementList.py
...skins/erp5_payroll/PaySheetTransaction_getMovementList.py
+6
-32
bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getSourceProjectRelatedTaskList.py
...s/erp5_project/Project_getSourceProjectRelatedTaskList.py
+3
-9
bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getSourceProjectRelatedTaskReportList.py
..._project/Project_getSourceProjectRelatedTaskReportList.py
+3
-9
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderStatList.py
...m/portal_skins/erp5_trade/OrderModule_getOrderStatList.py
+3
-4
product/CMFCategory/Category.py
product/CMFCategory/Category.py
+10
-2
product/CMFCategory/Renderer.py
product/CMFCategory/Renderer.py
+4
-1
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.FolderWorkflowActionUtils.py
...al_components/extension.erp5.FolderWorkflowActionUtils.py
+1
-8
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.py
...ins/erp5_core/Category_getSortedCategoryChildValueList.py
+0
-8
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.xml
...ns/erp5_core/Category_getSortedCategoryChildValueList.xml
+0
-62
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.DomainTool.py
...entTemplateItem/portal_components/tool.erp5.DomainTool.py
+5
-1
No files found.
bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingTransactionLineList.py
View file @
ab0546f0
if
not
portal_type
:
portal_type
=
context
.
getPortalObject
().
getPortalAccountingMovementTypeList
()
sort_dict
=
{
'income'
:
0
,
'expense'
:
-
2
,
'receivable'
:
-
2
,
'payable'
:
0
,
'collected_vat'
:
-
1
,
'refundable_vat'
:
-
1
}
sort_dict
=
{
'bank'
:
-
3
,
'income'
:
0
,
'expense'
:
-
2
,
'receivable'
:
-
2
,
'payable'
:
0
,
'collected_vat'
:
-
1
,
'refundable_vat'
:
-
1
,
}
def
getAccountingTransactionLineSortKey
(
line
):
return
sort_dict
.
get
(
line
.
getId
(),
(
line
.
getIntIndex
()
or
line
.
getIntId
()
or
0
))
...
...
bt5/erp5_calendar/SkinTemplateItem/portal_skins/erp5_calendar/PersonModule_getLeaveRequestReportLineList.py
View file @
ab0546f0
...
...
@@ -68,10 +68,7 @@ for person in person_value_list:
total
=
person_total
,
**
result_dict
))
result_list
.
sort
(
lambda
a
,
b
:
cmp
(
a
.
person_career_reference
or
a
.
person_title
,
b
.
person_career_reference
or
b
.
person_title
))
result_list
.
sort
(
key
=
lambda
r
:
(
r
.
person_career_reference
or
''
,
r
.
person_title
or
''
))
request
.
set
(
'total_time'
,
total_time
)
request
.
set
(
'total_time_per_resource'
,
total_time_per_resource
)
...
...
bt5/erp5_configurator/DocumentTemplateItem/portal_components/document.erp5.BusinessConfiguration.py
View file @
ab0546f0
...
...
@@ -553,12 +553,12 @@ class BusinessConfiguration(Item):
"immediateReindexObject"
])
# build
configuration_save_list
=
self
.
contentValues
(
portal_type
=
'Configuration Save'
)
configuration_save_list
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
getIntIndex
(
x
.
getIntId
()),
y
.
getIntIndex
(
y
.
getIntId
())))
configuration_save_list
.
sort
(
key
=
lambda
x
:
(
x
.
getIntIndex
(
x
.
getIntId
())
or
0
))
for
configuration_save
in
configuration_save_list
:
# XXX: check which items are configure-able
configuration_item_list
=
configuration_save
.
contentValues
()
configuration_item_list
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
getIntId
(),
y
.
getIntId
()))
configuration_item_list
.
sort
(
key
=
lambda
x
:
(
x
.
getIntId
()
or
0
))
for
configurator_item
in
configuration_item_list
:
configurator_item
.
activate
(
**
kw
).
fixConsistency
(
filter
=
{
"constraint_type"
:
"configuration"
})
...
...
bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_getActiveProcessFromSelectionList.py
View file @
ab0546f0
...
...
@@ -16,6 +16,4 @@ for (x,y) in selection_param_list:
active_process_list
=
[(
y
,
x
)
for
(
x
,
y
)
in
active_process_dict
.
items
()]
active_process_list
.
sort
(
lambda
x
,
y
:
cmp
(
x
[
1
],
y
[
1
]),
reverse
=
True
)
return
active_process_list
return
sorted
(
active_process_list
,
key
=
lambda
item
:
item
[
1
],
reverse
=
True
)
bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/AccountingTransactionModule_getNetSalaryReportSectionLineList.py
View file @
ab0546f0
...
...
@@ -58,13 +58,7 @@ for inventory in portal.portal_simulation.getInventoryList(
request
.
set
(
'total_price'
,
total_price
)
def
sort_method
(
a
,
b
):
employee_career_reference_diff
=
cmp
(
a
.
employee_career_reference
,
b
.
employee_career_reference
)
if
employee_career_reference_diff
:
return
employee_career_reference_diff
return
cmp
(
a
.
employee_title
,
b
.
employee_title
)
object_list
.
sort
(
sort_method
)
return
object_list
return
sorted
(
object_list
,
key
=
lambda
o
:
(
o
.
employee_career_reference
or
''
,
o
.
employee_title
)
)
bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/AccountingTransactionModule_getPaySheetLineReportSectionLineList.py
View file @
ab0546f0
...
...
@@ -38,10 +38,10 @@ inventory_param_dict = {
}
employee_param_dict
=
inventory_param_dict
.
copy
()
employee_param_dict
[
'contribution_share_uid'
]
=
context
.
portal_categories
.
contribution_share
.
employee
.
getUid
()
employee_param_dict
[
'contribution_share_uid'
]
=
portal
.
portal_categories
.
contribution_share
.
employee
.
getUid
()
employer_param_dict
=
inventory_param_dict
.
copy
()
employer_param_dict
[
'contribution_share_uid'
]
=
context
.
portal_categories
.
contribution_share
.
employer
.
getUid
()
employer_param_dict
[
'contribution_share_uid'
]
=
portal
.
portal_categories
.
contribution_share
.
employer
.
getUid
()
if
request
.
get
(
'mirror_section'
):
mirror_section
=
request
[
'mirror_section'
]
...
...
@@ -112,21 +112,14 @@ request.set('base_total', base_total)
request
.
set
(
'total'
,
total
)
sorted_inventory_list
=
[]
sorted_inventory_list
=
inventory_list
.
values
()
# sort by salary range, and add intermediate sums if needed
def
sort_method
(
a
,
b
):
salary_range_diff
=
cmp
(
a
.
salary_range
,
b
.
salary_range
)
if
salary_range_diff
:
return
salary_range_diff
employee_career_reference_diff
=
cmp
(
a
.
employee_career_reference
,
b
.
employee_career_reference
)
if
employee_career_reference_diff
:
return
employee_career_reference_diff
return
cmp
(
a
.
employee_title
,
b
.
employee_title
)
sorted_inventory_list
.
sort
(
sort_method
)
sorted_inventory_list
=
sorted
(
inventory_list
.
values
(),
key
=
lambda
i
:
(
i
.
salary_range
or
''
,
i
.
employee_career_reference
or
''
,
i
.
employee_title
or
''
,
))
i
=
0
intermediate_base_total
=
0
...
...
bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getMovementList.py
View file @
ab0546f0
...
...
@@ -120,38 +120,12 @@ for paysheet_line in paysheet_line_list:
if
'no_slice'
in
object_dict
:
line_list
.
append
(
paysheet_line
.
asContext
(
**
object_dict
[
'no_slice'
]))
# sort results
def
sortByTitleAscending
(
x
,
y
):
return
cmp
(
x
.
getTitle
(),
y
.
getTitle
())
def
sortByTitleDescending
(
x
,
y
):
return
cmp
(
y
.
getTitle
(),
x
.
getTitle
())
def
sortByIntIndexAscending
(
x
,
y
):
return
cmp
(
x
.
getIntIndex
(),
y
.
getIntIndex
())
def
sortByIntIndexDescending
(
x
,
y
):
return
cmp
(
y
.
getIntIndex
(),
x
.
getIntIndex
())
sortByDefaultSortMethod
=
sortByIntIndexAscending
reverse
=
False
sort_key
=
lambda
l
:
(
l
.
getIntIndex
()
or
0
)
if
'sort_on'
in
kw
:
sort_on
=
kw
[
'sort_on'
]
if
sort_on
[
0
][
0
]
==
'title'
and
sort_on
[
0
][
1
]
==
'ascending'
:
line_list
.
sort
(
sortByTitleAscending
)
elif
sort_on
[
0
][
0
]
==
'title'
and
sort_on
[
0
][
1
]
==
'descending'
:
line_list
.
sort
(
sortByTitleDescending
)
elif
sort_on
[
0
][
0
]
==
'int_index'
and
sort_on
[
0
][
1
]
==
'ascending'
:
line_list
.
sort
(
sortByIntIndexAscending
)
elif
sort_on
[
0
][
0
]
==
'int_index'
and
sort_on
[
0
][
1
]
==
'descending'
:
line_list
.
sort
(
sortByIntIndexDescending
)
else
:
line_list
.
sort
(
sortByDefaultSortMethod
)
else
:
line_list
.
sort
(
sortByDefaultSortMethod
)
reverse
=
sort_on
[
0
][
1
]
==
'descending'
if
sort_on
[
0
][
0
]
==
'title'
:
sort_key
=
lambda
l
:
(
l
.
getTitle
()
or
''
)
return
line_list
return
sorted
(
line_list
,
key
=
sort_key
,
reverse
=
reverse
)
bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getSourceProjectRelatedTaskList.py
View file @
ab0546f0
...
...
@@ -24,12 +24,6 @@ task_line_list = []
for
task
in
task_list
:
task_line_list
.
extend
(
task
.
contentValues
(
portal_type
=
'Task Line'
))
def
sortTaskLine
(
a
,
b
):
result
=
cmp
(
a
.
getStartDate
(),
b
.
getStartDate
())
if
result
==
0
:
result
=
cmp
(
a
.
getTitle
(),
b
.
getTitle
())
return
result
task_line_list
.
sort
(
sortTaskLine
)
return
task_line_list
return
sorted
(
task_line_list
,
key
=
lambda
tl
:
(
tl
.
hasStartDate
(),
tl
.
getStartDate
(),
tl
.
getTitle
()))
bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/Project_getSourceProjectRelatedTaskReportList.py
View file @
ab0546f0
...
...
@@ -40,12 +40,6 @@ for task in task_list:
task_line_list
.
extend
(
task
.
objectValues
(
portal_type
=
(
'Task Line'
,
'Task Report Line'
)))
def
sortTaskLine
(
a
,
b
):
result
=
cmp
(
a
.
getStartDate
(),
b
.
getStartDate
())
if
result
==
0
:
result
=
cmp
(
a
.
getTitle
(),
b
.
getTitle
())
return
result
task_line_list
.
sort
(
sortTaskLine
)
return
task_line_list
return
sorted
(
task_line_list
,
key
=
lambda
tl
:
(
tl
.
getStartDate
()
is
not
None
,
tl
.
getStartDate
(),
tl
.
getTitle
()))
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/OrderModule_getOrderStatList.py
View file @
ab0546f0
...
...
@@ -57,8 +57,6 @@ if active_process_path:
else
:
raise
ValueError
(
"No active process found to process report"
)
def
sortProduct
(
a
,
b
):
return
cmp
(
a
[
'product'
],
b
[
'product'
])
period_counter_dict
=
{}
line_list
=
[]
...
...
@@ -132,7 +130,7 @@ if len(client_dict):
product_lines_list
.
append
(
obj
)
# sort product list
product_lines_list
.
sort
(
sortProduct
)
product_lines_list
.
sort
(
key
=
lambda
p
:
p
[
'product'
]
)
extend
(
product_lines_list
)
else
:
# products
...
...
@@ -169,7 +167,8 @@ else:
period_counter_dict
[
'total amount'
]
=
line_total_amount
append
(
obj
)
line_list
.
sort
(
sortProduct
)
line_list
.
sort
(
key
=
lambda
p
:
p
[
'product'
])
obj
=
Object
(
uid
=
"new_"
)
obj
[
"client"
]
=
'Total'
...
...
product/CMFCategory/Category.py
View file @
ab0546f0
...
...
@@ -335,7 +335,11 @@ class Category(Folder):
if
not
isinstance
(
local_sort_id
,
(
tuple
,
list
)):
local_sort_id
=
(
local_sort_id
,
)
def
sort_key
(
c
):
return
[
c
.
getProperty
(
sort_id
,
0
)
for
sort_id
in
local_sort_id
]
k
=
[]
for
sort_id
in
local_sort_id
:
v
=
c
.
getProperty
(
sort_id
)
k
.
extend
([
v
is
not
None
,
v
])
return
k
local_sort_key
=
sort_key
if
local_sort_method
:
warnings
.
warn
(
...
...
@@ -894,7 +898,11 @@ class BaseCategory(Category):
if
not
isinstance
(
local_sort_id
,
(
tuple
,
list
)):
local_sort_id
=
(
local_sort_id
,
)
def
sort_key
(
c
):
return
[
c
.
getProperty
(
sort_id
,
0
)
for
sort_id
in
local_sort_id
]
k
=
[]
for
sort_id
in
local_sort_id
:
v
=
c
.
getProperty
(
sort_id
)
k
.
extend
([
v
is
not
None
,
v
])
return
k
local_sort_key
=
sort_key
if
local_sort_method
:
warnings
.
warn
(
...
...
product/CMFCategory/Renderer.py
View file @
ab0546f0
...
...
@@ -149,7 +149,10 @@ class Renderer(Filter):
elif
self
.
sort_key
is
not
None
:
value_list
.
sort
(
key
=
self
.
sort_key
)
elif
self
.
sort_id
is
not
None
:
value_list
.
sort
(
key
=
lambda
x
:
x
.
getProperty
(
self
.
sort_id
))
def
sort_key
(
x
):
k
=
x
.
getProperty
(
self
.
sort_id
)
return
(
k
is
not
None
,
k
)
value_list
.
sort
(
key
=
sort_key
)
# If base=1 but base_category is None, it is necessary to guess the base category
# by heuristic.
...
...
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.FolderWorkflowActionUtils.py
View file @
ab0546f0
...
...
@@ -148,14 +148,7 @@ def getDocumentGroupByWorkflowStateList(self, form_id='', **kw):
workflow_state
=
current_workflow_state
,
))
# Let us sort this list by translated title of workflow state and workflow
def
compareState
(
a
,
b
):
return
cmp
((
a
.
workflow_title
,
a
.
translated_workflow_state_title
),
(
b
.
workflow_title
,
b
.
translated_workflow_state_title
))
document_list
.
sort
(
compareState
)
# Return result
return
document_list
return
sorted
(
document_list
,
key
=
lambda
b
:
(
b
.
workflow_title
,
b
.
translated_workflow_state_title
))
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.py
deleted
100644 → 0
View file @
88ea9030
from
erp5.component.module.Log
import
log
# this script is no longer needed.
log
(
'Category_getSortedCategoryChildValueList'
,
'use getCategoryChildValueList method'
)
value_list
=
[
o
for
o
in
context
.
getCategoryChildValueList
()
if
o
.
getRelativeUrl
()
!=
context
.
getRelativeUrl
()]
sort_id
=
'int_index'
value_list
.
sort
(
key
=
lambda
x
:
x
.
getProperty
(
sort_id
))
return
value_list
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Category_getSortedCategoryChildValueList.xml
deleted
100644 → 0
View file @
88ea9030
<?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>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Category_getSortedCategoryChildValueList
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.DomainTool.py
View file @
ab0546f0
...
...
@@ -27,6 +27,7 @@
#
##############################################################################
import
functools
from
collections
import
defaultdict
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
...
...
@@ -243,7 +244,10 @@ class DomainTool(BaseTool):
if
sort_key_method
is
not
None
:
result_list
.
sort
(
key
=
sort_key_method
)
elif
sort_method
is
not
None
:
result_list
.
sort
(
cmp
=
sort_method
)
if
six
.
PY3
:
result_list
.
sort
(
key
=
functools
.
cmp_to_key
(
sort_method
))
else
:
result_list
.
sort
(
cmp
=
sort_method
)
return
result_list
# XXX FIXME method should not be public
...
...
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