Create a Modal Dialog in Odoo Website

I did create my Modal Popup in xml and put it in /my_module/static/src/xml/ folder

<t t-name="my_module.homepage_modal">
<!-- modal popup content , Signup prompt-->
</t>

This template is associated with a Javascript widget. I did render it in homepage using JavaScript as follows.

ajax.loadXML('/my_module/static/src/xml/modal_view.xml', qweb);

var ModalPopup = Widget.extend({
    template: 'my_module.homepage_modal',

    start: function () {
        this.$el.modal();
    },
});

base.ready().done(function() {

    if (location.pathname == '/'){
        var modal1 = new ModalPopup();
        modal1.appendTo($(document.body));

    };

});`

I have to render this Popup only when the user is not logged in (ie Public user). How can I do this? How can I check the current user id from JavaScript?

Answers:

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.