Search code examples
pythonodooodoo-12

I'm tring to adding js_class to calendar view, but get the error below


I can add other attributes like "string" etc, and it's worked. But "js_class" cannot add like this. My code:

    <record id="view_calendar_event_calendar" model="ir.ui.view">
        <field name="name">view.calendar.event.calendar.inherit.calendar_extend</field>
        <field name="model">calendar.event</field>
        <field name="inherit_id" ref="calendar.view_calendar_event_calendar"/>
        <field name="arch" type="xml">
            <xpath expr="//calendar" position="attributes">
                <attribute name="js_class">calendar_extend_view</attribute>
            </xpath>
        </field>
    </record>

Here is error:

  File "/home/odoo/odoo-dev/odoo-source/odoo/addons/base/models/ir_ui_view.py", line 360, in _check_xml
    raise ValidationError(_('Invalid view %s definition in %s') % (view.name, view.arch_fs))
odoo.tools.convert.ParseError: "Invalid view view.calendar.event.calendar.inherit.calendar_extend definition in calendar_extend/views/calendar_event_views.xml
None" while parsing /home/odoo/odoo-dev/vpc-addons/calendar_extend/views/calendar_event_views.xml:89, near
<record id="test_view_calendar_event_calendar" model="ir.ui.view">
        <field name="name">view.calendar.event.calendar.inherit.calendar_extend</field>
        <field name="model">calendar.event</field>
        <field name="inherit_id" ref="calendar.view_calendar_event_calendar"/>
        <field name="arch" type="xml">
            <xpath expr="//calendar" position="attributes">
                <attribute name="js_class">calendar_extend_view</attribute>
            </xpath>
        </field>
    </record>
> /home/odoo/odoo-dev/odoo-source/odoo/addons/base/models/ir_ui_view.py(360)_check_xml()
-> raise ValidationError(_('Invalid view %s definition in %s') % (view.name, view.arch_fs))
(Pdb) 

I'm sure about my js code is correctly.


Solution

  • If someone meet this problem, it might be your source code is outdated. This problem has been fixed in OdooCE. Here is the related issue in Github: https://github.com/odoo/odoo/pull/31679