Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
emailingemail_templatewebsiteodooV9
4937 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Email send from website page - Odoo v9 community Rezolvat
email_template website websites odooV9
Imagine profil
Imagine profil
1
mai 17
3610
Send email from website button using javascript on Odoo v9 community Rezolvat
models email_template website odooV9 JavascriptCallFromOdoo
Imagine profil
Imagine profil
1
mai 17
6311
how to modify / set language for "send message" email in project task?
emailing emailtemplate email_template
Imagine profil
0
iun. 23
2994
Custom Model show on Website Rezolvat
models website odooV9
Imagine profil
Imagine profil
1
oct. 16
7412
Extra Info Step in eCommece v9 Rezolvat
ecommerce website odooV9
Imagine profil
Imagine profil
1
iun. 16
4965
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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