Merge lp:~openerp-dev/openobject-server/trunk-for-caribou-jam into lp:openobject-server

Proposed by Vo Minh Thu
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-server/trunk-for-caribou-jam
Merge into: lp:openobject-server
Diff against target: 392 lines (+149/-51)
9 files modified
openerp-server (+2/-0)
openerp/addons/base/ir/workflow/print_instance.py (+63/-37)
openerp/modules/loading.py (+0/-2)
openerp/osv/orm.py (+2/-2)
openerp/tests/test_ir_sequence.py (+3/-0)
openerp/tools/convert.py (+5/-2)
openerp/workflow/instance.py (+10/-1)
openerp/workflow/wkf_service.py (+13/-2)
openerp/workflow/workitem.py (+51/-5)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-for-caribou-jam
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+118926@code.launchpad.net
To post a comment you must log in.
4246. By Jigar A.

[MERGE] lp:openobject-server

4247. By Jigar A.

[MERGE] lp:openobject-server

4248. By Jigar A.

[MERGE] lp:openobject-server

4249. By Jigar A.

[MERGE] lp:~openerp-dev/openobject-server/trunk-for-caribou-demo-tpa

4250. By Jigar A.

merge lp:openobject-server

4251. By Jigar A.

merge lp:openobject-server

4252. By Jigar A.

[merge] lp:openobject-server

4253. By Jigar A.

[FIX] Workflow node fix, patch by Vo Minh Thu

4254. By Jigar A.

merge lp:openobject-server

4255. By Jigar A.

merge lp:openobject-server

4256. By Jigar A.

[FIX] remvoed conflicts

4257. By Vo Minh Thu

[IMP] workflow: only use already loaded transitions during an update.

4258. By Jigar A.

Merge lp:openobject-server

4259. By Vo Minh Thu

[MERGE] merged trunk.

4260. By Vo Minh Thu

[IMP] loading: only CSV are in a forced noupdate, other data rely on the noupdate attr. in the XML file.

4261. By Jigar A.

[MERGE] Merged lp:openobject-server

4262. By Jigar A.

[MERGE] Merged lp:opeenobject-server

4263. By Vo Minh Thu

[FIX] workflow: during an update consider only workflows from already loaded modules.

4264. By Vo Minh Thu

[MERGE] merged trunk.

4265. By Jigar A.

[MERGE] lp:openobject-server

4266. By Jigar A.

[MERGE] lp:openobject-server

4267. By Jigar A.

[MERGE] lp:openobject-server

4268. By Vo Minh Thu

[IMP] workflow: consider only transitions and activities from loaded modules (useful during an update).

4269. By Vo Minh Thu

[FIX] workflows: the similarly-named columns in results of a select * with a join in SQL queries are overwritten, so use explicit column names.

4270. By Vo Minh Thu

[MERGE] merged trunk.

4271. By Vo Minh Thu

[FIX] workflow: consider only transitions from already loaded modules.

4272. By Vo Minh Thu

[MERGE] merged trunk.

4273. By Jigar A.

[MERGE] lp:openobject-server

4274. By Jigar A.

[MERGE] Sync with Trunk

4275. By Jigar A.

[MERGE] Sync with Trunk

Revision history for this message
Vo Minh Thu (thu) wrote :

This branch makes a few changes to the server to make it possible 1/ to install the demo data, 2/ to run the tests with a single update (i.e. the -u command-line flag) and have the tests pass.

This is intended to somewhat test a migrated database (which would normally not contain the demo data necessary to properly run the tests). The only trick is to set demo=True on the ir_module_module table before proceeding to the update.

So let's go through this.

- Changes in openerp/addons/base/ir/workflow/print_instance.py don't matter, this is just some minimal refactoring and exposes the ability to dump workflows as SVGs on disk.

- The if self.pool._init and False: in orm.py should clearly be reverted. This means that computing the left/right parents can't be deferred to after the tests (i.e. some tests need that information to be available).

