sur event : il faudrait que title soit reconnu comme le nom du modéle

This commit is contained in:
michel 2017-11-15 11:53:14 +01:00
parent 877632aab8
commit 797bef0aee
2 changed files with 14 additions and 7 deletions

View File

@ -12,7 +12,7 @@ class Event(models.Model):
_description = 'Event model definition'
_order = 'id desc'
title = fields.Char(required=True)
name = fields.Char('Title', required=True)
manager_id = fields.Many2one('coworking.coworker', 'Manager', index=True,
domain="[('coworker_type', 'in', ['staffer', 'member'])]")
date_start = fields.Datetime(default=fields.Date.context_today, required=True)
@ -30,6 +30,13 @@ class Event(models.Model):
participants_count = fields.Integer('Number of participants',
compute='_compute_participants_count')
@api.depends('participants_ids')
def _compute_participants_count(self):
""" Computes number of participants """
for event in self:
event.participants_count = len(event.participants_ids)
@api.depends('date_start')
def _compute_starts_this_week(self):
""" Computes is event starts this week """

View File

@ -13,7 +13,7 @@
<sheet>
<group name="group_top">
<group name="group_left">
<field name="title" />
<field name="name" />
<field name="manager_id" />
<field name="date_start" />
<field name="starts_this_week" attrs="{'invisible': [('date_start', '=', True)]}" />
@ -34,8 +34,8 @@
<field name="name">event Tree</field>
<field name="model">coworking.event</field>
<field name="arch" type="xml">
<tree default_order="date_start desc, title asc">
<field name="title" />
<tree default_order="date_start desc, name asc">
<field name="name" />
<field name="manager_id" />
<field name="date_start" />
<field name="participants_count" />
@ -50,7 +50,7 @@
<field name="model">coworking.event</field>
<field name="arch" type="xml">
<search>
<field name="title" />
<field name="name" />
<field name="manager_id" />
<filter name="status_confirmed" string="Confirmed"
@ -87,8 +87,8 @@
<field name="model">coworking.event</field>
<field name="arch" type="xml">
<calendar date_start="date_start" date_stop="date_end"
display="Title : [title]" >
<field name="title" />
display="name : [name]" >
<field name="name" />
</calendar>
</field>
</record>