Almabud
Almabud

Reputation: 162

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.

Upvotes: 3

Views: 2277

Answers (1)

Kenly
Kenly

Reputation: 26678

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).

Upvotes: 2

Related Questions