Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
346 Vues

I have created a module for displaying information on a portal. I have restarted the server and upgraded the module. however, when navigating on the portal, i got a pop-up error and when i closed the pop - up, i got the never-ending loading icon. 


Here is the controller code:


error:

UncaughtPromiseError > TypeError


Uncaught Promise > Cannot set properties of null (setting 'textContent')


Occured on localhost:8069 on 2025-04-24 12:48:44 GMT


TypeError: Cannot set properties of null (setting 'textContent')

    at http://localhost:8069/web/assets/c2de72e/web.assets_frontend_lazy.min.js:8417:2095

    at Array.forEach (<anonymous>)

    at http://localhost:8069/web/assets/c2de72e/web.assets_frontend_lazy.min.js:8417:1951

    at async Promise.all (index 0)



Here is the controller code:

from odoo.addons.portal.controllers.portal import CustomerPortal

from odoo import http

from odoo.http import request

 

class WeblearnsPortal(CustomerPortal):

    def _prepare_home_portal_values(self,counters):

        values = super(WeblearnsPortal, self)._prepare_home_portal_values(counters)

        student_counts = http.request.env['track.trace'].search_count([])

        values.update({

            'student_counts': student_counts

        })

        return values

Here is the template code:

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

 

    <template id="portal_my_home" name="Demo Records" inherit_id="portal.portal_my_home">

        <xpath expr="//div[hasclass('o_portal_docs')]" position="inside">

            <t t-if="student_counts" t-call="portal.portal_docs_entry">

                <t t-set="url">/my/students</t>

                <t t-set="title">Trace</t>

                <t t-set="count" t-value="student_counts"/>

                <t t-set="config_card" t-value="True"/>

            </t>

        </xpath>

    </template>

 

</odoo>

I wish to have something like below:

Avatar
Ignorer
Meilleure réponse

Hi,

Please update your code like this:-


In .py file


from odoo.addons.portal.controllers.portal import CustomerPortal


from odoo import http


from odoo.http import request



class WeblearnsPortal(CustomerPortal):


  def _prepare_home_portal_values(self, counters):

      values = super()._prepare_home_portal_values(counters)

      if 'student_count' in counters:

          values['student_count'] = http.request.env['track.trace'].search_count([])

      return values



In xml file

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

  <template id="portal_my_home_students" name="Demo Records"

            inherit_id="portal.portal_my_home">

      <xpath expr="//div[hasclass('o_portal_docs')]" position="inside">

          <t t-call="portal.portal_docs_entry">

              <t t-set="title">Students</t>

              <t t-set="url" t-value="'/my/students'"/>

              <t t-set="placeholder_count" t-value="'student_count'"/>

              <t t-set="show_count" t-value="True"/>

              <t t-set="count" t-value="student_count"/>

          </t>

      </xpath>

  </template>

</odoo>


Hope it helps

Avatar
Ignorer
Publications associées Réponses Vues Activité
0
mai 25
71
1
mai 25
234
0
avr. 25
2
1
avr. 25
399
1
avr. 25
373