Aug 9, 2019

all about followers odoo

just as your inspiration only.

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

10/18/18, 3:53 AM 1,075 views
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.



2
Ray Carnes United States
 10/18/18, 9:56 AM
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)

=========================  

add followers automatically

12/18/13, 5:27 AM 10,045 views
Hello in crm.lead the responsible user (user_id) is automatically added as follower to the new task. How can I add this functionality to add some users to my custom object?



3
Ray Carnes United States
 2/9/18, 3:16 AM
To expand on David's answer, I needed to add the Customer as a follower on a LEAD in v10.
I created an Automated Action that looked for crm.lead records created or updated that also had either a Customer or Email populated.
If the record had a Customer, I needed to just add that Customer as a follower (as long as it wasn't already).
If the record had an Email, I needed to check if a Customer already existed, and if not - create them.
This is the code I used for the Server Action:
if record.partner_id: 
    partner = record.partner_id  
else: 
    partner = env['res.partner'].search([('email','=',record.email_from)]) 
if not partner: 
    reg = { 
           'name': record.contact_name or record.email_from, 
           'email': record.email_from, 
           'type': 'contact', 
          } 
    partner = env['res.partner'].create(reg) 
partner_id = partner.id 
reg = { 
       'res_id': record.id, 
       'res_model': 'crm.lead', 
       'partner_id': partner_id, 
      } 
if not env['mail.followers'].search([('res_id','=',record.id),('res_model','=','crm.lead'),('partner_id','=',partner_id)]): 
    follower_id = env['mail.followers'].create(reg)

.
just as your inspiration only.

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

10/18/18, 3:53 AM 1,075 views
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.



2
Ray Carnes United States
 10/18/18, 9:56 AM
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)

=========================  

add followers automatically

12/18/13, 5:27 AM 10,045 views
Hello in crm.lead the responsible user (user_id) is automatically added as follower to the new task. How can I add this functionality to add some users to my custom object?



3
Ray Carnes United States
 2/9/18, 3:16 AM
To expand on David's answer, I needed to add the Customer as a follower on a LEAD in v10.
I created an Automated Action that looked for crm.lead records created or updated that also had either a Customer or Email populated.
If the record had a Customer, I needed to just add that Customer as a follower (as long as it wasn't already).
If the record had an Email, I needed to check if a Customer already existed, and if not - create them.
This is the code I used for the Server Action:
if record.partner_id: 
    partner = record.partner_id  
else: 
    partner = env['res.partner'].search([('email','=',record.email_from)]) 
if not partner: 
    reg = { 
           'name': record.contact_name or record.email_from, 
           'email': record.email_from, 
           'type': 'contact', 
          } 
    partner = env['res.partner'].create(reg) 
partner_id = partner.id 
reg = { 
       'res_id': record.id, 
       'res_model': 'crm.lead', 
       'partner_id': partner_id, 
      } 
if not env['mail.followers'].search([('res_id','=',record.id),('res_model','=','crm.lead'),('partner_id','=',partner_id)]): 
    follower_id = env['mail.followers'].create(reg)

No comments:

Post a Comment