# HG changeset patch
# Parent a358be0a577b0569831958a8ec1302825c645dee

Index: addons/openacademy/models.py
===================================================================
--- addons.orig/openacademy/models.py	2014-08-26 17:26:03.795783315 +0200
+++ addons/openacademy/models.py	2014-08-26 17:26:03.791783315 +0200
@@ -28,3 +28,13 @@
     course_id = fields.Many2one('openacademy.course',
         ondelete='cascade', string="Course", required=True)
     attendee_ids = fields.Many2many('res.partner', string="Attendees")
+
+    taken_seats = fields.Float(string="Taken seats", compute='_taken_seats')
+
+    @api.one
+    @api.depends('seats', 'attendee_ids')
+    def _taken_seats(self):
+        if not self.seats:
+            self.taken_seats = 0.0
+        else:
+            self.taken_seats = 100.0 * len(self.attendee_ids) / self.seats
Index: addons/openacademy/views/openacademy.xml
===================================================================
--- addons.orig/openacademy/views/openacademy.xml	2014-08-26 17:26:03.795783315 +0200
+++ addons/openacademy/views/openacademy.xml	2014-08-26 17:26:03.791783315 +0200
@@ -100,6 +100,7 @@
                                 <field name="start_date"/>
                                 <field name="duration"/>
                                 <field name="seats"/>
+                                <field name="taken_seats" widget="progressbar"/>
                             </group>
                         </group>
                         <label for="attendee_ids"/>
@@ -117,6 +118,7 @@
                 <tree string="Session Tree">
                     <field name="name"/>
                     <field name="course_id"/>
+                    <field name="taken_seats" widget="progressbar"/>
                 </tree>
             </field>
         </record>
