Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2977 Vistas

I have this method:

@api.model
def send_mail_function(self):
    template_id = self.env.ref('opencloud_cashflows.email_template_loan')
    if template_id:
       template_id.send_mail(self.id, force_send=True)
    return True

I call this from a website page like this:

<center><input 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;"/></center>

But it doesn't do anything, is there something else I need to do to call this method from frontend/website on Odoo?

I'm on Odoo v9 community.


Avatar
Descartar
Mejor respuesta

You can call button action as we did on odoo backend using its name on website pages, you need to trigger the function from front page to the model, like:-


odoo.define('module.custom_name', function (require) {
"use strict";
var ajax = require('web.ajax');
var core = require('web.core');
var session = require('web.session');
var base = require('web_editor.base');
var _t = core._t;
base.url_translations = '/website/translations';
var _t = core._t;
var Model = require('web.DataModel');
$(document).ready(function(){
var model = new Model('Your.Model');
$('#send_mail_function').click(function(){

model.call('send_mail_function',[])

})
});
});


Avatar
Descartar
Autor

Hi, Thank You very much, just a question, should I put this on my webpage directly? Like inside these marks <script></script>, or better, should they be on static/src as a file?

static file is better

Publicaciones relacionadas Respuestas Vistas Actividad
0
may 17
4153
1
may 17
5571
3
may 23
15657
1
oct 20
6451
1
oct 16
6627