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

How do I automatically add all followers from the partner to any new Sales Order with the same Partner?

So when a sales order is placed it will add all users following the Partner of the Sales Order to the Sales Order.

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

An Automated Action (this example should work with v11 and v12) can combine the followers (this example adds ONLY followers who are Users) on the Sale Order and followers from the Customer:



Code to copy/paste:

partners_who_are_users = []
users = env['res.users'].search([])
for user in users:
partners_who_are_users.append(user.partner_id.id)

followers = []
for partner in record.partner_id.message_partner_ids.ids:
if partner in partners_who_are_users:
followers.append(partner)
record.message_subscribe(followers)
Ảnh đại diện
Huỷ bỏ

Hello @Ray,

I'm used your code but it is showing this type of error :

NameError: name 'records' is not defined

so what i do ?

"records" is not in my code. Please double check the code you are using.

Câu trả lời hay nhất

I have used the code to catch incoming messages and it works perfectly(Odoo 14). It add one user to follow lead eatch time I got a reply message:

lead= env['crm.lead'].search([('message_ids', '=', record.id)])
followers = []
followers.append(lead_id)
lead .message_subscribe(followers)

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

Please I need help.

I have used Ray Carnes solution with odoo 13 and it worked perfectly but suddenly it gives error says "Can not add the same partner twice"

Any solution please

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 23
3953
0
thg 3 15
3701
1
thg 1 17
2716
0
thg 3 15
3371
2
thg 5 24
1468