[分享]几个查询工作流数据的SQL
-
下面是经常用的几个查询工作流数据的SQL,比界面上查询用着顺,就写下来了
--查询某个工作流的activity和transition
select
a.name,a.osv,a.on_create,
d.id,d.condition,d.group_id,d.signal,
b.id as from_act_id,b.name as from_action,b.split_mode,b.join_mode,b.kind,
c.id as to_act_id,c.name as to_action,c.split_mode,c.join_mode,c.kind
from wkf a
join wkf_activity b on a.id = b.wkf_id
join wkf_activity c on a.id = c.wkf_id
join wkf_transition d on b.id = d.act_from and c.id = d.act_to
where a.osv = 'sale.order'
--and b.name in('sent' ,'router', 'wait_invoice','wait_ship','ship')
order by b.name
--查询某个对象的工作流实例的workitem
select a.inst_id,a.act_id,c.name as act_name,a.state, c.split_mode,c.join_mode,c.kind
from wkf_workitem a
join wkf_instance b on a.inst_id = b.id
join wkf_activity c on a.act_id = c.id
where b.res_type = 'sale.order'
and b.res_id = 53
--查询某个对象的工作流实例的log
select a.* ,b.name as act_name
from wkf_logs a
join wkf_activity b on a.act_id = b.id
where res_id = 53 and res_type = 'sale.order'