Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How set 'To' field of email template with a many2many field

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
emailtemplatesmany2manymail.message
6 Réponses
13250 Vues
Avatar
Shawn Varghese

There are 2 parameters in the email templates:

To (Emails)

To (Partners)

I want to use a many2many fields variable for this. Something like ${object.user_ids}. Is there any way to do it?


0
Avatar
Ignorer
Avatar
Cyril Gaspard (GEM)
Meilleure réponse

Hi,

To (Emails) : 

'email_to': fields.char('To (Emails)', help="Comma-separated emailaddresses (placeholders may be used here)"),


To (Partners) :

'partner_to': fields.char('To (Partners)',

help="Comma-separated ids of recipient partners (placeholders may be used here)",

=> list of id of class res partner, not res users, but a user has a related partner


add in To (Partners)

${object.get_partner_ids(object.user_ids)}


in the class where is defined field user_ids, add the function used in ${object.get_partner_ids(object.user_ids)}

    def _get_partner_ids(self, cr, uid, user_ids) :

        return str([user.partner_id.id for user in user_ids]).replace('[', '').replace(']', '')


bye

5
Avatar
Ignorer
Avatar
Shawn Varghese
Auteur Meilleure réponse

Thanks Cyril ! This is excellent.

Just a couple of changes that I had to make from my end:

  1. The function name beginning with underscore (_get_partner_ids) had to be changed to just get_partner_ids because the private class was inaccessible from the template.

  2. partner.id should be partner_id.id

  3. Calling the function from template was defined without the cr,uid because that was raising issues for me

    ${object.get_partner_ids(object.user_ids)}
  4. Also, could you tell me why the additional char field is required?

Thanks again !

1
Avatar
Ignorer
Cyril Gaspard (GEM)

could yoy explain what you said : the additional char field ?

Shawn Varghese
Auteur

This char field: 'partner_to': fields.char('To (Partners)', help="Comma-separated ids of recipient partners (placeholders may be used here)", It is not being used right? So I was wondering why it is required.

Cyril Gaspard (GEM)

it is not required, but you should have at least one email address, if you want use directy address a@a.com,...., use field, 'email_to', if you want use email field of a partner, use 'partner_to', bye

Avatar
Lucas Huber
Meilleure réponse

I have a similar case, but can't figure out how I get the correct partner ids. I have a message model that is related to project.project and I want to get the followers of the project into my mail.template.

Here is my code so far. I stuck at the relation between the field project.message_follower_ids and  res_partner.  (project.message_follower_ids is related to mail.followers -> res_id).

<field name="partner_to">${object.get_partner_ids(object.project_id.message_follower_ids)}</field>

@api.multi  # TODO get the followers of the active Scrum Project
def get_partner_ids(self, user_ids):
  return str([user_ids.ids]).replace('[', '').replace(']', '')
0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Send email with python Résolu
email many2many
Avatar
Avatar
Avatar
4
juil. 24
19903
Email Template subject parameters Résolu
email templates
Avatar
Avatar
1
févr. 24
3676
Nothing rendered into email body_html (Odoo 16) Résolu
email templates
Avatar
1
juil. 23
4713
How to add company logo to email templates? Résolu
email templates
Avatar
Avatar
Avatar
Avatar
3
déc. 23
19986
Failed to render template Résolu
email templates
Avatar
Avatar
1
févr. 22
7215
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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