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. Keep a custom script for permit render other times of documents, ie.: Software Installation.
""" """
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
portal = context.getPortalObject() portal = context.getPortalObject()
query = ComplexQuery( kw['portal_type'] = ["Support Request", "Upgrade Decision"]
ComplexQuery( kw['default_or_child_aggregate_uid'] = context.getUid()
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['sort_on'] = (('modification_date', 'DESC'),) kw['sort_on'] = (('modification_date', 'DESC'),)
if 'simulation_state' not in kw: 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: if 'limit' not in kw:
kw['limit'] = 30 kw['limit'] = 30
result_list = [] return portal.portal_catalog(**kw)
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
...@@ -178,8 +178,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin): ...@@ -178,8 +178,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic() self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 0)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.submit() ticket.submit()
ticket.immediateReindexObject() ticket.immediateReindexObject()
...@@ -225,8 +224,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin): ...@@ -225,8 +224,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic() self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 0)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.submit() ticket.submit()
ticket.immediateReindexObject() ticket.immediateReindexObject()
...@@ -268,14 +266,12 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin): ...@@ -268,14 +266,12 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic() self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 0)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.plan() ticket.plan()
ticket.immediateReindexObject() ticket.immediateReindexObject()
open_related_ticket_list = document.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 0)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.confirm() ticket.confirm()
ticket.immediateReindexObject() ticket.immediateReindexObject()
...@@ -330,8 +326,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin): ...@@ -330,8 +326,7 @@ class TestSlapOSBase_getOpenRelatedTicketList(TestCRMSkinsMixin):
self.tic() self.tic()
open_related_ticket_list = document.Base_getOpenRelatedTicketList() open_related_ticket_list = document.Base_getOpenRelatedTicketList()
self.assertEqual(len(open_related_ticket_list), 1) self.assertEqual(len(open_related_ticket_list), 0)
self.assertEqual(open_related_ticket_list[0].getUid(), ticket.getUid())
ticket.cancel() ticket.cancel()
ticket.immediateReindexObject() 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