2
我正在自定義OpenERP。只要用戶創建產品,我就需要向所有「採購經理」顯示通知消息。Openerp - 創建產品時通過消息通知用戶
我看到一個消息下設置創建 - >電子郵件 - >消息說 「產品上創建的」。但它不顯示在主菜單消息 - >收件箱下的經理。
我想把這個消息作爲管理員的通知。但是,無法在Google中找到任何良好的文檔。
如果我缺少任何基本邏輯,請糾正我。
我正在自定義OpenERP。只要用戶創建產品,我就需要向所有「採購經理」顯示通知消息。Openerp - 創建產品時通過消息通知用戶
我看到一個消息下設置創建 - >電子郵件 - >消息說 「產品上創建的」。但它不顯示在主菜單消息 - >收件箱下的經理。
我想把這個消息作爲管理員的通知。但是,無法在Google中找到任何良好的文檔。
如果我缺少任何基本邏輯,請糾正我。
嘗試繼承產品模塊並重寫創建方法是這樣的:
def create(self, cr, uid, datas, context=None):
new_id = super(class_name, self).create(cr, uid, datas, context=context)
self.log_prod(cr, uid, new_id, context)
return new_id
def log_prod(self, cr, uid, ids, context=None):
product = self.pool.get('product.product').browse(cr, uid, ids)
msg = "Product %s has been created" % product.name
msg_id = self.message_post(cr, uid, ids, body=msg, context=context)
notif_obj = self.pool.get('mail.notification')
all_groups = self.pool.get('res.groups')
h1m_group = all_groups.browse(
cr,
uid,
all_groups.search(
cr,
uid,
[('name','=','Access Rights')],
))
for ids in h1m_group[0].users:
notif_obj.create(
cr,
uid,
{
'partner_id': ids.partner_id.id,
'read': False,
'message_id': msg_id,
},
context=context)
return True