- Changes in openerp/tests/test_ir_sequence.py are made to make sure the tests on ir_sequence can be played over again (i.e. one run doesn't affect the next run).

- Changes in openerp/tools/convert.py are made so we know which data are fresh (i.e. we just created them while reading the imported file): if the data is new, let the workflow run. Maybe it is not necessary any more because of the new noupdate semantic (see next bullet point).

- Changes in openerp/modules/loading.py: noupdate is forced only for CSV files. Otherwise, the noupdate attribute is honored (previously, demo data were always in noupdate).

- The openerp/workflow sub-module is changed to ignore activities and transitions that are available in db but defined by modules not already loaded (this is necessary to let workflows run in tests, while being in the middle of the update module graph).

4276. By Olivier Laurent (Open ERP)

[MERGE] merge with trunk

4277. By Olivier Laurent (Open ERP)

[FIX] re-raise exception in case of error

Revision history for this message
Vo Minh Thu (thu) wrote :

There is a leftover of some pydb import/call.

4278. By Vo Minh Thu

[REV] reverted leftover pydb call.

4279. By Vo Minh Thu

[MERGE]merged trunk.

Unmerged revisions

4279. By Vo Minh Thu

[MERGE]merged trunk.

4278. By Vo Minh Thu

[REV] reverted leftover pydb call.

4277. By Olivier Laurent (Open ERP)

[FIX] re-raise exception in case of error

4276. By Olivier Laurent (Open ERP)

[MERGE] merge with trunk

4275. By Jigar A.

[MERGE] Sync with Trunk

4274. By Jigar A.

[MERGE] Sync with Trunk

4273. By Jigar A.

[MERGE] lp:openobject-server

4272. By Vo Minh Thu

[MERGE] merged trunk.

4271. By Vo Minh Thu

[FIX] workflow: consider only transitions from already loaded modules.

4270. By Vo Minh Thu

[MERGE] merged trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp-server'
--- openerp-server 2012-10-29 17:33:21 +0000
+++ openerp-server 2012-11-09 14:23:22 +0000
@@ -97,6 +97,7 @@
97 registry.schedule_cron_jobs()97 registry.schedule_cron_jobs()
98 except Exception:98 except Exception:
99 _logger.exception('Failed to initialize database `%s`.', dbname)99 _logger.exception('Failed to initialize database `%s`.', dbname)
100 raise
100101
101def run_test_file(dbname, test_file):102def run_test_file(dbname, test_file):
102 """ Preload a registry, possibly run a test file, and start the cron."""103 """ Preload a registry, possibly run a test file, and start the cron."""
@@ -110,6 +111,7 @@
110 cr.close()111 cr.close()
111 except Exception:112 except Exception:
112 _logger.exception('Failed to initialize database `%s` and run test file `%s`.', dbname, test_file)113 _logger.exception('Failed to initialize database `%s` and run test file `%s`.', dbname, test_file)
114 raise
113115
114def export_translation():116def export_translation():
115 config = openerp.tools.config117 config = openerp.tools.config
116118
=== modified file 'openerp/addons/base/ir/workflow/print_instance.py'
--- openerp/addons/base/ir/workflow/print_instance.py 2012-02-02 12:54:42 +0000
+++ openerp/addons/base/ir/workflow/print_instance.py 2012-11-09 14:23:22 +0000
@@ -123,12 +123,35 @@
123 processed_subflows = set()123 processed_subflows = set()
124 graph_get(cr, graph, [x[0] for x in inst], nested, workitem_get(inst_id), processed_subflows)124 graph_get(cr, graph, [x[0] for x in inst], nested, workitem_get(inst_id), processed_subflows)
125125
126#126def create_dot_graph(cr, model_name, workflow_name, nested, inst_ids):
127# TODO: pas clean: concurrent !!!127 import pydot
128#128 graph = pydot.Dot(
129 graph_name=model_name.replace('.','_'),
130 fontsize='16',
131 label="""\\n\\nWorkflow: %s\\n Model: %s""" % (workflow_name, model_name),
132 size='7.3, 10.1', center='1', ratio='auto', rotate='0', rankdir='TB',
133 )
134 for inst_id in inst_ids:
135 graph_instance_get(cr, graph, inst_id[0], nested)
136 return graph
137
138def write_dot_graph_svg(graph, filename):
139 graph.write(filename, prog='dot', format='svg')
140
141def write_workflow_svg(cr, model_name, res_id, filename):
142 cr.execute('select name from wkf where osv=%s limit 1', (model_name,))
143 workflow = cr.dictfetchone()
144 cr.execute('select i.id from wkf_instance i left join wkf w on (i.wkf_id=w.id) where res_id=%s and osv=%s', (res_id, model_name))
145 instances = cr.fetchall()
146 graph = create_dot_graph(cr, model_name, workflow['name'] if workflow else 'NO WORKFLOW', True, instances)
147 write_dot_graph_svg(graph, filename)
129148
130class report_graph_instance(object):149class report_graph_instance(object):
131 def __init__(self, cr, uid, ids, data):150 def __init__(self, cr, uid, ids, data):
151 model_name = data['model']
152 res_id = data['id']
153 nested = data.get('nested', False)
154
132 try:155 try:
133 import pydot156 import pydot
134 except Exception,e:157 except Exception,e:
@@ -136,48 +159,29 @@
136 'Import Error for pydot, you will not be able to render workflows.\n'159 'Import Error for pydot, you will not be able to render workflows.\n'
137 'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html.')160 'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html.')
138 raise e161 raise e
162
163 # TODO: make it thread-safe.
139 self.done = False164 self.done = False
140165
166 # Create a Dot graph and render it as a PS string.
141 try:167 try:
142 cr.execute('select * from wkf where osv=%s limit 1',168 cr.execute('select name from wkf where osv=%s limit 1', (model_name,))
143 (data['model'],))
144 wkfinfo = cr.dictfetchone()169 wkfinfo = cr.dictfetchone()
170 cr.execute('select i.id from wkf_instance i left join wkf w on (i.wkf_id=w.id) where res_id=%s and osv=%s', (res_id, model_name))
171 inst_ids = cr.fetchall()
145 if not wkfinfo:172 if not wkfinfo:
146 ps_string = '''%PS-Adobe-3.0173 ps_string = NO_DEFINED_WORKFLOW
147/inch {72 mul} def174 elif not inst_ids:
148/Times-Roman findfont 50 scalefont setfont175 ps_string = NO_DEFINED_INSTANCE
1491.5 inch 15 inch moveto
150(No workflow defined) show
151showpage'''
152 else:176 else:
153 cr.execute('select i.id from wkf_instance i left join wkf w on (i.wkf_id=w.id) where res_id=%s and osv=%s',(data['id'],data['model']))177 graph = create_dot_graph(cr, model_name, wkfinfo['name'], nested, inst_ids)
154 inst_ids = cr.fetchall()178 ps_string = graph.create(prog='dot', format='ps')
155 if not inst_ids:
156 ps_string = '''%PS-Adobe-3.0
157/inch {72 mul} def
158/Times-Roman findfont 50 scalefont setfont
1591.5 inch 15 inch moveto
160(No workflow instance defined) show
161showpage'''
162 else:
163 graph = pydot.Dot(graph_name=data['model'].replace('.','_'),
164 fontsize='16',
165 label="""\\\n\\nWorkflow: %s\\n OSV: %s""" % (wkfinfo['name'],wkfinfo['osv']),
166 size='7.3, 10.1', center='1', ratio='auto', rotate='0', rankdir='TB',
167 )
168 for inst_id in inst_ids:
169 inst_id = inst_id[0]
170 graph_instance_get(cr, graph, inst_id, data.get('nested', False))
171 ps_string = graph.create(prog='dot', format='ps')
172 except Exception, e:179 except Exception, e:
173 _logger.exception('Exception in call:')180 _logger.exception('Exception in call:')
174 # string is in PS, like the success message would have been181 # Don't raise the exception but set an error message in the PS string.
175 ps_string = '''%PS-Adobe-3.0182 ps_string = NO_WORKFLOW
176/inch {72 mul} def183
177/Times-Roman findfont 50 scalefont setfont184 # Convert the PS string to a PDF file.
1781.5 inch 15 inch moveto
179(No workflow available) show
180showpage'''
181 if os.name == "nt":185 if os.name == "nt":
182 prog = 'ps2pdf.bat'186 prog = 'ps2pdf.bat'
183 else:187 else:
@@ -188,6 +192,7 @@
188 input.close()192 input.close()
189 self.result = output.read()193 self.result = output.read()
190 output.close()194 output.close()
195
191 self.done = True196 self.done = True
192197
193 def is_done(self):198 def is_done(self):
@@ -216,5 +221,26 @@
216221
217report_graph('report.workflow.instance.graph', 'ir.workflow')222report_graph('report.workflow.instance.graph', 'ir.workflow')
218223
224NO_DEFINED_WORKFLOW='''%PS-Adobe-3.0
225/inch {72 mul} def
226/Times-Roman findfont 50 scalefont setfont
2271.5 inch 15 inch moveto
228(No workflow defined) show
229showpage'''
230
231NO_DEFINED_INSTANCE='''%PS-Adobe-3.0
232/inch {72 mul} def
233/Times-Roman findfont 50 scalefont setfont
2341.5 inch 15 inch moveto
235(No workflow instance defined) show
236showpage'''
237
238NO_WORKFLOW='''%PS-Adobe-3.0
239/inch {72 mul} def
240/Times-Roman findfont 50 scalefont setfont
2411.5 inch 15 inch moveto
242(No workflow available) show
243showpage'''
244
219# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:245# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
220246
221247
=== modified file 'openerp/modules/loading.py'
--- openerp/modules/loading.py 2012-11-02 13:47:32 +0000
+++ openerp/modules/loading.py 2012-11-09 14:23:22 +0000
@@ -109,8 +109,6 @@
109 pathname = os.path.join(module_name, filename)109 pathname = os.path.join(module_name, filename)
110 fp = tools.file_open(pathname)110 fp = tools.file_open(pathname)
111 noupdate = False111 noupdate = False
112 if kind in ('demo', 'demo_xml'):
113 noupdate = True
114 try:112 try:
115 if ext == '.csv':113 if ext == '.csv':
116 if kind in ('init', 'init_xml'):114 if kind in ('init', 'init_xml'):
117115
=== modified file 'openerp/osv/orm.py'
--- openerp/osv/orm.py 2012-11-09 11:39:51 +0000
+++ openerp/osv/orm.py 2012-11-09 14:23:22 +0000
@@ -4147,7 +4147,7 @@
4147 # fields that are computer may refer (directly or indirectly) to4147 # fields that are computer may refer (directly or indirectly) to
4148 # parent_left/right (via a child_of domain)4148 # parent_left/right (via a child_of domain)
4149 if parents_changed:4149 if parents_changed:
4150 if self.pool._init:4150 if self.pool._init and False:
4151 self.pool._init_parent[self._name] = True4151 self.pool._init_parent[self._name] = True
4152 else:4152 else:
4153 order = self._parent_order or self._order4153 order = self._parent_order or self._order
@@ -4373,7 +4373,7 @@
4373 upd_todo.sort(lambda x, y: self._columns[x].priority-self._columns[y].priority)4373 upd_todo.sort(lambda x, y: self._columns[x].priority-self._columns[y].priority)
43744374
4375 if self._parent_store and not context.get('defer_parent_store_computation'):4375 if self._parent_store and not context.get('defer_parent_store_computation'):
4376 if self.pool._init:4376 if self.pool._init and False:
4377 self.pool._init_parent[self._name] = True4377 self.pool._init_parent[self._name] = True
4378 else:4378 else:
4379 parent = vals.get(self._parent_name, False)4379 parent = vals.get(self._parent_name, False)
43804380
=== modified file 'openerp/tests/test_ir_sequence.py'
--- openerp/tests/test_ir_sequence.py 2012-11-07 11:10:11 +0000
+++ openerp/tests/test_ir_sequence.py 2012-11-09 14:23:22 +0000
@@ -161,6 +161,9 @@
161 ids = registry('ir.sequence').search(cr, ADMIN_USER_ID,161 ids = registry('ir.sequence').search(cr, ADMIN_USER_ID,
162 [('code', 'in', ['test_sequence_type_3', 'test_sequence_type_4'])], {})162 [('code', 'in', ['test_sequence_type_3', 'test_sequence_type_4'])], {})
163 registry('ir.sequence').unlink(cr, ADMIN_USER_ID, ids, {})163 registry('ir.sequence').unlink(cr, ADMIN_USER_ID, ids, {})
164 ids = registry('ir.sequence.type').search(cr, ADMIN_USER_ID,
165 [('code', 'in', ['test_sequence_type_3', 'test_sequence_type_4'])], {})
166 registry('ir.sequence.type').unlink(cr, ADMIN_USER_ID, ids, {})
164 cr.commit()167 cr.commit()
165 cr.close()168 cr.close()
166169
167170
=== modified file 'openerp/tools/convert.py'
--- openerp/tools/convert.py 2012-10-01 14:49:41 +0000
+++ openerp/tools/convert.py 2012-11-09 14:23:22 +0000
@@ -508,10 +508,11 @@
508 self.pool.get('ir.model.data').ir_set(cr, self.uid, res['key'], res['key2'], res['name'], res['models'], res['value'], replace=res.get('replace',True), isobject=res.get('isobject', False), meta=res.get('meta',None))508 self.pool.get('ir.model.data').ir_set(cr, self.uid, res['key'], res['key2'], res['name'], res['models'], res['value'], replace=res.get('replace',True), isobject=res.get('isobject', False), meta=res.get('meta',None))
509509
510 def _tag_workflow(self, cr, rec, data_node=None):510 def _tag_workflow(self, cr, rec, data_node=None):
511 if self.isnoupdate(data_node) and self.mode != 'init':511 w_ref = rec.get('ref','')
512 if self.isnoupdate(data_node) and self.mode != 'init' and w_ref not in self.just_created:
512 return513 return
513 model = str(rec.get('model',''))514 model = str(rec.get('model',''))
514 w_ref = rec.get('ref','')515
515 if w_ref:516 if w_ref:
516 id = self.id_get(cr, w_ref)517 id = self.id_get(cr, w_ref)
517 else:518 else:
@@ -814,6 +815,7 @@
814815
815 id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )816 id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
816 if rec_id:817 if rec_id:
818 self.just_created.add(rec_id)
817 self.idref[rec_id] = int(id)819 self.idref[rec_id] = int(id)
818 if config.get('import_partial', False):820 if config.get('import_partial', False):
819 cr.commit()821 cr.commit()
@@ -867,6 +869,7 @@
867 report = assertion_report.assertion_report()869 report = assertion_report.assertion_report()
868 self.assertion_report = report870 self.assertion_report = report
869 self.noupdate = noupdate871 self.noupdate = noupdate
872 self.just_created = set()
870 self._tags = {873 self._tags = {
871 'menuitem': self._tag_menuitem,874 'menuitem': self._tag_menuitem,
872 'record': self._tag_record,875 'record': self._tag_record,
873876
=== modified file 'openerp/workflow/instance.py'
--- openerp/workflow/instance.py 2011-02-07 12:57:23 +0000
+++ openerp/workflow/instance.py 2012-11-09 14:23:22 +0000
@@ -29,7 +29,16 @@
29 (uid,res_type,res_id) = ident29 (uid,res_type,res_id) = ident
30 cr.execute('insert into wkf_instance (res_type,res_id,uid,wkf_id) values (%s,%s,%s,%s) RETURNING id', (res_type,res_id,uid,wkf_id))30 cr.execute('insert into wkf_instance (res_type,res_id,uid,wkf_id) values (%s,%s,%s,%s) RETURNING id', (res_type,res_id,uid,wkf_id))
31 id_new = cr.fetchone()[0]31 id_new = cr.fetchone()[0]
32 cr.execute('select * from wkf_activity where flow_start=True and wkf_id=%s', (wkf_id,))32 import openerp
33 pool = openerp.modules.registry.RegistryManager.registries[cr.dbname]
34 if pool._init:
35 # Module init currently in progress, only consider activities from modules whose code was already loaded
36 cr.execute("""select wkf_activity.id from wkf_activity left join ir_model_data md on
37 (md.model = 'workflow.activity' and md.res_id = wkf_activity.id)
38 where flow_start=True and wkf_id=%s and md.module in %s""",
39 (wkf_id, tuple(pool._init_modules)))
40 else:
41 cr.execute('select id from wkf_activity where flow_start=True and wkf_id=%s', (wkf_id,))
33 res = cr.dictfetchall()42 res = cr.dictfetchall()
34 stack = []43 stack = []
35 workitem.create(cr, res, id_new, ident, stack=stack)44 workitem.create(cr, res, id_new, ident, stack=stack)
3645
=== modified file 'openerp/workflow/wkf_service.py'
--- openerp/workflow/wkf_service.py 2011-09-24 14:52:58 +0000
+++ openerp/workflow/wkf_service.py 2012-11-09 14:23:22 +0000
@@ -101,7 +101,16 @@
101 if res_type in self.wkf_on_create_cache[cr.dbname]:101 if res_type in self.wkf_on_create_cache[cr.dbname]:
102 wkf_ids = self.wkf_on_create_cache[cr.dbname][res_type]102 wkf_ids = self.wkf_on_create_cache[cr.dbname][res_type]
103 else:103 else:
104 cr.execute('select id from wkf where osv=%s and on_create=True', (res_type,))104 import openerp
105 pool = openerp.modules.registry.RegistryManager.registries[cr.dbname]
106 if pool._init and pool._init_modules:
107 # Module init currently in progress, only consider transitions from modules whose code was already loaded
108 cr.execute("""select wkf.id from wkf left join ir_model_data md on
109 (md.model = 'workflow' and md.res_id = wkf.id)
110 where osv=%s and on_create=True and md.module in %s""",
111 (res_type, tuple(pool._init_modules)))
112 else:
113 cr.execute('select id from wkf where osv=%s and on_create=True', (res_type,))
105 wkf_ids = cr.fetchall()114 wkf_ids = cr.fetchall()
106 self.wkf_on_create_cache[cr.dbname][res_type] = wkf_ids115 self.wkf_on_create_cache[cr.dbname][res_type] = wkf_ids
107 for (wkf_id,) in wkf_ids:116 for (wkf_id,) in wkf_ids:
@@ -120,7 +129,9 @@
120 ident = (uid,res_type,res_id)129 ident = (uid,res_type,res_id)
121 # ids of all active workflow instances for a corresponding resource (id, model_nam)130 # ids of all active workflow instances for a corresponding resource (id, model_nam)
122 cr.execute('select id from wkf_instance where res_id=%s and res_type=%s and state=%s', (res_id, res_type, 'active'))131 cr.execute('select id from wkf_instance where res_id=%s and res_type=%s and state=%s', (res_id, res_type, 'active'))
123 for (id,) in cr.fetchall():132 res = cr.fetchall()
133 assert len(res) <= 1 # TODO make (res_type, res_id) unique?
134 for (id,) in res:
124 res2 = instance.validate(cr, id, ident, signal)135 res2 = instance.validate(cr, id, ident, signal)
125 result = result or res2136 result = result or res2
126 return result137 return result
127138
=== modified file 'openerp/workflow/workitem.py'
--- openerp/workflow/workitem.py 2011-12-11 10:21:40 +0000
+++ openerp/workflow/workitem.py 2012-11-09 14:23:22 +0000
@@ -44,7 +44,16 @@
44 if stack is None:44 if stack is None:
45 raise 'Error !!!'45 raise 'Error !!!'
46 result = True46 result = True
47 cr.execute('select * from wkf_activity where id=%s', (workitem['act_id'],))47 import openerp
48 pool = openerp.modules.registry.RegistryManager.registries[cr.dbname]
49 if pool._init:
50 # Module init currently in progress, only consider activities from modules whose code was already loaded
51 cr.execute("""select wkf_activity.id, split_mode, signal_send, kind, action, action_id, subflow_id from wkf_activity left join ir_model_data md on
52 (md.model = 'workflow.activity' and md.res_id = wkf_activity.id)
53 where wkf_activity.id=%s and md.module in %s""",
54 (workitem['act_id'], tuple(pool._init_modules)))
55 else:
56 cr.execute('select id, split_mode, signal_send, kind, action, action_id, subflow_id from wkf_activity where id=%s', (workitem['act_id'],))
48 activity = cr.dictfetchone()57 activity = cr.dictfetchone()
4958
50 triggers = False59 triggers = False
@@ -62,7 +71,14 @@
62 triggers = triggers and not ok71 triggers = triggers and not ok
6372
64 if triggers:73 if triggers:
65 cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],))74 if pool._init:
75 # Module init currently in progress, only consider transitions from modules whose code was already loaded
76 cr.execute("""select wkf_transition.id, trigger_model, trigger_expr_id from wkf_transition left join ir_model_data md on
77 (md.model = 'workflow.transition' and md.res_id = wkf_transition.id)
78 where act_from=%s and md.module in %s""",
79 (workitem['act_id'], tuple(pool._init_modules)))
80 else:
81 cr.execute('select id, trigger_model, trigger_expr_id from wkf_transition where act_from=%s', (workitem['act_id'],))
66 alltrans = cr.dictfetchall()82 alltrans = cr.dictfetchall()
67 for trans in alltrans:83 for trans in alltrans:
68 if trans['trigger_model']:84 if trans['trigger_model']:
@@ -149,7 +165,16 @@
149def _split_test(cr, workitem, split_mode, ident, signal=None, stack=None):165def _split_test(cr, workitem, split_mode, ident, signal=None, stack=None):
150 if stack is None:166 if stack is None:
151 raise 'Error !!!'167 raise 'Error !!!'
152 cr.execute('select * from wkf_transition where act_from=%s', (workitem['act_id'],))168 import openerp
169 pool = openerp.modules.registry.RegistryManager.registries[cr.dbname]
170 if pool._init:
171 # Module init currently in progress, only consider transitions from modules whose code was already loaded
172 cr.execute("""select wkf_transition.id, signal, group_id, condition from wkf_transition left join ir_model_data md on
173 (md.model = 'workflow.transition' and md.res_id = wkf_transition.id)
174 where act_from=%s and md.module in %s""",
175 (workitem['act_id'], tuple(pool._init_modules)))
176 else:
177 cr.execute('select id, signal, group_id, condition from wkf_transition where act_from=%s', (workitem['act_id'],))
153 test = False178 test = False
154 transitions = []179 transitions = []
155 alltrans = cr.dictfetchall()180 alltrans = cr.dictfetchall()
@@ -178,13 +203,34 @@
178 return False203 return False
179204
180def _join_test(cr, trans_id, inst_id, ident, stack):205def _join_test(cr, trans_id, inst_id, ident, stack):
181 cr.execute('select * from wkf_activity where id=(select act_to from wkf_transition where id=%s)', (trans_id,))206 import openerp
207 pool = openerp.modules.registry.RegistryManager.registries[cr.dbname]
208 if pool._init:
209 # Module init currently in progress, only consider activities from modules whose code was already loaded
210 cr.execute("""select wkf_activity.id, join_mode from wkf_activity left join ir_model_data md on
211 (md.model = 'workflow.activity' and md.res_id = wkf_activity.id)
212 where wkf_activity.id=
213 (select act_to from wkf_transition left join ir_model_data md on
214 (md.model = 'workflow.transition' and md.res_id = wkf_transition.id)
215 where wkf_transition.id=%s and md.module in %s
216 )
217 and md.module in %s""",
218 (trans_id, tuple(pool._init_modules), tuple(pool._init_modules)))
219 else:
220 cr.execute('select id, join_mode from wkf_activity where id=(select act_to from wkf_transition where id=%s)', (trans_id,))
182 activity = cr.dictfetchone()221 activity = cr.dictfetchone()
183 if activity['join_mode']=='XOR':222 if activity['join_mode']=='XOR':
184 create(cr,[activity], inst_id, ident, stack)223 create(cr,[activity], inst_id, ident, stack)
185 cr.execute('delete from wkf_witm_trans where inst_id=%s and trans_id=%s', (inst_id,trans_id))224 cr.execute('delete from wkf_witm_trans where inst_id=%s and trans_id=%s', (inst_id,trans_id))
186 else:225 else:
187 cr.execute('select id from wkf_transition where act_to=%s', (activity['id'],))226 if pool._init:
227 # Module init currently in progress, only consider transitions from modules whose code was already loaded
228 cr.execute("""select wkf_transition.id from wkf_transition left join ir_model_data md on
229 (md.model = 'workflow.transition' and md.res_id = wkf_transition.id)
230 where act_to=%s and md.module in %s""",
231 (activity['id'], tuple(pool._init_modules)))
232 else:
233 cr.execute('select id from wkf_transition where act_to=%s', (activity['id'],))
188 trans_ids = cr.fetchall()234 trans_ids = cr.fetchall()
189 ok = True235 ok = True
190 for (id,) in trans_ids:236 for (id,) in trans_ids: