Skip to content

Commit

Permalink
[FIX] doc: gantt view no longer support date_delay
Browse files Browse the repository at this point in the history
Use date_stop instead, and remove the instruction to remove the computed
field.

closes odoo#45664

Signed-off-by: Denis Ledoux (dle) <[email protected]>
  • Loading branch information
madprog committed Feb 18, 2020
1 parent ea4dc2e commit 3650adb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 40 deletions.
1 change: 0 additions & 1 deletion doc/howtos/backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ their root element is ``<gantt>``.

.. only:: solutions

#. Create a computed field expressing the session's duration in hours
#. Add the gantt view's definition, and add the gantt view to the
*Session* model's action

Expand Down
34 changes: 2 additions & 32 deletions doc/howtos/backend/exercise-gantt
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,10 @@
# Parent dba00a105dd2a82490394b8dec5fea5f1d8847e1
# Parent f4374b6e2e661e0782e396b24c57c1eb97d13288

diff --git a/openacademy/models.py b/openacademy/models.py
--- a/openacademy/models.py
+++ b/openacademy/models.py
@@ -61,6 +61,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:
@@ -107,6 +110,15 @@ class Session(models.Model):
# so add one day to get 5 days instead
r.duration = (r.end_date - r.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
@@ -142,10 +142,22 @@
@@ -142,10 +142,21 @@
</field>
</record>

Expand All @@ -43,9 +14,8 @@ diff --git a/openacademy/views/openacademy.xml b/openacademy/views/openacademy.x
+ <field name="model">openacademy.session</field>
+ <field name="arch" type="xml">
+ <gantt string="Session Gantt"
+ date_start="start_date" date_delay="hours"
+ date_start="start_date" date_stop="end_date"
+ default_group_by='instructor_id'>
+ <!-- <field name="name"/> this is not required after Odoo 10.0 -->
+ </gantt>
+ </field>
+ </record>
Expand Down
14 changes: 7 additions & 7 deletions doc/howtos/backend/exercise-graph
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
diff --git a/openacademy/models.py b/openacademy/models.py
--- a/openacademy/models.py
+++ b/openacademy/models.py
@@ -64,6 +64,9 @@ class Session(models.Model):
hours = fields.Float(string="Duration in hours",
compute='_get_hours', inverse='_set_hours')
@@ -60,6 +60,9 @@ class Session(models.Model):
end_date = fields.Date(string="End Date", store=True,
compute='_get_end_date', inverse='_set_end_date')

+ attendees_count = fields.Integer(
+ string="Attendees count", compute='_get_attendees_count', store=True)
+
@api.depends('seats', 'attendee_ids')
def _taken_seats(self):
for r in self:
@@ -119,6 +122,11 @@ class Session(models.Model):
for r in self:
r.duration = r.hours / 24
@@ -106,6 +109,11 @@ class Session(models.Model):
# so add one day to get 5 days instead
r.duration = (r.end_date - r.start_date).days + 1

+ @api.depends('attendee_ids')
+ def _get_attendees_count(self):
Expand All @@ -30,7 +30,7 @@ diff --git a/openacademy/models.py b/openacademy/models.py
diff --git a/openacademy/views/openacademy.xml b/openacademy/views/openacademy.xml
--- a/openacademy/views/openacademy.xml
+++ b/openacademy/views/openacademy.xml
@@ -154,10 +154,21 @@
@@ -153,10 +153,21 @@
</field>
</record>

Expand Down

0 comments on commit 3650adb

Please sign in to comment.