Uncaught TypeError: Cannot read property 'length' of undefined

Bug #1118564 reported by Fabio Colognesi
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Web (MOVED TO GITHUB)
Confirmed
Undecided
Unassigned

Bug Description

OpenERP version 7.0-20130206-000101

I have a search view on "ir.attachment" in which I prepared two o three filters on "create_date" field to report documents created "Today", "Yesterday" or "Last Week". This filter works well in 6.1, in 6.2 but in 7.0 raise a message :

Uncaught TypeError: Cannot read property 'length' of undefined
http://localhost:8069/web/webclient/js:3209

If I try to connect to 7.0 with GTK Client (6.1 version) my filter works fine, so it could seem a web issue.

Search View is :

    <record model="ir.ui.view" id="plm_document_search">
         <field name="name">plm.document</field>
         <field name="model">ir.attachment</field>
         <field name="type">search</field>
         <field name="priority" eval="1"/>
         <field name="arch" type="xml">
     <search string="Attachments">
                    <group colspan="4" col="10">
                        <filter icon="terp-go-month" string=" Last Month " separator="1"
                                domain="[('create_date','&lt;=', (datetime.date.today() - relativedelta(day=31,months=1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
                                help="Created last month"/>
                        <filter icon="terp-go-month" string=" Last Week " separator="1"
                                domain="[('create_date','&lt;=', (datetime.date.today()-relativedelta(weeks=1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;=',(datetime.date.today()-relativedelta(weeks=2)).strftime('%%Y-%%m-%%d'))]"
                                help="Created last week"/>
                        <filter icon="terp-go-month" string=" Latest 7 Days " separator="1"
                                domain="[('create_date','&lt;=', (datetime.date.today()).strftime('%%Y-%%m-%%d')),('create_date','&gt;=',(datetime.date.today()-relativedelta(weeks=1)).strftime('%%Y-%%m-%%d'))]"
                                help="Created latest 7 Days"/>
                   <filter icon="terp-go-month" string=" Yesterday " separator="1"
                           domain="[('create_date','&lt;=', (datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d')),('create_date','&gt;=',(datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d'))]"
                           help="Created yesterday"/>
                  <filter icon="terp-go-month" string=" Today " separator="1"
                           domain="[('create_date','&lt;=', (datetime.date.today()).strftime('%%Y-%%m-%%d')),('create_date','&gt;=',(datetime.date.today()).strftime('%%Y-%%m-%%d'))]"
                           help="Created today"/>
                     <separator orientation="vertical"/>
                        <field name="name"/>
                        <field name="datas_fname"/>
                        <field name="create_uid">
                            <filter icon="terp-personal" domain="[('create_uid','=',uid)]" help="Filter on documents created by me"/>
                        </field>
                        <field name="write_uid">
                            <filter icon="terp-personal" domain="[('write_uid','=',uid)]" help="Filter on documents changed by me"/>
                        </field>
                     <separator orientation="vertical"/>
                     <filter string="Confirmed" icon="terp-stock_symbol-selection" domain="[('state', '=', 'confirmed')]"/>
                     <filter string="Released" icon="terp-stock_symbol-selection" domain="['|',('state', '=', 'released'),('state', '=', 'undermodify')]"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Group By...">
                        <filter string="Owner" icon="terp-personal" domain="[]" context="{'group_by':'create_uid'}"/>
                        <filter string="Month" help="Creation Month" icon="terp-go-month" domain="[]" context="{'group_by':'create_date'}"/>
                    </group>
              </search>
         </field>
    </record>

I'm using Google Chrome Version 24.0.1312.57 m on Windows XP

Many Thanks
Regards

Related branches

Revision history for this message
gmarcon (gmarcon) wrote :

"Uncaught TypeError: Cannot read property 'length' of undefined" is a very generic error that means that the filter did not work as expected. To verify the error enter in debug mode (About OpenERP > Activate the developer mode), debugging the javascript (in my case views.js line 776) you can verify the error object.

It seems that the relativedelta implementation in pyeval.ps does not take named arguments (could be a general problem of the javascript python evaluator implementation), my error is "TypeError: function takes exactly 19 arguments".

Revision history for this message
gmarcon (gmarcon) wrote :

I managed to call the relativedelta function with the Python Javascript implementation explicitly passing all the named parameters:
relativedelta(year=0, month=0, day=0, hour=0, minute=0, second=0, microsecond=0, years=0, months=1, weeks=0, days=0, hours=0, minutes=0, secondes=0, microseconds=0, weekday=0, leakdays=0, yearday=0, nlyearday=0).

But datetime.date.today() is not working (Error from the interpreter: "AttributeError: object has no attribute 'today'").

I have the feeling that the Javascript Python interpreter still needs some reworks...

Revision history for this message
Mohammed Shekha(Open ERP) (msh-openerp) wrote :

Hello,

It has been fixed in lp:~openerp-dev/openerp-web/7.0-opw-591255-msh.

Thanks.

Changed in openerp-web:
status: New → Fix Committed
Revision history for this message
gmarcon (gmarcon) wrote :

The provided fix is only related to the datetime.date.today function call.

Would you also able to address the relativedelta function call? The main problems seems to be that it is not possible to call it with named arguments. Additionally the relativedelta function has several TODOs and FIXMEs in the code (including a very frightening "TODO: test this whole mess").

I am available to test the implementation in real life cases if needed.

Thank you and regards.

Changed in openerp-web:
status: Fix Committed → Confirmed
Revision history for this message
gmarcon (gmarcon) wrote :

I do not agree that this is a duplicate of #1081044. "Uncaught TypeError: Cannot read property 'length' of undefined" is a very generic error and represents several errors on the web client.

The specific bug reported here is related to the relativedelta function call of the Javascript Python interpreter (/addons/web/static/src/js/pyeval.js ). It could be related to the more generic problem of the Javascript Python interpreter not supporting function calls with named arguments - but that does not seem the problem of #1081044 to me...

Changed in openerp-web:
status: Confirmed → Fix Committed
status: Fix Committed → Confirmed
Revision history for this message
Ajit (alessandro-domanico) wrote :

I agree with @gmarcon that it is a generic error, in my case it occurs on

http://localhost:8069/web/static/src/js/view_form.js:3306

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.