Skip to Content
Menu
This question has been flagged

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
1
Sep 20
2571
0
Jun 21
4
0
Jun 21
5
3
Oct 18
13697
2
Jul 24
12604