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