62 lines
2.3 KiB
Plaintext
62 lines
2.3 KiB
Plaintext
# 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"
|