0

有没有办法跟踪对工作流状态所做的更改,以便用户可以遵循我正在实施的流程。

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

我将把它留在这里,以帮助任何与我遇到同样问题的人。感谢您的提示!

4

3 回答 3

0

我已经使用 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

我将把它留在这里,以帮助任何与我遇到同样问题的人。

于 2014-04-07T10:56:26.987 回答
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"/>
于 2014-03-24T20:39:38.747 回答
-1

我们已经开发了一个模块来执行这个任务,如果其他人有需要可以从https://github.com/AC-Hoatzin/odoo-addons下载。

于 2015-03-02T20:17:35.750 回答