Przejdź do zawartości
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Sztuczna inteligencja
    • IoT
    • VoIP
    • Wiedza
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

how send automatic email when a form's state is change?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
automatic_emailmailtemplatesendmail
2 Odpowiedzi
10626 Widoki
Awatar
nasim

hi

I want know, how send automatic email when a form's state is change?

I search and one page find that someone had given such a solution:

---------------------------------------------

@api.onchange('state')
@api.one
def email_onchange_state(self):
if self.state == 'done':
    tmplt_id = self.env['mail.template'].search([("name", "=", "my_temp_onchange_state_to_done")])  # (I create "my_temp_onchange_state_to_done" template email)
    if tmplt_id:
        self.env['mail.template'].browse(tmplt_id.id).send_mail(self.id, force_send=True)
--------------------------------------------

but when I test , it does not work.( without error)

do you have a solution?


0
Awatar
Odrzuć
Sehrish

Check how to send email on some event: https://goo.gl/z16PBZ

Awatar
faOtools
Najlepsza odpowiedź

A few hints:

1. Do not use 'onchange' for that purpose, since even not saved update will lead to an email of being sent. Instead use inverse.

2. Since you are working with some object (e.g a sale order or an opportunity) it is better to use message_post of that model without trying to use mail.template.

So, you should have something like:

@api.multi
def _inverse_state(self):
"""
For sure you can change body or subject, and generate those based on a template
"""
for obj in self:
obj.message_post(body="State is changed", subject="State is changed", subtype="mail.mt_comment")

state = fields.Selection(inverse=_inverse_state) # field type might be Many2one in case of certain models

Another alternative is to rely upon tracking. Look for examples in the project module - https://github.com/odoo/odoo/blob/12.0/addons/project/models/project.py

0
Awatar
Odrzuć
nasim
Autor

Hi

Thanks for your help

I wanted to use "mai". so my function became: (and works fine :) )

---------------------------------

@api.multi

def _inverse_state(self):

if self.state == 'done':

tmplt_id = self.env['mail.template'].search([("name", "=", "my_temp_onchange_state_to_done")])

if tmplt_id:

self.env['mail.template'].browse(tmplt_id.id).send_mail(self.id, force_send=True)

--------------------

state = fields.Selection(inverse='_inverse_state')

------------------------------------------------------------------------------------------

Thanks

Awatar
Niyas Raphy (Walnut Software Solutions)
Najlepsza odpowiedź

Hi,

 Can you please put a print statement or logger message for the tmplt_id and see whether it receives the email template, might be the email is not send or created as the execution of the code didn't enter inside the if statement.

Refer : Finding and sending e-mail templates in Odoo

Also you can check whether the onchange function is getting executed, you can test the same by putting a print statement it. If the state of the record is changed in a button click, you can override that button action and add this codes to send email in it.


For sending the email in the during the state change, you can use the automated action to send the email. For that install the module named base_automation in the database and navigate to Settings -> Technical -> Automation -> Automated Action and create a new record here by specifying the model for which the action has to be triggered, and in the field Trigger condition specify the condition and in the Action To Do select the Send Email option.


Thanks

0
Awatar
Odrzuć
nasim
Autor

thanks for your help

but I did not want to use 'Aoutomated Action' (because I want know it is posibble write this without automated action?)

so I used the above method.( def _inverse_state(self) )

so thanks

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Send Email from Template When convert_opportunity sends duplicate mails
mailtemplate sendmail
Awatar
0
maj 16
4015
Automatisation of mails to customers
automatic_email
Awatar
Awatar
Awatar
3
wrz 25
2722
How to send mail automatically while saving the record Rozwiązane
automatic_email
Awatar
Awatar
Awatar
Awatar
Awatar
5
lut 25
9422
Automatic Email only if some fields are filled
automatic_email
Awatar
Awatar
1
lip 21
3610
Override mail template in Odoo 9
mailtemplate
Awatar
Awatar
Awatar
Awatar
5
lis 19
11616
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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