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 call email templates with a custom module

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
v8email_templateselectable
4 Respostas
14614 Visualizações
Avatar
NASHMIN YEGANEH

Hello 

I'm going to add some code to my custom module to be able to call email templates and choose related template with my module through a drop down selector list, so any body know how to start to do that?

i already made 2 template to my custom module inside email.template  and i tested with mail.compose.message module and it worked fine

i watched to some similar modules but actually they made me more confused.. so i just want to call my modules own templates with a Many2one field and nothing more no send mail or other extra task... but saving current content can be effective

the field that template should load in that is note and my custom module is res_correspond_int with ResCorrespondINT class
as i got until now i should add a line for my xml file like below 

<field name="template_id" attrs="{'readonly': [ ('state', 'not in', ['draft'])], 'required': True}"/>

and a code for calling related template (not working )

template_id = fields.Many2one(
    'email.template',
    string='Template',
    track_visibility='onchange',
    default=default_template)

@api.multi
def default_template(self):
    note = ''
    default_template_obj = self.env['email.template']
    template_id = default_template_obj.search([('model', '=', 'res.correspond.int')], limit=5)
    if template_id:
     for i in self:
        note += '\n' + i.note
        default_template_obj.note(template_id.id, self._context.get('active_id'), )
     return


0
Avatar
Cancelar
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Melhor resposta

I am not sure exactly what you are trying to do but I think you want to show the Email Templates which are related to your model.

Try following code:

template_id = fields.Many2one(
'email.template',
string='Template',
domain=[('model', '=', 'res.correspond.int')],
track_visibility='onchange',
default=default_template)

If you wish send the email from any method, try following code:

@api.multi
def action_send_mail(self):
for rec in self:
rec.template_id.send_mail(rec.id) # Call send_mail method of the mail template obj
return True
4
Avatar
Cancelar
Avatar
Nitin Kantak
Melhor resposta

This may help you :

# template id is nothing but xml id of that particular template
template = self.env['ir.model.data'].get_object('# object_name',template_id)

# Send out the e-mail template to the user
template_obj = self.env['mail.template'].browse(template.id)
template_obj.send_mail(# record_id)

1
Avatar
Cancelar
Avatar
NASHMIN YEGANEH
Autor Melhor resposta

@Nitin Kantak 
Hello Nitin, Can you please tell me what do this "template" field below? coz it does not called any where in code.. it just collect data and stop


template = self.env['ir.model.data'].get_object('# object_name',template_id)


for second line i said in first that i won't send mail this template.. just want to load into "note" field inside my class and save .. so do you know any way to putting it inside a field (note) with selecting that from a Many2one drop down list?



# Send out the e-mail template to the user
template_obj = self.env['mail.template'].browse(template.id)
template_obj.send_mail(# record_id)

**********************************************************

@Sudhir Arya

\\
\\\\

Sudhir AryaSudhir AryaSudhir Arya


No, actually i just want to load email.template data inside a field named "note" thats all

0
Avatar
Cancelar
Balvant Ramani

In that case you have to write onchange event of template_id like this

@api.onchange('template_id')

def onchange_template_id(self):

if self.template_id :

self.notes = self.env['mail.template'].render_template(self.template_id.body, 'hr.employee', self.id)

you can hr.employee with your model name.

Avatar
Hendra
Melhor resposta

Hi, I'm using odoo 10, i already installing project_issue, I want to know where can I find project issue email template.


thanks you

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
Email template is failed to render ? [SOLVED] Resolvido
v8 sale.order email_template
Avatar
Avatar
Avatar
Avatar
4
jan. 19
33085
How to feeding a field with template by selecting a drop down list
v8 dropdownlist email_template
Avatar
0
nov. 18
5192
is it possible to use QWeb template when define a email template?
v8 qweb email_template
Avatar
Avatar
1
set. 16
4637
Default Outgoing server can't be recognize while using email templates in Odoo V8.
v8 email_template outgoing_server
Avatar
0
mar. 15
4466
How to send Partner Mass Mail to partner and parters contacts, v8. Resolvido
mail v8 emailtemplate email_template
Avatar
Avatar
Avatar
Avatar
4
jun. 18
10931
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