Skip to Content
Menu
This question has been flagged
2 Replies
1878 Zobrazenia

Hi,

I am working on an integration with Odoo that makes use of a JavaScript applet on the website to read the attributes of a

element and use them to identify the logged in customer.

Unfortunately, I am a noob at front-end development and cannot get it to work.

An element like this does output the email address, for instance me@example.com, of the user onto the web page:

This does not happen in the identification

element:
    id="customer-identification-html-element"
data-authenticated="true"
    data-email="me@example.com"
/>

How can I assign the value of request.env.user.partner_id.email to the data-email attribute?


Thanks!

Andrea

Avatar
Zrušiť
Autor Best Answer

Thanks John! I tried changing the attributes, writing them as this, but then Odoo is not able to render the template

    id="customer-identification-html-element"
    data-authenticated="true"
    t-att-data-email="me@example.com"


Avatar
Zrušiť

If you are giving static value, then give the email in quotes. t-att-data-email="'me@example.com'"

Autor

Thanks for the help, John! I would like to respond to your answer directly, but do not have enough karma points.

I actually solved it by writing the attributes as follows:

id="customer-identification-html-element"
data-authenticated="true"
t-attf-data-email="{{request and request.env.user.partner_id.email}}"

The trick was to prefix t-attf- to the name of the data-email attribute, so that what's inside the double curly braces is then processed as code and resolves to the email address of the logged in customer.

t-attf- is then stripped while rendering, and the external service sees it as data-email="me@example.com"

Best Answer

Give t-att values in the website template. t-att-data-email="request.env.user.paretner_id.email"

Avatar
Zrušiť