Skip to Content
Menu
This question has been flagged
5 Replies
5112 Views

i want to make calendar view for planning of employee 

inherit = 'hr.employee'

_columns = {

'planing_line': fields.one2many('asc.rental.contract','rental_employ_id','planning driver'),

'is_driver': fields.boolean(' is driver'),

}

model  (asc.rental.contract) contain start_date and  end_date

how i can make calendar view for many period 

Avatar
Discard
Best Answer

To display one2many fields in a calendar view in Odoo, you will need to create a calendar view and define the fields that you want to display in the view.


Here is an example of how you can define a calendar view with one2many fields in Odoo:


Copy code

    Calendar View with One2many Fields

    project.task

    calendar

   

       

                  date_start="start_date"

                  date_stop="end_date"

                  mode="month"

                  color="priority"

                  display_secondary_color="True"

                  event_open_popup="True"

                  event_create="True"

                  all_day="True">

           

           

           

           

           

           

       

   

In this example, the calendar view displays the 'name', 'description', 'project_id', 'tag_ids', 'attachment_ids', and 'note_ids' fields from the 'project.task' model. The 'tag_ids', 'attachment_ids', and 'note_ids' fields are all one2many fields.


I hope this helps! Let me know if you have any further questions

Avatar
Discard
Best Answer

There's no direct way to do it. But yes another way around.

You can create a compute field and plot computed field in calendar view.


i.e.

calendar_common_date = fields.Date(string="date", compute='sync_date')

@api.depends('calendar_common_date')
def sync_visitdate(self):
for obj in self:
            if (your condition):
                obj.calendar_common_date = obj.date

For one2many field you will require to browse that particular model.


Hope this helps

Avatar
Discard
Best Answer

You can't: the Calendar view supports only one date field. For the effect you want you need four event records.

I suggest this design:

  • add to proevents.events a child model (one-to-many relation), proevents.events.date, to store the date records you need, and expected to have four rows.
  • have the calendar view use proevents.events.date.

Depending on your specific use case, you might need to add some logic to ensure that the four date lines are added for each event.

Note: your model should be named in singular and with the underlying main module as the first word: event.provevent.

Avatar
Discard
Author Best Answer

thank you for help 


Avatar
Discard
Best Answer

Hi,

You can make the calendar in the asc.rental.contract and make the color in the employee_id field ..

Avatar
Discard