有没有办法跟踪对工作流程状态所做的更改,以便用户可以完成我正在实施的流程。
Ex:
Created on March 1st, by User 1.
Submitted on March 1st, by User 1.
Reviewing on March 2nd, by Admin.
Evaluating on March 4th, by SuperUser.
Accepted on March 6th, by MegaUser.
因此,在创建请求时将插入拳头记录,在单击工作流程按钮“提交”时插入第二个;单击工作流程按钮“审核”时的第三个,依此类推。
非常欢迎任何想法或消息!
使用Audit Trail的记录不是一个选项。
提前致谢。 -FC。
我已经使用self.pool.get('obj_name')。create(cr,uid,values)在第二个表中创建新条目。
使用了这个功能:
def insert_trace(self, cr, uid, id_request, context=None):
request = self.browse(cr, uid, id_request, context)
values = {
'generic_request_id': id_request[0],
'executor': self._get_user(cr, uid, context),
'state': request[0].state,
}
tracing_ids = self.pool.get('tracing').create(cr, uid,values)
return True
并在每次工作流程发生变化时调用它,例如:
def request_draft(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'draft'})
self.insert_trace(cr, uid, ids, context)
return True
def submit_request(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'submitted'})
self.insert_trace(cr, uid, ids, context)
return True
我会把它留在这里,以帮助那些遇到同样问题的人。谢谢你的提示!
答案 0 :(得分:0)
让您的表继承mail.thread
,并让您的按钮向任何关注者发送消息。
这是我实施此项目的其中一个表格的精简版本:
class fnx_sr_shipping(osv.Model):
_name = 'fnx.sr.shipping'
_description = 'shipping & receiving'
_inherit = ['mail.thread']
_mail_flat_thread = False
...
def create(self, cr, uid, values, context=None):
...
body = "some message"
follower_ids = [47, 29, 31] # actual ids here
...
new_id = super(fnx_sr_shipping, self).create(cr, uid, values, context=context)
self.message_post(cr, uid, new_id, body=body,
partner_ids=follower_ids, subtype='mt_comment',
context=context)
return new_id
def sr_complete(self, cr, uid, ids, context=None):
...
for id in ids:
current = self.browse(cr, uid, id, context=context)
if self.write(cr, uid, id, values, context=context):
context['mail_create_nosubscribe'] = True
followers = self._get_followers(cr, uid, [id], None, None,
context=context)[id]['message_follower_ids']
message = 'Complete: ...'
self.message_post(cr, uid, id, body=message, subtype='mt_comment',
partner_ids=followers, context=context)
return True
然后在XML
文件中:
<button string="Complete" name="sr_complete" type="object"/>
答案 1 :(得分:0)
我使用self.pool.get(&#39; obj_name&#39;)创建(cr,uid,values)以在第二个表中创建新条目。
使用了这个功能:
def insert_trace(self, cr, uid, id_request, context=None):
request = self.browse(cr, uid, id_request, context)
values = {
'generic_request_id': id_request[0],
'executor': self._get_user(cr, uid, context),
'state': request[0].state,
}
tracing_ids = self.pool.get('tracing').create(cr, uid,values)
return True
并在每次工作流程发生变化时调用它,例如:
def request_draft(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'draft'})
self.insert_trace(cr, uid, ids, context)
return True
def submit_request(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'submitted'})
self.insert_trace(cr, uid, ids, context)
return True
我会把它留在这里,以帮助那些遇到同样问题的人。
答案 2 :(得分:-1)
我们已经开发了一个模块来执行此任务,如果有其他需要的人可以从https://github.com/AC-Hoatzin/odoo-addons下载。