跳至内容
菜单
此问题已终结

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.


形象
丢弃
最佳答案

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

})
});
});


形象
丢弃
编写者

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

相关帖文 回复 查看 活动
0
5月 17
4163
1
5月 17
5579
3
5月 23
15667
1
10月 20
6454
1
10月 16
6640