Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo - Using template in calendar view?

Is it possible to use Qweb template in calendar view? I want to modify it a bit, but all I can do is just add new fields to be showed in calendar item, like this - field1, field2, field3.....

Is there any better way to customize calendar view, like you can with kanban view by using Qweb templating engine?

For example if I use like this:

    <record model="ir.ui.view" id="view_calendar_service_work_calendar">
        <field name="name">Service Works Calendar</field>
        <field name="model">calendar.service.work</field>
        <field name="priority" eval="1"/>
        <field name="arch" type="xml">
            <calendar string="Service Works" date_start="start_time" color="employee_id" date_stop="end_time" mode="week">
                <field name="name"/>
                <field name="employee_id"/>                                     
                <template>
                    <t t-name="something"></t>
                </template>
            </calendar>
        </field>
    </record>  

This will throw error:

Uncaught TypeError: Cannot read property 'type' of undefined

http://localhost:8090/web_calendar/static/src/js/web_calendar.js:414

As a matter of fact, if I use anything else other than field tag, it will throw that error. I can't even use div tag. So it seems you can't style calendar at all?

like image 719
Andrius Avatar asked Oct 31 '22 19:10

Andrius


1 Answers

You can Define in Calendar Controller Following Attributes. This is the Rules are Define in odoo Framework this all are Attribute is use in calendar tag. so you can not use template tag in calendar.

  • string
  • color
  • date_start
  • date_stop
  • day_length
  • date_delay
  • all_day
  • event_open_popup
  • attendee
  • color_is_attendee
  • avatar_filter
  • avatar_model
  • avatar_title
  • use_contacts
  • quick_add
  • display
  • type
  • mode ==> month/week/day
  • html

Example :

 <field name="arch" type="xml">
            <calendar string="Meetings" date_start="start" date_stop="stop" date_delay="duration" all_day="allday" 
                         display="[name]" color="color_partner_id" attendee="partner_ids" avatar_model="res.partner"
                         use_contacts="True" event_open_popup="%(calendar.view_calendar_event_form_popup)s">
                <field name="name"/>
                <field name="user_id"/>
                <field name="color_partner_id"/>
                <field name="partner_ids"/>
            </calendar>
        </field>

If you change the view of the calendar then you can modified in web_calendar module.

i hope you understand.

like image 175
Jainik Patel Avatar answered Nov 15 '22 09:11

Jainik Patel