[IMP] event: improve some view

Kanban view
===========
- add a field ``sales_total_price`` which contains the total sum of all sale order lines (care about the currency)
- this field is used in ``event_sale``
- display the number of expected and confirmed
- when clicking on these buttons, redirect to the tree view with the correct filter
- display this new field in the kanban view
- display the location instead of the country in the kanban view

Form view
=========
Change the order of the buttons in the header of the event form view
Preview Badge > Contact Attendee > Contact Speaker
Add a note field on the model `event.event`

Search
======
Remove the default filter "Upcoming/Running"

Task #2088538
This commit is contained in:
Debauche Stéphane
2020-01-08 09:11:50 +00:00
committed by Thibault Delavallée
parent 412ff994f1
commit f59a68983c
8 changed files with 114 additions and 51 deletions
+8
View File
@@ -7,6 +7,7 @@ from odoo import _, api, fields, models
from odoo.tools import format_datetime
from odoo.exceptions import AccessError, UserError, ValidationError
from odoo.tools.translate import html_translate
from odoo.tools.misc import _format_time_ago
from dateutil.relativedelta import relativedelta
@@ -102,6 +103,7 @@ class EventEvent(models.Model):
name = fields.Char(
string='Event', translate=True, required=True,
readonly=False)
note = fields.Text(string='Note')
active = fields.Boolean(default=True)
user_id = fields.Many2one(
'res.users', string='Responsible',
@@ -131,6 +133,7 @@ class EventEvent(models.Model):
legend_blocked = fields.Char(related='stage_id.legend_blocked', string='Kanban Blocked Explanation', readonly=True)
legend_done = fields.Char(related='stage_id.legend_done', string='Kanban Valid Explanation', readonly=True)
legend_normal = fields.Char(related='stage_id.legend_normal', string='Kanban Ongoing Explanation', readonly=True)
duration_str = fields.Char(compute='_compute_duration_str')
# Seats and computation
seats_max = fields.Integer(
string='Maximum Attendees Number',
@@ -269,6 +272,11 @@ class EventEvent(models.Model):
end_tz = fields.Datetime.context_timestamp(event, event.date_end)
event.is_one_day = (begin_tz.date() == end_tz.date())
@api.depends('date_begin', 'date_end')
def _compute_duration_str(self):
for event in self:
event.duration_str = _format_time_ago(self.env, event.date_end - event.date_begin, add_direction=False)
@api.onchange('is_online')
def _onchange_is_online(self):
if self.is_online:
+15 -10
View File
@@ -1,34 +1,39 @@
.o_kanban_view.o_event_kanban_view {
.o_kanban_record {
position: relative;
padding: 0;
display: flex;
.o_kanban_record_title {
font-size: 1.2em;
}
.o_event_left {
flex: 1 1 25%;
text-align: center;
color: white;
background-color: $o-brand-primary;
padding: 8px;
.o_day {
font-size: 26px;
}
}
.o_event_right {
flex: 1 1 75%;
padding: 8px;
margin-left: 8px;
}
width: 70%;
.o_event_stat {
padding: 0;
height: 35px;
width: 60%;
}
}
.o_event_float_right {
right: 8px;
top: 40px;
}
.o_event_bottom_right {
position: absolute;
width: 60px;
right: 8px;
bottom: 8px;
img {
width: 20px;
height: 20px;
+57 -34
View File
@@ -175,6 +175,13 @@
</field>
</record>
<record id="event_registration_action_tree" model="ir.actions.act_window">
<field name="name">Event registrations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">event.registration</field>
<field name="view_mode">tree,kanban,form,calendar,graph</field>
</record>
<!-- EVENT.EVENT VIEWS -->
<record id="event_event_action_pivot" model="ir.actions.act_window" >
<field name="name">Events Analysis</field>
@@ -251,6 +258,9 @@
<field name="seats_max" attrs="{'invisible': [('seats_availability', '=', 'unlimited')], 'required': [('seats_availability', '=', 'limited')]}"/>
</div>
</group>
<group class="w-100">
<field name="note" placeholder="Add a note..." nolabel="1"/>
</group>
</group>
<notebook>
<page string="Communication" name="event_communication">
@@ -297,14 +307,29 @@
</field>
</record>
<record id="event_event_view_form_quick_create" model="ir.ui.view">
<field name="name">event.event.form.quick_create</field>
<field name="model">event.event</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<form>
<group>
<field name="name"/>
<field name="date_begin"/>
<field name="date_end"/>
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_event_kanban">
<field name="name">event.event.kanban</field>
<field name="model">event.event</field>
<field name="arch" type="xml">
<kanban class="o_event_kanban_view" default_group_by="stage_id">
<kanban class="o_event_kanban_view" default_group_by="stage_id" quick_create_view="event.event_event_view_form_quick_create">
<field name="user_id"/>
<field name="stage_id" options='{"group_by_tooltip": {"description": "Description"}}'/>
<field name="country_id"/>
<field name="address_id"/>
<field name="date_begin"/>
<field name="date_end"/>
<field name="seats_unconfirmed"/>
@@ -315,22 +340,13 @@
<field name="legend_blocked"/>
<field name="legend_normal"/>
<field name="legend_done"/>
<field name="duration_str"/>
<field name="activity_ids"/>
<field name="activity_state"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="{{!selection_mode ? 'oe_kanban_color_' + kanban_getcolor(record.color.raw_value) : ''}} oe_kanban_card oe_kanban_global_click">
<div class="o_dropdown_kanban dropdown">
<a class="dropdown-toggle o-no-caret btn" role="button" data-toggle="dropdown" data-display="static" href="#" aria-label="Dropdown menu" title="Dropdown menu">
<span class="fa fa-ellipsis-v"/>
</a>
<div class="dropdown-menu" role="menu">
<t t-if="widget.deletable">
<a role="menuitem" type="delete" class="dropdown-item">Delete</a>
</t>
<ul class="oe_kanban_colorpicker" data-field="color" role="menu"/>
</div>
</div>
<div class="o_event_left">
<div class="o_event_left text-center">
<div class="o_day"><t t-esc="record.date_begin.raw_value.getDate()"/></div>
<div>
<t t-esc="moment(record.date_begin.raw_value).format('MMM')"/>
@@ -338,26 +354,35 @@
</div>
<div><t t-esc="moment(record.date_begin.raw_value).format('LT')"/></div>
</div>
<div class="o_event_right">
<h4 class="o_kanban_record_title"><field name="name"/></h4>
<div class="o_event_right d-flex flex-column justify-content-between">
<div>
<t t-if="record.country_id.raw_value"> <b class="o_kanban_record_subtitle"> <field name="country_id"/> </b> <br/> </t>
<b><i class="fa fa-clock-o"/>
To</b> <t t-esc="moment(record.date_end.raw_value).format('lll')"/>
<h1 class="o_kanban_record_title"><field name="name"/></h1>
<p t-esc="record.address_id.value"/>
</div>
<div class="o_event_duration_str">Duration <field name="duration_str"/></div>
<div class="o_event_stat text-left d-flex justify-content-between">
<div class="text-left inline-block mr-2">
<button
type="action"
class="btn btn-link p-0"
name="%(event_registration_action_tree)d"
t-esc="record.seats_expected.raw_value"/>
<p>Expected</p>
</div>
<div class="text-left inline-block">
<button
type="action"
class="btn btn-link my-0 p-0"
name="%(event_registration_action_tree)d"
context="{'search_default_confirmed': True}"
t-esc="record.seats_reserved.raw_value"/>
<p>Confirmed</p>
</div>
</div>
<h4>
<a name="%(act_event_registration_from_event)d" type="action">
<t t-esc="record.seats_expected.raw_value"/> Expected attendees
</a>
<t t-if="(record.seats_reserved.raw_value + record.seats_used.raw_value) > 0 "><br/>
<a name="%(event_event_action_pivot)d" type="action">
<t t-esc="record.seats_reserved.raw_value + record.seats_used.raw_value"/> Confirmed attendees
</a>
</t>
</h4>
</div>
<div class="o_event_bottom_right">
<field name="kanban_state" widget="state_selection" groups="base.group_user"/>
<div class="o_event_bottom_right d-flex justify-content-between align-items-center position-absolute">
<field name="activity_ids" widget="kanban_activity"/>
<field name="kanban_state" widget="state_selection"/>
<img t-att-src="kanban_image('res.users', 'image_128', record.user_id.raw_value)" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/>
</div>
</div>
@@ -436,7 +461,6 @@
<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="context">{"search_default_upcoming":1}</field>
<field name="search_view_id" ref="view_event_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
@@ -706,6 +730,5 @@
</record>
<menuitem name="Mail Schedulers" id="menu_event_mail_schedulers" action="action_event_mail" parent="menu_event_configuration" groups="base.group_no_one"/>
</data>
</odoo>
+15 -3
View File
@@ -47,7 +47,7 @@ class Event(models.Model):
'sale.order.line', 'event_id',
string='All sale order lines pointing to this event')
sales_total_price = fields.Monetary(compute='_compute_sales_total_price')
sale_total_price = fields.Monetary(compute='_compute_sale_total_price')
currency_id = fields.Many2one(
'res.currency', string='Currency',
default=lambda self: self.env.company.currency_id.id, readonly=True)
@@ -73,9 +73,9 @@ class Event(models.Model):
event.start_sale_date = min(start_dates) if start_dates else False
@api.depends('sale_order_lines_ids')
def _compute_sales_total_price(self):
def _compute_sale_total_price(self):
for event in self:
event.sales_total_price = sum([
event.sale_total_price = sum([
event.currency_id._convert(
sale_order_line_id.price_reduce_taxexcl,
sale_order_line_id.currency_id,
@@ -90,6 +90,18 @@ class Event(models.Model):
non_open_events.event_registrations_open = False
super(Event, self - non_open_events)._compute_event_registrations_open()
@api.depends('sale_order_lines_ids')
def _compute_sale_total_price(self):
for event in self:
event.sale_total_price = sum([
event.currency_id._convert(
sale_order_line_id.price_reduce_taxexcl,
sale_order_line_id.currency_id,
sale_order_line_id.company_id,
sale_order_line_id.order_id.date_order)
for sale_order_line_id in event.sale_order_lines_ids
])
class EventTicket(models.Model):
_name = 'event.event.ticket'
+12
View File
@@ -145,6 +145,18 @@
</field>
</record>
<record id="event_view_kanban" model="ir.ui.view">
<field name="name">event.kanban.inherit</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_kanban"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('o_event_duration_str')]" position="after">
<field name="currency_id" invisible="1"/>
<div attrs="{'invisible': [('sale_total_price', '&lt;=', 0)]}">Sales <field name="sale_total_price" widget="monetary"/></div>
</xpath>
</field>
</record>
<record id="event_ticket_form_view" model="ir.ui.view">
<field name="name">event.event.ticket.form</field>
<field name="model">event.event.ticket</field>
@@ -3,9 +3,10 @@
<record id="event_event_view_form_inherit_mass_mailing" model="ir.ui.view">
<field name="name">event.event.view.form.inherit.mass.mailing</field>
<field name="model">event.event</field>
<field name="priority" eval="15"/>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<xpath expr="//field[@name='stage_id']" position="before">
<button name="action_mass_mailing_attendees" string="Contact Attendees" type="object" attrs="{'invisible': [('seats_expected', '=', 0)]}"/>
</xpath>
</field>
@@ -3,9 +3,10 @@
<record id="event_event_view_form_inherit_mass_mailing_track" model="ir.ui.view">
<field name="name">event.event.view.form.inherit.mass.mailing.track</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="website_event_track.view_event_form"/>
<field name="priority" eval="25"/>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<xpath expr="//field[@name='stage_id']" position="before">
<button name="action_mass_mailing_track_speakers" string="Contact Track Speakers" type="object" attrs="{'invisible': [('track_count', '=', 0)]}"/>
</xpath>
</field>
+2 -1
View File
@@ -28,6 +28,7 @@
<record id="event_event_view_form_inherit_website" model="ir.ui.view">
<field name="name">event.event.view.form.inherit.website</field>
<field name="model">event.event</field>
<field name="priority" eval="5"/>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<field name="organizer_id" position="before">
@@ -41,7 +42,7 @@
<field name="website_menu"/>
<label for="website_menu" string="Website Menu"/>
</label>
<xpath expr="//header" position="inside">
<xpath expr="//field[@name='stage_id']" position="before">
<button name="action_open_badge_editor"
type="object"
string="Preview Badges"/>