This commit is contained in:
michel 2017-11-14 13:43:06 +01:00
parent 1c81289236
commit c47575ce45
8 changed files with 83 additions and 5 deletions

3
.floo Normal file
View File

@ -0,0 +1,3 @@
{
"url": "https://floobits.com/yaltik/coworking"
}

9
.flooignore Normal file
View File

@ -0,0 +1,9 @@
#*
*.o
*.pyc
*~
extern/
heroku.yml
node_modules/
tmp
vendor/

View File

@ -1,3 +1,4 @@
[MASTER]
load-plugins=pylint_odoo
disable=C8101

0
Note.txt Normal file
View File

View File

@ -42,6 +42,11 @@ class Coworker(models.Model):
is_done = fields.Boolean('Done?')
is_active = fields.Boolean('Active?', default=True)
# Event fields
manager_event_ids = fields.One2many('coworking.event', 'manager_id',
string='Events managed')
event_ids = fields.Many2many('coworking.event', string='Events visited')
@api.depends('name', 'firstname')
def _compute_full_name(self):

View File

@ -12,7 +12,8 @@ class Event(models.Model):
_order = 'id desc'
title = fields.Char(required=True)
manager_id = fields.Many2one('coworking.coworker', 'Users', required=False, index=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)
date_end = fields.Datetime(required=True)
@ -22,8 +23,23 @@ class Event(models.Model):
('confirmed', 'Confirmed'),
('canceled', 'Canceled')], default='draft')
participants_ids = fields.Many2many('coworking.coworker', string='Users')
participants_ids = fields.Many2many('coworking.coworker', string='Subscribers')
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.constrains('statut', 'participants_ids')
def _check_if_confirmed(self):
"""Test si participants_ids est confirmed"""
for event in self:
if event.participants_ids and event.statut == 'draft':
raise models.ValidationError(_('You can have subscribed people '
'if event is not confirmed yet'))
@api.constrains('date_end')
def _check_date_end(self):

View File

@ -38,6 +38,11 @@
<field name="note" />
</page>
<page string="Events" name="Events">
<group name="events">
<field name="manager_event_ids"
context="{'default_manager_id': active_id}" />
<field name="event_ids" />
</group>
</page>
</notebook>
</groupe>

View File

@ -7,6 +7,9 @@
<field name="model">coworking.event</field>
<field name="arch" type="xml">
<form string="event">
<header>
<field name="statut" widget="statusbar" clickable="1" />
</header>
<sheet>
<group name="group_top">
<group name="group_left">
@ -16,8 +19,8 @@
<field name="date_end" />
<field name="duration" />
<field name="description" />
<field name="statut" />
<fiels name="participants_ids" />
<field name="participants_ids" widget="many2many_tags"
options="{'no_create': true}" />
</group>
</group>
</sheet>
@ -34,10 +37,46 @@
<field name="title" />
<field name="manager_id" />
<field name="date_start" />
<field name="participants_ids" />
<field name="participants_count" />
<field name="statut" />
</tree>
</field>
</record>
<!-- Search -->
<record id="view_search_event" model="ir.ui.view">
<field name="name">Event Search</field>
<field name="model">coworking.event</field>
<field name="arch" type="xml">
<search>
<field name="title" />
<field name="manager" />
<filter name="Satut" string="confirmed"
domain="[('statut','!=',False)]" />
<filter name="in_compagny" string="in_compagny"
domain="[('company_name','!=',False)]" />
<separator />
<filter name="is_savoyar" string="Is_savoyar"
domain="[('contact_zip','=like','73___')]" />
<filter name="meet_of_2017" string="Meet_of_2017"
domain="[('contact_date','like','2017')]" />
<filter name="group_city" string="Group city"
context="{'group_by': 'city'}" />
<filter name="group_month" string="Group month"
context="{'group_by': 'contact_date'}" />
<filter name="group_years" string="Group years"
context="{'group_by': 'contact_date:year'}" />
</search>
</field>
</record>
</odoo>