Commit 6f832dc6 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: No need ComplexQuery

   Use default_or_child_aggregate_uid is enough (and simpler).
   Use specific states to be consistent with RSS queries.
parent 0bb24217
"""
Keep a custom script for permit render other times of documents, ie.: Software Installation.
"""
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
portal = context.getPortalObject()
query = ComplexQuery(
ComplexQuery(
SimpleQuery(portal_type="Support Request"),
SimpleQuery(default_aggregate_uid=context.getUid()),
logical_operator='and'),
ComplexQuery(
SimpleQuery(portal_type="Upgrade Decision Line"),
SimpleQuery(default_aggregate_uid=context.getUid()),
logical_operator='and'),
logical_operator='or')
kw['portal_type'] = ["Support Request", "Upgrade Decision"]
kw['default_or_child_aggregate_uid'] = context.getUid()
kw['sort_on'] = (('modification_date', 'DESC'),)
if 'simulation_state' not in kw:
kw['simulation_state'] = "NOT cancelled"
kw['simulation_state'] = ['validated','submitted', 'suspended', 'invalidated',
# Unfortunally Upgrade decision uses diferent states.
'confirmed', 'started', 'stopped', 'delivered']
if 'limit' not in kw:
kw['limit'] = 30
result_list = []
for document in portal.portal_catalog(query=query, **kw):
if document.getPortalType() == "Upgrade Decision Line":
if document.getParentValue().getSimulationState() != 'cancelled':
result_list.append(document.getParentValue())
continue
result_list.append(document)
return result_list
return portal.portal_catalog(**kw)
......@@ -178,8 +178,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
self.assertEqual(len(open_related_ticket_list), 0)
ticket.submit()
ticket.immediateReindexObject()
......@@ -225,8 +224,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
self.assertEqual(len(open_related_ticket_list), 0)
ticket.submit()
ticket.immediateReindexObject()
......@@ -268,14 +266,12 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
self.assertEqual(len(open_related_ticket_list), 0)
ticket.plan()
ticket.immediateReindexObject()
open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
self.assertEqual(len(open_related_ticket_list), 0)
ticket.confirm()
ticket.immediateReindexObject()
......@@ -330,8 +326,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
self.assertEqual(len(open_related_ticket_list), 0)
ticket.cancel()
ticket.immediateReindexObject()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment