Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
2921 Vizualizări

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.


Imagine profil
Abandonează
Cel mai bun răspuns

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',[])

})
});
});


Imagine profil
Abandonează
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

Related Posts Răspunsuri Vizualizări Activitate
0
mai 17
4084
1
mai 17
5484
3
mai 23
15492
1
oct. 20
6313
1
oct. 16
6564