Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
4808 Vistas

Hi, i have problem with this JS

odoo.define('my_module.certification_template', function (require) {'use strict';
    var Model = require('web.Model')
    console.log('TESTTTTTTTTTTTTTTTTTTTTTTTTTT');

    (new Model('certification.certification').call('get_field_certificate_template').then(function (get_field) {
            var image_format = 'url("data:image/png;base64,'+ get_field + '")'

$(".certificate-img").css("background-image", image_format);

      }));

});


Python

class Certification(models.Model):
    _name = 'certification.certification'
    _description = 'Certification'

cert_template = Binary Field

@api.model
def get_field_certificate_template(self):
    for rec in self :
        get_field = rec.cert_template
    return get_field


QWEB

<div class="page certificate-img" style="border-collapse: collapse; page-break-after:always;">

<script type="text/javascript" src="/my_module/certification/certification_template.js"></script>


so i want trigger the javascript but when i print the template is nothing changed or console.log.

i don't know how to trigger this javascript

Avatar
Descartar
Mejor respuesta

Hello Chaanto,

Please make sure that your js file is registered to odoo asset.


<template id="assets_frontend" inherit_id="web.assets_frontend" name="Assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="path to js file"></script>
</xpath>
</template>

Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 20
3266
0
jun 21
4
0
jun 21
5
3
oct 18
14587
1
jun 25
3727