2014-03-24 50 views
0

是否有方法跟蹤對工作流狀態所做的更改,以便用戶可以按照我正在實施的流程進行操作。跟蹤OpenERP 7.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')。創建(CR,UID,值)來創建在第二個表新條目。

使用此功能:

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

讓你的表繼承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"/> 
+0

感謝您的回答,但我想我對我的解釋並不清楚。 我希望更改存儲在數據庫上,並在窗體視圖中顯示頁面上每個請求的跟蹤。 這樣,用戶在任何時候都可以看到流程演變,他的當前狀態以及在給定時刻負責誰。 –

+0

@FilipeCastanheira:也許'OpenChatter'就是你想要的。它顯示在表單視圖底部發送的所有消息。否則,您需要創建一個帶有「one2many」鏈接的單獨的「歷史」表,在那裏記錄您的條目,並將其添加爲「筆記本」頁面。 –

+0

謝謝,我會嘗試。 –

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 

在這裏我要離開這個,幫,帶,我是同樣的問題,任何人有。