Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

how to create a new record from incomming mail (custom module)

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
modulesemailrecordsincoming
2 Відповіді
13748 Переглядів
Аватар
Beat Besmer

a incoming e-mail should create a new record in my model.

the model exists, it contains two fields and i can edit manually .
under incoming-mail-server i also choosed "create new record" pointing at my model
i guess i can use the "message_new" function from the project_issue.py to my model.py and change some values to get the values in (subject, sender, body) in my models fields. am i right?

i just started learning phyton so i can need some hints :) thx

0
Аватар
Відмінити
Аватар
Beat Besmer
Автор Найкраща відповідь

i was right with the method "message_new"

https://www.odoo.com/forum/help-1/question/customize-the-auto-lead-creation-through-incoming-emails-272, answer of Lucio from 2/19/13 helped me out so far

just had to use correct syntax to write in database :)

1
Аватар
Відмінити
Аватар
Victor Lopes
Найкраща відповідь

Hi Beat Besmer! I would like to take your post as an opportunity to clarify this process a bit more for people new to Odoo, like me. Because as of today, Odoo still has some built-in modules that don't support record creation based on incoming e-mails.

I was trying to create Purchase Orders from e-mail messages, for example, but I was seeing log errors like this (/var/log/odoo - file: odoo-server):

17-11-21 02:00:01,390 1293  odoo.addons.fetchmail.models.fetchmail: start checking for new emails on imap server YOURSERVER
2017-11-21 02:00:04,191 1293 odoo.addons.mail.models.mail_thread: Routing mail from John Doe <john@somedomain.com> to PO <po_odoo@somedomain.com> with Message-Id <033BEAFA3A88314AAD1AF741D8A56C0E95DD2533@YOURSERVER>: fallback to model:purchase.order, thread_id:None, custom_values:None, uid:5
2017-11-21 02:00:04,288 1293 ERROR odoo.sql_db: bad query: b'INSERT INTO "purchase_order" ("id", "currency_id", [... LONG COLUNM LIST...]
ERROR: null value in column "partner_id" violates not-null constraint


So here is an example of a simple "message_new" method that you can use on an Odoo 10 installation, for Purchase Orders:

Edit the file /odoo/odoo-server/addons/purchase/models/purchase.py and add the following lines:

    @api.model
    def message_new(self, msg, custom_values=None):
        """ Overrides mail_thread message_new that is called by the mailgateway
            through message_process.
            This override updates the document according to the email.
        """
        # remove default author when going through the mail gateway. Indeed we
        # do not want to explicitly set user_id to False; however we do not
        # want the gateway user to be responsible if no other responsible is
        # found.
        if custom_values is None:
            custom_values = {}
        defaults = {
            'name': msg.get('subject') or _("No Subject"),
            'partner_id': msg.get('author_id')
        }
        defaults.update(custom_values)
        p_order = super(PurchaseOrder, self).message_new(msg, custom_values=defaults)         return p_order


I don't believe there is a particular order, but make it between two other existing functions (defs).

This was adapted from other Odoo methods that do have a message_new implementation, and using tips from other posts.
I believe that you can change it to fit your needs with other modules as well.

After modifying this file and restarting Odoo's service (sudo service odoo-server restart) you can configure an incoming e-mail server and set the "Create New Record" to Purchase Order, for example.

This function above will set the sender as "partner" (partner_id), so keep in mind that the sender will have to be a valid user in Odoo (otherwise the record creation will still fail). Either that or you will need to elaborate more in order to create a new user on the fly, case it doesn't exist yet.

More about: 

Configuring e-mail server and alias domain: https://www.odoo.com/documentation/user/11.0/discuss/email_servers.html

More information about this issue (and a sample for Odoo 11): https://github.com/odoo/odoo/issues/6757


0
Аватар
Відмінити
Enjoying the discussion? Don't just read, join in!

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

Реєстрація
Related Posts Відповіді Переглядів Дія
Can someone explain the full procedure to configure incoming mail? Вирішено
email incoming
Аватар
Аватар
Аватар
Аватар
Аватар
7
трав. 22
25755
Odoo 9 incoming mail servers Вирішено
email incoming odoo9
Аватар
Аватар
1
лист. 15
5178
email is not fetching correctly ( incoming emails) ?
email incoming fetching
Аватар
0
бер. 15
5442
How Odoo proceed to delete absent xml record?
modules xml delete records
Аватар
Аватар
1
бер. 22
10816
Action from incoming e-mail Вирішено
server email fetchmail incoming
Аватар
Аватар
Аватар
Аватар
Аватар
4
груд. 20
14450
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція Odoo - це одночасно дуже проста у використанні та повністю інтегрована.

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