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 to create a new record from incomming mail (custom module)

S'inscrire

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

Cette question a été signalée
modulesemailrecordsincoming
2 Réponses
13742 Vues
Avatar
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
Avatar
Ignorer
Avatar
Beat Besmer
Auteur Meilleure réponse

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
Avatar
Ignorer
Avatar
Victor Lopes
Meilleure réponse

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
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é
Can someone explain the full procedure to configure incoming mail? Résolu
email incoming
Avatar
Avatar
Avatar
Avatar
Avatar
7
mai 22
25752
Odoo 9 incoming mail servers Résolu
email incoming odoo9
Avatar
Avatar
1
nov. 15
5177
email is not fetching correctly ( incoming emails) ?
email incoming fetching
Avatar
0
mars 15
5439
How Odoo proceed to delete absent xml record?
modules xml delete records
Avatar
Avatar
1
mars 22
10814
Action from incoming e-mail Résolu
server email fetchmail incoming
Avatar
Avatar
Avatar
Avatar
Avatar
4
déc. 20
14446
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