Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call qweb template inside odoo data template

I am trying to make an OTP service for login and registration. So I made a module for otp service that is working fine. But here for UI, I made and template that should be called inside the login page to visible the otp box and otp send button. Please see samplae code bellow:

<templates xml:space="preserve">
    <div name="otp_service" t-name="bulk_sms_otp_service.otp_service">
        <h1>Hello world</h1>
    </div>
</templates>

Now I am trying to call this template inside login view. Please see bellow:

<odoo>
  <template id="custom_login" name="Custom login" inherit_id="web.login">
    <xpath expr="//p[hasclass('alert-success')]" position="after">
        <t t-call="bulk_sms_otp_service.otp_service"/>
    </xpath>
  </template>
</odoo>

But this call not working. Giving me an error like:

External id "bulk_sms_otp_service.otp_service" not found

I don't know what's wrong with my code or I am wrong. Please Help me to solve this issue.

like image 318
Almabud Avatar asked Mar 01 '26 06:03

Almabud


1 Answers

You can read at Helpers:

in which case templates stored in the database (as views)

You can deduct that some qweb templates are not stored in database.

You can also read in the JS QWeb Template Engine documentation that templates defined in files listed in the qweb entry in each module manifest are loaded when the web client starts.

When odoo process custom_login template it will try to retrive the bulk_sms_otp_service.otp_service template view_id (From ir.model.data) to read the corresponding template and it will fail because custom_login templates is not stored in database (In ir.ui.view).

like image 136
Kenly Avatar answered Mar 03 '26 16:03

Kenly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!