Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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
Eteri
erp5_fork
Commits
8db89296
Commit
8db89296
authored
Jun 08, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
composition: Treat invalidated models as archived and improving the ranking method
parent
fa048dfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
product/ERP5/mixin/composition.py
product/ERP5/mixin/composition.py
+10
-6
No files found.
product/ERP5/mixin/composition.py
View file @
8db89296
...
...
@@ -55,7 +55,7 @@ def _getEffectiveModel(self, start_date, stop_date):
query_list
=
[
Query
(
reference
=
reference
),
Query
(
portal_type
=
self
.
getPortalType
()),
Query
(
validation_state
=
(
'deleted'
,
'
invalidated
'
),
Query
(
validation_state
=
(
'deleted'
,
'
draft
'
),
operator
=
'NOT'
)]
if
start_date
is
not
None
:
query_list
.
append
(
ComplexQuery
(
Query
(
effective_date
=
None
),
...
...
@@ -69,14 +69,18 @@ def _getEffectiveModel(self, start_date, stop_date):
logical_operator
=
'OR'
))
# XXX What to do the catalog returns nothing (either because 'self' was just
# created and not yet indexed, or because it was invalidated) ?
# created and not yet indexed, or because it was invalidated
/archived
) ?
# For the moment, we return self if self is invalidated and we raise otherwise.
# This way, if this happens in activity it may succeed when activity is retried.
model_list
=
self
.
getPortalObject
().
portal_catalog
.
unrestrictedSearchResults
(
query
=
ComplexQuery
(
logical_operator
=
'AND'
,
*
query_list
),
sort_on
=
((
'version'
,
'descending'
),))
model_list
=
sorted
(
self
.
getPortalObject
().
portal_catalog
.
unrestrictedSearchResults
(
query
=
ComplexQuery
(
logical_operator
=
'AND'
,
*
query_list
)),
key
=
lambda
model
:
(
model
.
getValidationState
()
==
'archived'
,
# We give priority to explicit archived state
model
.
getVersion
(),
# Sort by version, as text XXX we need to improve this
model
.
getModificationDate
()),
# Lastly by modification date
reverse
=
True
)
if
not
model_list
:
if
self
.
getValidationState
()
==
'invalidated'
:
if
self
.
getValidationState
()
in
(
'invalidated'
,
'archived'
)
:
return
self
raise
KeyError
(
'No %s found with the reference %s between %s and %s'
%
\
(
self
.
getPortalType
(),
reference
,
start_date
,
stop_date
))
...
...
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