forked from michel/Coworking
/
This commit is contained in:
parent
c47575ce45
commit
168f28d0c9
@ -2,6 +2,7 @@
|
||||
|
||||
""" Event module """
|
||||
|
||||
from datetime import datetime
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
@ -15,17 +16,39 @@ class Event(models.Model):
|
||||
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)
|
||||
starts_this_week = fields.Integer(compute='_compute_starts_this_week',
|
||||
search='_search_starts_this_week')
|
||||
date_end = fields.Datetime(required=True)
|
||||
|
||||
duration = fields.Float(compute='_compute_duration')
|
||||
description = fields.Text()
|
||||
statut = fields.Selection([('draft', 'Draft'),
|
||||
('confirmed', 'Confirmed'),
|
||||
('canceled', 'Canceled')], default='draft')
|
||||
('canceled', 'Canceled')], default='canceled')
|
||||
|
||||
participants_ids = fields.Many2many('coworking.coworker', string='Subscribers')
|
||||
participants_count = fields.Integer('Number of participants',
|
||||
compute='_compute_participants_count')
|
||||
participants_count2 = fields.Integer('Number of participants #2',
|
||||
compute='_compute_participants_count')
|
||||
|
||||
@api.depends('date_start')
|
||||
def _compute_starts_this_week(self):
|
||||
""" Computes is event starts this week """
|
||||
for event in self:
|
||||
date_start = fields.Datetime.from_string(event.date_start)
|
||||
week_start = date_start.isocalendar()[1]
|
||||
event.starts_this_week = (datetime.now().isocalendar()[1] == week_start)
|
||||
|
||||
def _search_starts_this_week(self, operator, value):
|
||||
""" Searches function for starts_this_week """
|
||||
res_ids = []
|
||||
for event in self.search([]):
|
||||
date_start = fields.Datetime.from_string(event.date_start)
|
||||
week_start = date_start.isocalendar()[1]
|
||||
if datetime.now().isocalendar()[1] == week_start:
|
||||
res_ids.append(event.id)
|
||||
return [('id', 'in', res_ids)]
|
||||
|
||||
@api.depends('participants_ids')
|
||||
def _compute_participants_count(self):
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
<!-- Action to open Coworkers list -->
|
||||
<act_window id="event_action" name="Event"
|
||||
res_model="coworking.event" view_mode="tree,form" />
|
||||
res_model="coworking.event" view_mode="tree,form"
|
||||
context="{'search_default_status_confirmed': True, 'search_default_status_draft': True}" />
|
||||
<!-- Menu item to open Event list -->
|
||||
<menuitem id="event_menu" name="Event" action="event_action" />
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
<field name="title" />
|
||||
<field name="manager_id" />
|
||||
<field name="date_start" />
|
||||
<field name="starts_this_week" attrs="{'invisible': [('date_start', '=', True)]}" />
|
||||
<field name="date_end" />
|
||||
<field name="duration" />
|
||||
<field name="description" />
|
||||
@ -50,30 +51,30 @@
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="title" />
|
||||
<field name="manager" />
|
||||
<field name="manager_id" />
|
||||
|
||||
<filter name="Satut" string="confirmed"
|
||||
domain="[('statut','!=',False)]" />
|
||||
|
||||
<filter name="in_compagny" string="in_compagny"
|
||||
domain="[('company_name','!=',False)]" />
|
||||
<filter name="status_confirmed" string="Confirmed"
|
||||
domain="[('statut','=','confirmed')]" />
|
||||
<filter name="status_draft" string="Draft"
|
||||
domain="[('statut','=','draft')]" />
|
||||
<filter name="canceled" string="Canceled"
|
||||
domain="[('statut','=','canceled')]" />
|
||||
|
||||
<separator />
|
||||
<filter name="this_week" string="Starts this week"
|
||||
domain="[('starts_this_week','=', True)]" />
|
||||
|
||||
<filter name="is_savoyar" string="Is_savoyar"
|
||||
domain="[('contact_zip','=like','73___')]" />
|
||||
<filter name="this_30_month" string="Starts 30 month"
|
||||
domain="[('date_start','<=', datetime.datetime.combine(context_today() + datetime.timedelta(days=30), datetime.time(23,59,59))),
|
||||
('date_start','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]" />
|
||||
|
||||
<filter name="meet_of_2017" string="Meet_of_2017"
|
||||
domain="[('contact_date','like','2017')]" />
|
||||
<filter name="group_status" string="Group status"
|
||||
context="{'group_by': 'statut'}" />
|
||||
<filter name="group_manager_id" string="Group manager"
|
||||
context="{'group_by': 'manager_id'}" />
|
||||
<filter name="group_years_start" string="Group years start"
|
||||
context="{'group_by': 'date_start:years'}" />
|
||||
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user