Search code examples
pythonxmlodooodoo-13

How to inherit and modify calendar view in Odoo 13?


I want to inherit a calendar view in my custom module and edit it's date_stop attribute, how can I inherit and do that? a piece of code would help a lot ! here are some details. (I am new to Odoo)

Module: time off

Model: hr.leave

external id (of calendar view) : hr_holidays.hr_leave_view_dashboard

I tried this, but shows error.

<!--Adding stop date 2 to calendar-->
    <record id="view_order_tree_inherited" model="ir.ui.view">
        <field name="name">calendar2.inherited</field>
        <field name="model">hr.leave</field>
        <field name="inherit_id" ref="hr_holidays.hr_leave_view_dashboard"/>
        <field name="arch" type="xml">
            <calendar js_class="time_off_calendar" string="Time Off Request" form_view_id="%(hr_holidays.hr_leave_view_form_dashboard)d" event_open_popup="true" date_start="date_from" date_stop="date_to_2" mode="month" quick_add="False" color="employee_id">
                <field name="display_name"/>
            </calendar>
        </field>
    </record>

Solution

  • You should see the following error in the log :

    Element '<calendar ...>' cannot be located in parent view
    

    To change the calendar date_stop attribute, you need to use the position attributes. Try to replace the calendar tag with the following:

    <calendar position="attributes">
        <attribute name="date_stop">date_to_2</attribute>
    </calendar>