Commit bd5bfca7 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: searchAndActivate cannot receive uid

Simplify the alarm call to not re-query more them once.
parent e3c2f5ef
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
method_id='OpenSaleOrder_reindexIfIndexedBeforeLine',
portal_type="Open Sale Order",
children_portal_type="Open Sale Order Line",
uid=[i.uid for i in portal.ERP5Site_zGetOpenOrderWithModifiedLineUid()],
activate_kw={'tag': tag},
)
for line in portal.ERP5Site_zGetOpenOrderWithModifiedLineUid():
context.activate(activity="SQLQueue",tag=tag).OpenSaleOrder_reindexIfIndexedBeforeLine(uid=line.uid)
context.activate(after_tag=tag).getId()
......@@ -8,7 +8,8 @@ WHERE
AND open_sale_order_line_catalog.path != 'reserved'
AND catalog.portal_type = "Open Sale Order"
AND catalog.uid = open_sale_order_line_catalog.parent_uid
AND catalog.validation_state IN ('draft', 'validated', 'archived')
AND open_sale_order_line_catalog.portal_type = "Open Sale Order Line"
AND open_sale_order_line_catalog.indexation_timestamp > catalog.indexation_timestamp
AND open_sale_order_line_catalog.indexation_timestamp >= catalog.indexation_timestamp
group by
catalog.uid
\ No newline at end of file
catalog.uid
......@@ -2,17 +2,22 @@ from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
order = context
if uid is None:
uid = context.getUid()
portal = context.getPortalObject()
indexation_timestamp = portal.portal_catalog(
uid=order.getUid(),
select_dict={'indexation_timestamp': None})[0].indexation_timestamp
order = portal.portal_catalog(
uid=uid,
select_dict={'indexation_timestamp': None})[0]
indexation_timestamp = order.indexation_timestamp
line_list = portal.portal_catalog(
portal_type="Open Sale Order Line",
parent_uid=order.getUid(),
portal_type="Open Sale Order Line",
parent_uid=uid,
indexation_timestamp={'query': indexation_timestamp, 'range': 'nlt'},
limit=1)
if len(line_list):
order.activate().immediateReindexObject()
order.getObject().activate().immediateReindexObject()
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
<value> <string>uid=None, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -1359,10 +1359,11 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'uid=None,*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by OpenSaleOrder_reindexIfIndexedBeforeLine') """ )
open_order = context.portal_catalog.getResultValue(uid=uid)
portal_workflow.doActionFor(open_order, action='edit_action', comment='Visited by OpenSaleOrder_reindexIfIndexedBeforeLine') """ )
transaction.commit()
def _dropOpenSaleOrder_reindexIfIndexedBeforeLine(self):
......@@ -1373,6 +1374,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by O
def test_alarm(self):
open_order = self.createOpenOrder()
self.tic()
open_order.newContent(portal_type="Open Sale Order Line")
self.tic()
self._simulateOpenSaleOrder_reindexIfIndexedBeforeLine()
......
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