Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

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

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
modulesemailrecordsincoming
2 Respostas
13743 Visualizações
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
Cancelar
Avatar
Beat Besmer
Autor Melhor resposta

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
Cancelar
Avatar
Victor Lopes
Melhor resposta

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
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
Can someone explain the full procedure to configure incoming mail? Resolvido
email incoming
Avatar
Avatar
Avatar
Avatar
Avatar
7
mai. 22
25752
Odoo 9 incoming mail servers Resolvido
email incoming odoo9
Avatar
Avatar
1
nov. 15
5177
email is not fetching correctly ( incoming emails) ?
email incoming fetching
Avatar
0
mar. 15
5439
How Odoo proceed to delete absent xml record?
modules xml delete records
Avatar
Avatar
1
mar. 22
10814
Action from incoming e-mail Resolvido
server email fetchmail incoming
Avatar
Avatar
Avatar
Avatar
Avatar
4
dez. 20
14446
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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