Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
9606 Lượt xem

Hi,

I am trying to setup an automated action which notifies a channel that a sales order has been placed on Odoo V11.

I have got it to post a flat message, but I want it to contain a link to the sales order which the user can click and gets taken to it.


In the automated action I have the below python code:

for rec in records:
  channel_id = env['mail.channel'].search([('id', '=', 29)])
  notification = ('<div class="sale.order"><a href="#" class="o_redirect" data-oe-id="%s">#%s</a></div>') % (rec.id, rec.name,)
  channel_id.message_post(
                        body='Order has been placed: '+str(rec.id)+' '+notification+' by: '+ str( env['res.users'].search([('id', '=',rec.create_uid.id)]).name )+ '',
                        subtype='mail.mt_comment')


This comes up with the error message "Record does not exist or has been deleted."

Does anyone know where I am going wrong?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

It happens because the channel of Id=29, does not exist. Make sure that the id of channel is 29. Or use other search criteria for searching the mail channel.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
5438
3
thg 4 24
2084
1
thg 9 23
1962
5
thg 7 20
5877
0
thg 3 17
3056