ODOO 15通知导航返回任务/记录

发布于 2025-01-23 17:15:01 字数 1040 浏览 3 评论 0原文

我正在尝试向用户A发送通知,然后用户B批准了一项任务。 (但是使用odoobot用户)

notification_ids = [(0,0,{'res_partner_id':user_id.partner_id.id,'notification_type':'inbox'})]

self.sudo().message_post(subject=summary,body=summary_link,message_type='notification, subtype_xmlid='mail.mt_comment', author_id=odoo_bot_id.partner_id.id, notification_ids=notification_ids)

它正在工作,但现在我要这样做:

valueError:在业务文档上发布消息。使用Message_notify向用户发送通知。

if self._name == 'mail.thread' or not self.id or message_type == 'user_notification':
            raise ValueError(_('Posting a message should be done on a business document. Use message_notify to send a notification to an user.'))

不是self.id是什么意思

,我应该使用

message_notify_ids = [user_id.partner_id.id]

record.sudo().message_notify(partner_ids=message_notify_ids, parent_id=odoo_bot_id.partner_id.id, author_id=odoo_bot_id.partner_id.id,  body=summary_link, subject=summary)

以下显示弹出通知,但没有在索引中显示,以便用户可以导航到任务

I am trying to send notification to user A then user B Approves a task. (but using the odoobot user)

notification_ids = [(0,0,{'res_partner_id':user_id.partner_id.id,'notification_type':'inbox'})]

self.sudo().message_post(subject=summary,body=summary_link,message_type='notification, subtype_xmlid='mail.mt_comment', author_id=odoo_bot_id.partner_id.id, notification_ids=notification_ids)

it was working but now i am going this:

ValueError: Posting a message should be done on a business document. Use message_notify to send a notification to an user.

if self._name == 'mail.thread' or not self.id or message_type == 'user_notification':
            raise ValueError(_('Posting a message should be done on a business document. Use message_notify to send a notification to an user.'))

what does not self.id mean

according to this I should use

message_notify_ids = [user_id.partner_id.id]

record.sudo().message_notify(partner_ids=message_notify_ids, parent_id=odoo_bot_id.partner_id.id, author_id=odoo_bot_id.partner_id.id,  body=summary_link, subject=summary)

this shows the popup notification but does not show in the index so the user can navigate to the task

Odoo Form

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相对绾红妆 2025-01-30 17:15:01

当我记录self.id时,我得到了newID_26404,这是一个临时ID,因为该函数是在计算中运行的。

修复

record = record if isinstance(record.id,int) else record._origin

说明:丢弃更改确实在我的情况下发送了通知,因此最好将其添加到写功能中,

如果有更好的解决方案感谢,我对建议开放。

When I logged self.id I got NewId_26404 which is a temp id since the function was run in a compute.

Fix

record = record if isinstance(record.id,int) else record._origin

Note: discarding the changes did send the notification in my case, so it maybe better to add it in write function

I am open to suggestions if there is a better solution thank.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文