Skip to Content
Menu
This question has been flagged
1 Reply
8460 Views

I am creating website theme and in that i have created my custom module for my services. now i want to show them on home page.
<t t-foreach="request.env['websoly_apps.websoly_apps'].search([])" t-as="WebsolyApp">

      <div class="appstore-i">

               <a href="#" >

                   <img class="appstore-image" t-att-src="'data:image/png;base64,%s' % WebsolyApp.photo"/>

                   <span><p class="appstore-name"><t t-esc="WebsolyApp.name"/></p></span>

                   <span><p class="appstore-download"><t t-esc="WebsolyApp.downloads"/> <i class="fa fa-download" aria-hidden="true"></i></p></span>

               </a>

           </div>

</t>


it works fine but only extent when i am login. when i open it in incognito it gives error.

Avatar
Discard
Best Answer

Hello Ahmed,


Your Problem

=============

  • If you access any model record on website that time public user have no rights for directly access. So add sudo()  to access model record.

  • Use sudo() to give super user rights.

  • For Example,

    •  <t t-foreach="request.env['websoly_apps.websoly_apps'].sudo().search([])" t-as="WebsolyApp" />


Solution
=============

Try this below code, 

<t t-foreach="request.env['websoly_apps.websoly_apps'].sudo().search([])" t-as="WebsolyApp">

      <div class="appstore-i">

               <a href="#" >

                   <img class="appstore-image" t-att-src="'data:image/png;base64,%s' % WebsolyApp.photo"/>

                   <span><p class="appstore-name"><t t-esc="WebsolyApp.name"/></p></span>

                   <span><p class="appstore-download"><t t-esc="WebsolyApp.downloads"/> <i class="fa fa-download" aria-hidden="true"></i></p></span>

               </a>

           </div>

</t>


I hope my answer is helpful.

If any query so comment please.

Avatar
Discard
Author

you are savior bro.

it's my pleasure

Related Posts Replies Views Activity
3
Sep 21
2898
2
Jan 20
6341
1
Sep 16
2269
0
Oct 16
2412
4
Dec 23
2506