[IMP] event: adds graph view and adds change for event_barcode
PURPOSE - In order to get an overview over events, add a graph view grouped by event name and measure by seats available. - Before this commit you had to install event_sale to see the popup window in the barcode interface when scanning an attendee. With this commit you'll see the popup even when event_sale is not installed. SPECIFICATION - Add the minimal information about the registration in the event module and overrides it in the event_sale module to add the necessary informations. That makes the window popup appear everytime when scanning an attendee. - Add a "is_ongoing" field on event model to use it as a filter in event_barcode. LINKS Task ID : 2093336 PR : #43420 Enterprise PR : odoo/enterprise#7760
This commit is contained in:
@@ -170,12 +170,13 @@ class EventEvent(models.Model):
|
||||
date_end = fields.Datetime(string='End Date', required=True, tracking=True)
|
||||
date_begin_located = fields.Char(string='Start Date Located', compute='_compute_date_begin_tz')
|
||||
date_end_located = fields.Char(string='End Date Located', compute='_compute_date_end_tz')
|
||||
is_ongoing = fields.Boolean('Is Ongoing', compute='_compute_is_ongoing', search='_search_is_ongoing')
|
||||
is_one_day = fields.Boolean(compute='_compute_field_is_one_day')
|
||||
start_sale_date = fields.Date('Start sale date', compute='_compute_start_sale_date')
|
||||
# Location and communication
|
||||
is_online = fields.Boolean('Online Event')
|
||||
address_id = fields.Many2one(
|
||||
'res.partner', string='Location', tracking=True,
|
||||
'res.partner', string='Venue', tracking=True,
|
||||
default=lambda self: self.env.company.partner_id,
|
||||
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
|
||||
country_id = fields.Many2one('res.country', 'Country', related='address_id.country_id', store=True, readonly=False)
|
||||
@@ -251,6 +252,25 @@ class EventEvent(models.Model):
|
||||
else:
|
||||
event.date_end_located = False
|
||||
|
||||
@api.depends('date_begin', 'date_end')
|
||||
def _compute_is_ongoing(self):
|
||||
now = fields.Datetime.now()
|
||||
for event in self:
|
||||
event.is_ongoing = event.date_begin <= now < event.date_end
|
||||
|
||||
def _search_is_ongoing(self, operator, value):
|
||||
if operator not in ['=', '!=']:
|
||||
raise ValueError(_('This operator is not supported'))
|
||||
if not isinstance(value, bool):
|
||||
raise ValueError(_('Value should be True or False (not %s)'), value)
|
||||
now = fields.Datetime.now()
|
||||
if (operator == '=' and value) or (operator == '!=' and not value):
|
||||
domain = [('date_begin', '<=', now), ('date_end', '>', now)]
|
||||
else:
|
||||
domain = ['|', ('date_begin', '>', now), ('date_end', '<=', now)]
|
||||
event_ids = self.env['event.event']._search(domain)
|
||||
return [('id', 'in', event_ids)]
|
||||
|
||||
@api.depends('date_begin', 'date_end', 'date_tz')
|
||||
def _compute_field_is_one_day(self):
|
||||
for event in self:
|
||||
|
||||
@@ -249,6 +249,12 @@ class EventRegistration(models.Model):
|
||||
else:
|
||||
return _('on ') + format_datetime(self.env, self.event_begin_date, tz=self.event_id.date_tz, dt_format='medium')
|
||||
|
||||
def summary(self):
|
||||
def _get_registration_summary(self):
|
||||
self.ensure_one()
|
||||
return {'information': []}
|
||||
return {
|
||||
'id': self.id,
|
||||
'partner_id': self.partner_id.id,
|
||||
'ticket_name': self.event_ticket_id.name or _('None'),
|
||||
'name': self.name,
|
||||
'event_name': self.event_id.name,
|
||||
}
|
||||
|
||||
@@ -485,11 +485,22 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="event_event_view_graph" model="ir.ui.view" >
|
||||
<field name="name">event.event.view.graph</field>
|
||||
<field name="model">event.event</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Events">
|
||||
<field name="name" type="row"/>
|
||||
<field name="seats_available" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_event_view">
|
||||
<field name="name">Events</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">event.event</field>
|
||||
<field name="view_mode">kanban,calendar,tree,form,pivot</field>
|
||||
<field name="view_mode">kanban,calendar,tree,form,pivot,graph</field>
|
||||
<field name="search_view_id" ref="view_event_search"/>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
@@ -658,6 +669,8 @@
|
||||
<search string="Event Registration">
|
||||
<field name="id" string="Registration ID"/>
|
||||
<field name="name" string="Participant" filter_domain="['|', '|', ('name', 'ilike', self), ('email', 'ilike', self), ('origin', 'ilike', self)]"/>
|
||||
<filter string="Ongoing Events" name="filter_is_ongoing" domain="[('event_id.is_ongoing', '=', True)]"/>
|
||||
<separator/>
|
||||
<filter string="Unread Messages" name="message_needaction" domain="[('message_needaction','=',True)]"/>
|
||||
<filter string="Expected" name="expected" domain="[('state', 'in', ['draft', 'open', 'done'])]"/>
|
||||
<separator/>
|
||||
|
||||
@@ -60,21 +60,20 @@ class EventRegistration(models.Model):
|
||||
}
|
||||
return {}
|
||||
|
||||
def summary(self):
|
||||
res = super(EventRegistration, self).summary()
|
||||
if self.event_ticket_id.product_id.image_128:
|
||||
res['image'] = '/web/image/product.product/%s/image_128' % self.event_ticket_id.product_id.id
|
||||
information = res.setdefault('information', {})
|
||||
information.append((_('Name'), self.name))
|
||||
information.append((_('Ticket'), self.event_ticket_id.name or _('None')))
|
||||
def _get_registration_summary(self):
|
||||
res = super(EventRegistration, self)._get_registration_summary()
|
||||
order = self.sale_order_id.sudo()
|
||||
order_line = self.sale_order_line_id.sudo()
|
||||
has_to_pay = False
|
||||
if not order or float_is_zero(order_line.price_total, precision_digits=order.currency_id.rounding):
|
||||
payment_status = _('Free')
|
||||
elif not order.invoice_ids or any(invoice.payment_state != 'paid' for invoice in order.invoice_ids):
|
||||
payment_status = _('To pay')
|
||||
res['alert'] = _('The registration must be paid')
|
||||
has_to_pay = True
|
||||
else:
|
||||
payment_status = _('Paid')
|
||||
information.append((_('Payment'), payment_status))
|
||||
res.update({
|
||||
'payment_status': payment_status,
|
||||
'has_to_pay': has_to_pay
|
||||
})
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user