[IMP]GOLEM Activity Session : add minimum places and significant colors to tree

This commit is contained in:
Fabien Bourgeois 2016-06-28 19:20:00 +02:00
parent 661849e8b7
commit fd775e5a08
2 changed files with 20 additions and 4 deletions

View File

@ -61,6 +61,13 @@ class GolemActivitySession(models.Model):
s.name = s.activity_id.activity_name s.name = s.activity_id.activity_name
member_ids = fields.Many2many('golem.member', string='Members') member_ids = fields.Many2many('golem.member', string='Members')
places_used = fields.Integer('Places used', compute='_compute_places_used')
@api.depends('member_ids')
def _compute_places_used(self):
for s in self:
s.places_used = len(s.member_ids)
# TODO: recurrence etc... to link with calendar.event # TODO: recurrence etc... to link with calendar.event
activity_id = fields.Many2one('golem.activity', string='Activité', activity_id = fields.Many2one('golem.activity', string='Activité',
required=True) required=True)
@ -86,6 +93,8 @@ class GolemActivitySession(models.Model):
'after end of the period.')) 'after end of the period.'))
places = fields.Integer('Places', default=0) places = fields.Integer('Places', default=0)
places_min = fields.Integer('Minimum places', default=0,
help="Minimum places to maintain the session")
is_overbooked = fields.Boolean('Allow overbook?', default=False) is_overbooked = fields.Boolean('Allow overbook?', default=False)
places_overbooked = fields.Integer('Places with overbook', default=0) places_overbooked = fields.Integer('Places with overbook', default=0)
places_remain = fields.Integer('Remaining places', store=True, places_remain = fields.Integer('Remaining places', store=True,

View File

@ -44,6 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="activity_id" /> <field name="activity_id" />
<field name="animator_id" /> <field name="animator_id" />
<field name="places" /> <field name="places" />
<field name="places_min" />
<field name="is_overbooked" /> <field name="is_overbooked" />
<field name="places_overbooked" <field name="places_overbooked"
attrs="{'invisible': [('is_overbooked', '=', False)]}" /> attrs="{'invisible': [('is_overbooked', '=', False)]}" />
@ -76,12 +77,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="name">Session list</field> <field name="name">Session list</field>
<field name="model">golem.activity.session</field> <field name="model">golem.activity.session</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree> <tree colors="darkgrey: places_used &lt; places_min;
red: places_remain == 0;
orange: places_remain &lt;= 4;">
<field name="activity_id" /> <field name="activity_id" />
<field name="animator_id" /> <field name="animator_id" />
<field name="weekday" /> <field name="weekday" string="Day" />
<field name="hour_start" /> <field name="hour_start" string="Start" />
<field name="hour_end" /> <field name="hour_end" string="End" />
<field name="places" />
<field name="places_min" string="Min." />
<field name="places_remain" string="Remain" />
<field name="places_used" invisible="True" />
</tree> </tree>
</field> </field>
</record> </record>