Server IP : 127.0.0.2 / Your IP : 18.222.84.251 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/doc/howtos/backend/ |
Upload File : |
# HG changeset patch # Parent dba00a105dd2a82490394b8dec5fea5f1d8847e1 # Parent f4374b6e2e661e0782e396b24c57c1eb97d13288 diff --git a/openacademy/models.py b/openacademy/models.py --- a/openacademy/models.py +++ b/openacademy/models.py @@ -59,6 +59,9 @@ class Session(models.Model): end_date = fields.Date(string="End Date", store=True, compute='_get_end_date', inverse='_set_end_date') + hours = fields.Float(string="Duration in hours", + compute='_get_hours', inverse='_set_hours') + @api.depends('seats', 'attendee_ids') def _taken_seats(self): for r in self: @@ -108,6 +111,15 @@ class Session(models.Model): end_date = fields.Datetime.from_string(r.end_date) r.duration = (end_date - start_date).days + 1 + @api.depends('duration') + def _get_hours(self): + for r in self: + r.hours = r.duration * 24 + + def _set_hours(self): + for r in self: + r.duration = r.hours / 24 + @api.constrains('instructor_id', 'attendee_ids') def _check_instructor_not_in_attendees(self): for r in self: diff --git a/openacademy/views/openacademy.xml b/openacademy/views/openacademy.xml --- a/openacademy/views/openacademy.xml +++ b/openacademy/views/openacademy.xml @@ -145,11 +145,23 @@ </field> </record> + <record model="ir.ui.view" id="session_gantt_view"> + <field name="name">session.gantt</field> + <field name="model">openacademy.session</field> + <field name="arch" type="xml"> + <gantt string="Session Gantt" color="course_id" + date_start="start_date" date_delay="hours" + default_group_by='instructor_id'> + <field name="name"/> + </gantt> + </field> + </record> + <record model="ir.actions.act_window" id="session_list_action"> <field name="name">Sessions</field> <field name="res_model">openacademy.session</field> <field name="view_type">form</field> - <field name="view_mode">tree,form,calendar</field> + <field name="view_mode">tree,form,calendar,gantt</field> </record> <menuitem id="session_menu" name="Sessions"