Commit 5c4e8c60 authored by Julien Muchembled's avatar Julien Muchembled

Clear activity table unconditionally when a site is created

Tests like testComplexTradeModelLineUseCase were failing without --portal_id=
because a new site was created whereas there were remaining activities from
previously run tests.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41596 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cc830779
...@@ -4688,12 +4688,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4688,12 +4688,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
gen = generator_class() gen = generator_class()
# update activity tool first if necessary # update activity tool first if necessary
if self.getTitle() == 'erp5_core' and self.getTemplateUpdateTool(): if self.getTitle() == 'erp5_core' and self.getTemplateUpdateTool():
if not site.hasObject('portal_activities'): gen.setupLastTools(site)
create_activities = True
LOG('Business Template', 0, 'Updating Activity Tool')
else:
create_activities = False
gen.setupLastTools(site, update=1, create_activities=create_activities)
if not force: if not force:
if len(object_to_update) == 0: if len(object_to_update) == 0:
# check if we have to update tools # check if we have to update tools
......
...@@ -1573,25 +1573,18 @@ class ERP5Generator(PortalGenerator): ...@@ -1573,25 +1573,18 @@ class ERP5Generator(PortalGenerator):
reindex=reindex, **kw) reindex=reindex, **kw)
return p return p
def setupLastTools(self, p, **kw): def setupLastTools(self, p, create_activities=True, **kw):
""" """
Set up finals tools Set up finals tools
We want to set the activity tool only at the end to We want to set the activity tool only at the end to
make sure that we do not put un the queue the full reindexation make sure that we do not put un the queue the full reindexation
""" """
# Add Activity Tool # Add Activity Tool
if kw.get('create_activities', False): if create_activities and not p.hasObject('portal_activities'):
if not p.hasObject('portal_activities'): addTool = p.manage_addProduct['CMFActivity'].manage_addTool
addTool = p.manage_addProduct['CMFActivity'].manage_addTool addTool('CMF Activity Tool', None) # Allow user to select active/passive
addTool('CMF Activity Tool', None) # Allow user to select active/passive
# Initialize Activities # Initialize Activities
portal_activities = getToolByName(p, 'portal_activities', None) p.portal_activities.manageClearActivities(keep=0)
if portal_activities is not None:
if kw.get('update', 0):
keep = 1
else:
keep = 0
portal_activities.manageClearActivities(keep=keep)
# Add several other tools, only at the end in order # Add several other tools, only at the end in order
# to make sure that they will be reindexed # to make sure that they will be reindexed
......
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