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

Failed to render template %r using values %r - Odoo v9 community

S'inscrire

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

Cette question a été signalée
emailingemail_templatewebsiteodooV9
4940 Vues
Avatar
Alberto

I have this model:

@api.one
def send_mail_function_model(self):
    template_id = self.env.ref('opencloud_cashflows.email_template_loan') #self.pool('email.template') self.env.ref
    if template_id:
        template_id.send_mail(self.id, force_send=True) #self.ids[0], force_send=True
    return True

Which I call from this controller:

class Loan(http.Controller):
@http.route(['/request_loan'], type='http', auth='user', website=True)
def send_mail_function(self, **kw):
    if request.env.uid != request.website.user_id.id:
        request.env.user.send_mail_function_model()
    return request.website.render('opencloud_cashflows.request_loan')

This is the javascript file:

odoo.define('opencloud_cashflows.opencloud_cashflows', function (require) { "use strict";
var ajax = require('web.ajax');
var core = require('web.core');
var website = require('website.website');
var _t = core._t;
var Model = require('web.Model');
$('.send_mail_function').on('click', function (){
    var model = new Model('res_users');
    $('send_mail_function_model').click(function(){
        model.call('send_mail_function_model',[])

    })
});
});

The email template:

<?xml version="1.0" ?>
<openerp>
<data noupdate="0">
    <!--Email template -->
    <record id="email_template_loan" model="mail.template">
        <field name="name">Loan - Send by Email</field>
        <field name="email_from"><![CDATA[${object.company_id.name} <${(object.company_id.email or user.email)|safe}>]]></field>
        <field name="email_to">${(object.company_id.loan_email and '%s &lt;%s&gt;' % (object.company_id.name, object.company_id.loan_email) or '')|safe}</field>
        <field name="subject">${object.company_id.name} Pedido de préstamo desde blinking.cl</field>
        <!--<field name="partner_to">${object.partner_id.id}</field>-->
        <field name="model_id" ref="model_cashflow_report"/>
        <field name="auto_delete" eval="True"/>
        <field name="lang">${object.env.user.lang}</field>
        <field name="body_html"><![CDATA[
        <div style="font-family: 'Lucida Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
<center><img src="http://www.blinking.cl/images/blinking-img-redes.jpg"></img></center>
<p>Hola ${object.partner_id.bank},</p>
<br/>
<p>Requerimos la siguiente cantidad como préstamo ${object.field_total},</p>
<br/>
<p>Por favor cualquier duda comuniquese con nuestro teléfono ${object.company_id.phone},</p>
<br/>
<p>Muchas Gracias</p>
        ]]></field>
    </record>
</data>
</openerp>

The view I'm calling from the controller:

    </template>
    <template id="request_loan" name="Loan">
        <t t-call="website.layout">
          <div id="wrap">
            <div class="oe_structure"/>
            <div class="container">
                <h1>¡Gracias!</h1>
                <div class="row">
                    <div class="col-md-8">
                        <div class="alert alert-success">
                            Tu pedido se ha enviado satisfactoriamente.
                            <button type="button" class="close" data-dismiss="alert">&amp;times;</button>
                        </div>
                        <!--<p>
                            We will get back to you shortly.
                        </p>--><p class="mt64">
                            If you have an emergency, do not hesitate to contact us by phone:
                        </p>
                        <ul class="list-unstyled">
                            <li><i class="fa fa-phone"></i> : <span t-field="res_company.phone"/></li>
                            <li><i class="fa fa-envelope"></i> : <span t-field="res_company.email"/></li>
                        </ul>
                        <a href="/cashflows/"><span class="btn btn-primary btn-lg" style="margin-left:560px; margin-top:-70px; background-color:#e67e22;">Volver</span></a>
                    </div>
                    <div class="col-md-4">
                        <t t-call="website.company_description"/>
                    </div>
                </div>
            </div>
            <div class="oe_structure"/>
          </div>
        </t>
    </template>

And the button from which I call the function:

<center><a href="/request_loan"><button id="send_mail_function" class="btn btn-primary btn-lg" name="send_mail_function" value="Pedir préstamo al Banco" type="submit" style="background-color:#e67e22;" >Pedir préstamo al Banco</button></a></center>

It seems to be working fine though, besides the fact that it cannot render the email template, every time I click on the button it throws me this:

Traceback (most recent call last):
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/website/models/ir_http.py", line 242, in _handle_exception
response = super(ir_http, self)._handle_exception(exception)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/base/ir/ir_http.py", line 158, in _handle_exception
return request._handle_exception(exception)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 786, in _handle_exception
return super(HttpRequest, self)._handle_exception(exception)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/base/ir/ir_http.py", line 183, in _dispatch
result = request.dispatch()
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 845, in dispatch
r = self._call_function(**self.params)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 321, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 314, in checked_call
result = self.endpoint(*a, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 964, in __call__
return self.method(*args, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 514, in response_wrap
response = f(*args, **kw)
File "/home/kristian/odoov9/danisan/opencloud_cashflows/controllers/main.py", line 1017, in send_mail_function
request.env.user.send_mail_function_model()
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 425, in new_api
result = [method(rec, *args, **kwargs) for rec in self]
File "/home/kristian/odoov9/danisan/opencloud_cashflows/models/res_users.py", line 27, in send_mail_function_model
template_id.send_mail(self.id, force_send=True) #self.ids[0], force_send=True
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/mail/models/mail_template.py", line 537, in send_mail
values = self.generate_email(res_id)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/mail/models/mail_template.py", line 470, in generate_email
post_process=(field == 'body_html'))
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/mail/models/mail_template.py", line 367, in render_template
raise UserError(_("Failed to render template %r using values %r")% (template, variables))
UserError: (u"Failed to render template <Template memory:7fb8f2abf050> using values {'format_tz': <function <lambda> at 0x7fb8f03b0668>, 'ctx': {'lang': u'es_CL', 'tz': u'America/Santiago', 'safe': True, 'website_id': 1, 'uid': 1}, 'user': res.users(1,), 'object': cashflow.report(1,)}", None)

I've read somewhere that it has to do with the default language set up in the database, or user, and on some other post someone says that it is due to the gmail smtp server (which I have configured as smtp server in my odoo instance)

Any ideas?


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é
Email send from website page - Odoo v9 community Résolu
email_template website websites odooV9
Avatar
Avatar
1
mai 17
3613
Send email from website button using javascript on Odoo v9 community Résolu
models email_template website odooV9 JavascriptCallFromOdoo
Avatar
Avatar
1
mai 17
6311
how to modify / set language for "send message" email in project task?
emailing emailtemplate email_template
Avatar
0
juin 23
2994
Custom Model show on Website Résolu
models website odooV9
Avatar
Avatar
1
oct. 16
7412
Extra Info Step in eCommece v9 Résolu
ecommerce website odooV9
Avatar
Avatar
1
juin 16
4965
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