Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

[Meeting]How to not send email to attendees?

Odebírat

Get notified when there's activity on this post

This question has been flagged
meeting
1 Odpovědět
8577 Zobrazení
Avatar
Bonnet Denis

If I set a meeting with 2 attendees who are some OpenERP users they receive 2 mails:

  • One at the meeting creation
  • A second when an invitation is validate

this validation create a new meeting with the same attendees and send email to them, again.

How to prevent this second email?

regards

edit: I try this:

class calendar_attendee(osv.osv):
_name = 'calendar.attendee'
_inherit = 'calendar.attendee'

def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None):
    """
    Send mail for event invitation to event attendees.
    @param email_from: email address for user sending the mail
    @return: True
    """
    company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.name
    for att in self.browse(cr, uid, ids, context=context):
        sign = att.sent_by_uid and att.sent_by_uid.signature or ''
        sign = '<br>'.join(sign and sign.split('\n') or [])
        res_obj = att.ref
        if res_obj:
            att_infos = []
            sub = res_obj.name
            other_invitation_ids = self.search(cr, uid, [('ref', '=', res_obj._name + ',' + str(res_obj.id))])
            for att2 in self.browse(cr, uid, other_invitation_ids):
                att_infos.append(((att2.user_id and att2.user_id.name) or \
                             (att2.partner_id and att2.partner_id.name) or \
                                att2.email) + ' - Status: ' + att2.state.title())
            #dates and times are gonna be expressed in `tz` time (local timezone of the `uid`)
            tz = context.get('tz', pytz.timezone('UTC'))
            #res_obj.date and res_obj.date_deadline are in UTC in database so we use context_timestamp() to transform them in the `tz` timezone
            date_start = fields.datetime.context_timestamp(cr, uid, datetime.strptime(res_obj.date, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)
            date_stop = False
            if res_obj.date_deadline:
                date_stop = fields.datetime.context_timestamp(cr, uid, datetime.strptime(res_obj.date_deadline, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)
            body_vals = {'name': res_obj.name,
                        'start_date': date_start,
                        'end_date': date_stop,
                        'timezone': tz,
                        'description': res_obj.description or '-',
                        'location': res_obj.location or '-',
                        'attendees': '<br>'.join(att_infos),
                        'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User',
                        'sign': sign,
                        'company': company
            }
            body = html_invitation2 % body_vals
            if mail_to and email_from:
                ics_file = self.get_ics_file(cr, uid, res_obj, context=context)
                vals = {'email_from': email_from,
                        'email_to': mail_to,
                        'state': 'outgoing',
                        'subject': sub,
                        'body_html': body,
                        'auto_delete': True}
                if ics_file:
                    vals['attachment_ids'] = [(0,0,{'name': 'invitation.ics',
                                                    'datas_fname': 'invitation.ics',
                                                    'datas': str(ics_file).encode('base64')})]
                self.pool.get('mail.mail').create(cr, uid, vals, context=context)
        return True
def do_accept(self, cr, uid, ids, context=None, *args):
    """
    Update state of invitation as Accepted and if the invited user is other
    then event user it will make a copy of this event for invited user.
    @param cr: the current row, from the database cursor
    @param uid: the current user's ID for security checks
    @param ids: list of calendar attendee's IDs
    @param context: a standard dictionary for contextual values
    @return: True
    """
    if context is None:
        context = {}

    for vals in self.browse(cr, uid, ids, context=context):
        if vals.ref and vals.ref.user_id:
            mod_obj = self.pool.get(vals.ref._name)
            res=mod_obj.read(cr,uid,[vals.ref.id],['duration','class'],context)
            defaults = {'user_id': vals.user_id.id, 'organizer_id': vals.ref.user_id.id,'duration':res[0]['duration'],'class':res[0]['class']}
            if 'already_send' not in context :
                _logger.debug('               pas encore     ')
                context['already_send']=True
                mod_obj.copy(cr, uid, vals.ref.id, default=defaults, context=context)
                del context['already_send']
            else:
                _logger.debug('               oui     ')
        self.write(cr, uid, vals.id, {'state': 'accepted'}, context)

    return True
class crm_meeting(osv.osv):
    _name='crm.meeting'
    _inherit = 'crm.meeting'
def create_attendees(self, cr, uid, ids, context):
        #définition du context
        context = context or {}
        att_obj = self.pool.get('calendar.attendee')
        user_obj = self.pool.get('res.users')
        current_user = user_obj.browse(cr, uid, uid, context=context)
        for event in self.browse(cr, uid, ids, context):
            attendees = {}
            for att in event.attendee_ids:
                attendees[att.partner_id.id] = True
            new_attendees = []
            mail_to = ""
            for partner in event.partner_ids:
                if partner.id in attendees:
                    continue
                att_id = self.pool.get('calendar.attendee').create(cr, uid, {
                    'partner_id': partner.id,
                    'user_id': partner.user_ids and partner.user_ids[0].id or False,
                    'ref': self._name+','+str(event.id),
                    'email': partner.email
                }, context=context)
                if partner.email:
                    mail_to = mail_to + " " + partner.email
                self.write(cr, uid, [event.id], {
                    'attendee_ids': [(4, att_id)]
                }, context=context)
                new_attendees.append(att_id)

            if mail_to and current_user.email and 'already_send' not in context:
                att_obj._send_mail(cr, uid, new_attendees, mail_to,
                    email_from = current_user.email, context=context)
            att_obj.do_accept(cr, uid, new_attendees, context=context)
        return True

And it's working.

2
Avatar
Zrušit
Franklin

File: <openerp_home>/addons/base_calendar/base_calendar.py

Avatar
Bonnet Denis
Autor Nejlepší odpověď

I found the solution by myself. See question edit for the code.

0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Big problem with the calendar
meeting
Avatar
0
lis 23
1601
Send meeting request to group
meeting
Avatar
0
bře 15
3769
#Meeting Scheduling
meeting scheduling
Avatar
Avatar
Avatar
2
kvě 23
4369
How can i setup ICE servers? Vyřešeno
meeting discuss
Avatar
1
pro 24
8465
meeting analysis
meeting analysis
Avatar
0
čvn 16
3344
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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