Search code examples
javascriptodooqr-codeodoo-12

how to implement third party JS library in Odoo


Hi I want to implement this qr code generator in odoo pos but i don't have any idea how to do it and I can't see any tutorial even in Javascript reference in odoo 12

I want to generate a qr code with the receipt reference(this.uid) as output(when scanned) and display it in PosTicket

i've tried adding the qrcode.min.js and qrcode.js in my static/src/js folder and adding

<script src="/tw_pos_inherit/static/src/js/qrcode.min.js" type="text/javascript"></script>
<script src="/tw_pos_inherit/static/src/js/qrcode.js" type="text/javascript"></script>

to my view and tried the said example but it always give me an error

anyone who have an idea how to use third party javascript library in odoo12 please show me an example

thank you


Solution

  • OK so I just need to move the js and min.js file in my static/src/js folder and add the code

    <script src="/tw_pos_inherit/static/src/js/qrcode.js" type="text/javascript"></script>
    <script src="/tw_pos_inherit/static/src/js/qrcode.min.js" type="text/javascript"></script>
    

    to my assets file and

    and i tried the examples again like

    this.qrcode = new QRCode('qrcode');
    this.qrcode.makeCode(this.pos.get_order().uid);
    

    to my initialized function and it worked properly