Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2972 Widoki

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.


Awatar
Odrzuć
Najlepsza odpowiedź

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

})
});
});


Awatar
Odrzuć
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

Powiązane posty Odpowiedzi Widoki Czynność
0
maj 17
4143
1
maj 17
5557
3
maj 23
15630
1
paź 20
6440
1
paź 16
6623