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

how to send message(not email) programatically that can be seen by all /some users

Iscriviti

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

La domanda è stata contrassegnata
programaticallymail.message
4 Risposte
38278 Visualizzazioni
Avatar
raiye hailu

I am trying to programmatically post a message (not email). But I don't know how. The message for example can show up in the discussion app , #generals channel. I searched the internet but all I get it is how to send email messages to users using the mail.thread object.

in other words how to accomplish the following using python code

<record model="mail.message" id="module_install_notification">
<field name="model">mail.channel</field>
<field name="res_id" ref="mail.channel_all_employees"/>
<field name="message_type">notification</field>
<field name="subtype_id" ref="mail.mt_comment"/>
<field name="subject">Project Management application installed!</field>
<field name="body"><![CDATA[<p>Manage multi-level projects and tasks. You can delegate tasks, track task work, and review your planning.</p>
<p>You can manage todo lists on tasks by installing the <i>Todo Lists</i> application, supporting the Getting Things Done (GTD) methodology.</p>
<p>You can also manage issues/bugs in projects by installing the "Issue Tracker" application.</p>]]></field>
</record>

The above xml code posts the "body" to the #general channel of the Discuss app.

I am using odoo v9.

1
Avatar
Abbandona
Avatar
Muhammad Younis
Risposta migliore

Hello,

First of all, create a channel for a group of users. For example, I want to create for accountant group like this:


Accountant

Message Notifications.

then create a record in mail.message model like this:

def action_send_notification(self):
    self.env['mail.message'].create({
'email_from': self.env.user.partner_id.email, # add the sender email
'author_id': self.env.user.partner_id.id, # add the creator id
'model': 'mail.channel', # model should be mail.channel
'type': 'comment',
'subtype_id': self.env.ref('mail.mt_comment').id, Leave this as it is
'body': "Body of the message", # here add the message body
'channel_ids': [(4, self.env.ref('module_name.channel_accountant_group').id)], # This is the channel where you want to send the message and all the users of this channel will receive message
'res_id': self.env.ref('modulename.channel_accountant_group').id, # here add the channel you created.
})

This code will help you to understand and send messages (not email) programmatically).

Thank You.

6
Avatar
Abbandona
Avatar
raiye hailu
Autore Risposta migliore

For now I have figured out a way to send messages to followers of a record when a field's value is changed.

Suppose I have a field x.

x=fields.Integer('a var', track_visibility='onchange')
    the track_visibility attribute tells odoo to log any change of x , either from a form view or by a function. The log is posted as an internal note. For this to happen your class must inhert mail.thread and use appropriate widget in the definition of the form view. For that check out  https://www.odoo.com/documentation/10.0/reference/mixins.html


    The internal log note taken by the track_visibility option can be sent as a message to users following the record. On the left of the open chatter you can see that there is a button to add followers for the record. There is also a button which says 'following'. Clicking it gives a list of options with check marks for each. Followers of the record will get messages corresponding to the events represented by each choice in the list. We will first have to add a choice to this list. A choice that corresponds to change of value of x. It is called message sub type.
    In the xml file where you define your form,list...views put the following.
    <record id="mt_x_value_changed" model="mail.message.subtype">
    <field name="name">The value of x changed</field>
    <field name="res_model">modelname</field>
    <field name="default" eval="True"/>
    <field name="description">The value of x changed</field>
    </record>
     Then in your module python file override the _track_subtype(init_values) method. init_values contains a dictionary of changed fields and their previous values. self.x is the current x value. If the option 'The value of x changed' is checked, when x is changed the followers of the record will get a message saying the 'The value of x changed'. In this case it  only when x is < 5 the message is sent.



    def _track_subtype(self,init_values):
    self.ensure_one()
    if (('x' in init_values) and (self.x <= 5)):

    return 'module_name.mt_x_value_changed'
    return super(class_name,self)._track_subtype(init_values)
    1
    Avatar
    Abbandona
    Avatar
    Jainesh Shah(Aktiv Software)
    Risposta migliore

    Hi raiye hailu,

    To post a message that can seen by specific recipients,you can simply write below python code into your model:

     partner_ids = self.env['res.partner'].search(search_domain).ids

     # search domain to filter specific partners

     self.message_post(subject=subject,body=body,partner_ids=[(4, [partner_ids])])

     Hope this will helpful to you!

    Thanks!

    0
    Avatar
    Abbandona
    raiye hailu
    Autore

    Thank you Jainesh for the answer. But it did not work. Even if it did, I think your code sends email message to partners using the email address input when the partners were created. I don't want to send email messages. I want to send a message to a user of odoo(or post a message to a channel).

    I expect the solution to contain references to res.users not res.partner(or contain a reference a channel id).

    Avatar
    Obay Abdelgadir
    Risposta migliore

    Dude!!! you are commenting python code with //

    0
    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à
    Invite new users
    mail.message
    Avatar
    Avatar
    Avatar
    Avatar
    4
    gen 24
    14396
    Displaying an attachement in a mail.message programmatically
    programatically timeline mail_thread attachement mail.message
    Avatar
    0
    dic 15
    5784
    I cannot add Field to "pos.order" in "modelo.Order"
    pos programatically
    Avatar
    Avatar
    2
    dic 24
    3663
    Cannot create mail.message even though I have set permissions
    mail.message PERMISSION
    Avatar
    0
    lug 24
    1901
    How to show message_type = notification in a portal chatter? Risolto
    chatter mail.message
    Avatar
    Avatar
    1
    set 21
    7501
    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