Help

0

Automatically add follower to Sales Order if user(s) is a follower of the Contact - Odoo 10

Avatar
Ranpan

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.

Avatar
Discard
1 Answer
4
Avatar
Ray Carnes (ray)
Best Answer

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)
2 Comments
Avatar
Discard
Avatar
Kiran
-

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 ?

Avatar
Ray Carnes (ray)
-

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