تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5330 أدوات العرض

I have the following method on my model:

from openerp import models, fields, api, SUPERUSER_ID

class Loan(models.Model):
    _name = 'loan'

    @api.model
    def send_mail_function_model(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

This is my email template:

<?xml version="1.0" ?>
<openerp>
<data noupdate="1">
    <!--Email template -->
    <record id="email_template_loan" model="mail.template">
        <field name="name">Loan - Send by Email</field>
        <field name="email_from">${(object.company_id.loan_email and '%s &lt;%s&gt;' % (object.company_id.name, object.company_id.loan_email) or '')|safe}</field>
        <field name="subject">${object.company_id.name} Invoice (Ref ${object.number or 'n/a'})</field>
        <!--<field name="partner_to">${object.partner_id.id}</field>-->
        <field name="model_id" ref="base.model_res_company"/>
        <field name="auto_delete" eval="True"/>
        <field name="lang">${object.env.user.lang}</field>
        <field name="body_html"><![CDATA[
        ]]></field>
    </record>
</data>
</openerp>

Now, since this method should an email from frontpage (a website page) I've made this javascript function:

odoo.define('opencloud_cashflows.loan_send', 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('loan');
    $('#send_mail_function_model').click(function(){

        model.call('send_mail_function_model',[])

    })
});
});

Then I call this from website page like this:

<script type="text/javascript" src="/opencloud_cashflows/static/src/js/email.js"/>

And in the button which should trigger the javascript:

<center><input id="loan_send" class="btn btn-primary btn-lg" name="loan_send" value="Pedir préstamo al Banco" type="submit" style="background-color:#e67e22;"/></center>

But it doesn't do anything, any ideas on what could be wrong here please?

الصورة الرمزية
إهمال
أفضل إجابة

Here your button id is

input id="loan_send" but you are listening event of unknown id 
 $('#send_mail_function_model')

الصورة الرمزية
إهمال
الكاتب

Hi, well it doesn't "do anything" but I think it is actually the concept, I mean, in this case, it will deliver the email by reading the backend odoo configuration? Just asking to be sure, I mean this routine seems to work but there is no receipt though

What is actually you need, just check whether you configured the outgoing mail server and if you need more to be done, hire an odoo developer

الكاتب

Yes, it is configured, but the task is quite confusing, so if I have more doubts I'll open a new question, Thank You

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أكتوبر 16
6372
0
مايو 17
3962
0
مايو 17
2830
1
مايو 17
2857
0
يناير 25
866