Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
2965 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
0
Mei 17
4137
1
Mei 17
5547
3
Mei 23
15612
1
Okt 20
6432
1
Okt 16
6614