Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

add followers automatically

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
followermailopenerp
8 Risposte
38695 Visualizzazioni
Avatar
sayed fathy

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?

5
Avatar
Abbandona
Gopakumar N G

Write to the message_follower_ids field.

sayed fathy
Autore

Please, can you explain more!

Matteo Boscolo

You can overwrite the create function and inject the ids on the message_follower_ids

sayed fathy
Autore

it returns false

Aldennis

In your custom module, add a field like this: 'user_id': fields.many2one('res.users', 'Anyname', select=True, track_visibility='onchange'), Then create a record and click Save. The user you specified in user_id field will automatically added on the list of followers

sayed fathy
Autore

What if i want to add follower not user_id field or the parent of the user_id field

Avatar
Ray Carnes
Risposta migliore

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)
5
Avatar
Abbandona
Brandon Lackey

This code works in v16. However, I have to manually add them to "Discussions" to be able to use the "Send message" function in chatter. Is there a way to modify this code to be able to do that with the automation?

Ray Carnes (ray)

You need to specify the Discussions Subtype when creating the mail.follower record on the last line. To do this add the subtype to the reg dictionary being used - the one containing the res_id field (not the first one being used to create the partner). Add a new line: 'subtype_ids': [env.ref('mail.mt_comment').id]

Avatar
David Todd
Risposta migliore

You've probably either already found your answer, or don't need it anymore, but I found myself having the same need to automatically add specific followers on my module written for Odoo v9. Here's my approach for the future people who have a similar question.

Preface: In my module, we do use the mail.message widget on our forms, but we use it as an automatic change tracker for auditing purposes. This allows us to see every change that was made to a form between saves, and which user made these changes. In the module I'm currently making, we want to be able to add specific people as followers when the form is in a specific stage.

First things first, we need a list of users that will become followers depending on the stage. Rather than hardcode them (we have a high turnover rate and it would introduce unnecessary updates), I'm creating a model called stage_followers that only users of the admin group can create/write/unlink. Normal users have only read access to that model.

First my model.py. On your actual form model, make sure you also have a stage selection field that is exactly the same. This will be used later in the write override

from openerp import models, fields
class stage_followers(models.Model):
_name = 'mymodule.stage_followers'
user = fields.Many2one('res.partner', required=True, domain=[('parent_id.name', '=', 'MyCompany')], string='User')
stage = fields.Selection(selection=yourStages, default='initial', string='Stage')

Next, my views.xml

<record model="ir.ui.view" id="mymodule.settings_sfollowers_form">
<field name="name">mymodule.settings_sfollowers.form</field>
<field name="model">mymodule.stage_followers</field>
<field name="arch" type="xml">
<form>
<field name="user" />
<field name="stage" />
</form>
</field>
</record>
<record model="ir.ui.view" id="mymodule.settings_sfollowers_list">
<field name="name">mymodule.settings_sfollowers.list</field>
<field name="model">mymodule.stage_followers</field>
<field name="arch" type="xml">
<tree>
<field name="user" />
<field name="stage" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="mymodule.action_view_sfollowers_settings">
<field name="name">MyModule Settings - Stage Followers</field>
<field name="res_model">mymodule.stage_followers</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Stage Followers" groups="mymodule.group_mymodule_admin" id="mymodule.menu_settings_sfollowers" parent="mymodule.menu_settings" action="mymodule.action_view_sfollowers_settings" />

Whew, now that's out of the way, we can get into the nitty gritty. I wrote a method that lives inside the write override, it looks something like this.

def add_follower_id(self, res_id, model, partner_id):
follower_id = False
reg = {
'res_id': res_id,
'res_model': model,
'partner_id': partner_id
}
try:
follower_id = self.env['mail.followers'].create(reg)
except:
# This partner is already following this record
return False
return follower_id

The above should be fairly self explanatory. I've also written a method that will remove followers from specific records

def remove_follower_id(self, res_id, model, partner_id):
env = self.env['mail.followers']
domain = [('partner_id', '=', partner_id), ('res_id', '=', res_id), ('res_model', '=', model)]
try:
env.search(domain).unlink()
return True
except:
# The record was either not found, or the unlink operation was not allowed by the current user
return False

Now I mentioned a write override, I'll provide a small sample of what mine looks like. This is on whatever form you want to add the followers to.

@api.multi
def write(self, vals):
res = super(mymodule, self).write(vals) # Save the form
stage_followers = self.env['mymodule.stage_followers'].search([('stage', '=', vals['state'])])
for i in stage_followers:
add_follower_id(self, self.id, 'mymodule.myform', i['user'])
# Message posting is optional. Add_follower_id will still make the partner follow the record
messages = "Whatever you want to put in the message box."
if messages:
self.message_post(body=messages, partner_ids=self.message_follower_ids)
return res

Removing followers is the same as adding them above, except you might want to do the inverse of the search ( "!=" instead of "=" )

And that's basically it. Tweak this to your needs and it should do what you need. It sure does what I needed it to do.

1
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Disable Followers Risolto
follower mail
Avatar
Avatar
1
lug 24
12994
Copy paste multiple email id in recipients form in invite follower
follower mail
Avatar
0
feb 20
3382
How to disable auto-add followers in discussion groups - copy solution from mail_thread.py?
follower mail odoo8.0
Avatar
Avatar
Avatar
2
mar 16
10383
Where is the function that send notification when their are some object's activity?
development follower mail
Avatar
1
mar 15
6845
Add followers and send email automatically (Odoo 14.0)
follower mail crm crm.lead
Avatar
0
giu 22
3606
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now