Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
emailtemplatesmany2manymail.message
6 Replies
13252 Zobrazenia
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
Zrušiť
Avatar
Cyril Gaspard (GEM)
Best Answer

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
Zrušiť
Avatar
Shawn Varghese
Autor Best Answer

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
Zrušiť
Cyril Gaspard (GEM)

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

Shawn Varghese
Autor

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
Best Answer

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
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Send email with python Solved
email many2many
Avatar
Avatar
Avatar
4
júl 24
19903
Email Template subject parameters Solved
email templates
Avatar
Avatar
1
feb 24
3678
Nothing rendered into email body_html (Odoo 16) Solved
email templates
Avatar
1
júl 23
4714
How to add company logo to email templates? Solved
email templates
Avatar
Avatar
Avatar
Avatar
3
dec 23
19988
Failed to render template Solved
email templates
Avatar
Avatar
1
feb 22
7215
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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