The previous commit introduced an optimization to reduce the number of
queries and fields fetched when we call `name_search`. But it works much
better when the dependencies of `display_name` contain field names used
in the calculation (on the same record/model).
Then, to improve the performance and the cache coherency, add `depends`
and `depends_context` depending on the custom `_compute_display_name`.
Add only the first level of dependencies (never traverse relational
field) because only these have a positive impact on the previous
optimization and the cost is very low (see `modified`).
About `depends_context`, we don't include `lang` because (when `_` is
used by example) it is unlikely to get the same display_name in the same
request with two different lang.
closesodoo/odoo#122085
Related: odoo/documentation#4639
Related: odoo/enterprise#42599
Related: odoo/upgrade#4780
Signed-off-by: Raphael Collet <rco@odoo.com>
Rationale
=========
Since v8, the `display_name` field is present on all models. By default,
`display_name` uses `name_get` which has pretty much the same purpose
(return record name used by the web client). Gradually, many (backend)
developers (and the ORM: https://github.com/odoo/odoo/commit/6da1c3ac4c036eac289597602976538e243cb939)
started using `display_name` (more convenient than
`record.name_get()[0][1]`) but it still had the `name_get` override.
It becomes more complex than necessary and poeple start to misunderstand
the two (and sometimes override both, leading to inconstiencies between
`display_name`/`name_get`).
To simplify the ORM and the API, we decided to keep only one of them,
the `display_name` field:
- It is much more convenient from a backend point of view
(`record.name_get()[0][1]` vs `record.display_name`)
- It is cached during the same transaction (and invalidated if
its dependencies change)
- It can be overridden like any other compute field (override
`_compute_display_name` with any extra dependencies)
- `name_get` is replaced by `read(['display_name'])`
(API perceptive), which can actually be more efficient
(if `display_name`'s depends are correct, the ORM will only fetch the
fields it needs instead of every prefetchable field)
Changes
=======
- Deprecates `name_get` for the v17 and based the method on
`display_name` (the opposite of before)
- Converts all usage of `name_get`
- Overrides of `name_get` are now overrides of `_compute_display_name`
- For `res.partner`, rename the field store `display_name` into
`complete_name` because `display_name` context-dependent and it makes
no sense to have a compute store that is context-dependent.
- Previously, it was possible to return multiple names for the same
record with `name_get`, but it was tricky and most of the usage of
this `name_get` didn't take this into account. The only example of
this is the `name_get` of `product.product`
(now use `", ".join(<names>)`).
Part-of: odoo/odoo#122085
When the price and the event are the same, nothing allows
ordering tickets in event_sale. Therefore, add a sequence
number and handle widget to the tickets (in data as well).
Also do it for ticket templates. Also, order the tickets
(on events and templates) by name before id.
Since event type tickets are not linked to any event, the
order does not include the event_id. However, event event
tickets are, and if they appear in the same list / reporting
someday, it makes sense to order them by event_id first.
In event_sale, we make sure the price is also in the order.
As the price is in the copied fields on the event when
using an event template, we add the price on the event
type tickets ordering to align with the event event tickets.
Add default value to sequence and sequence number to data
for event.type model. They were sequenced but demo data had
none, hence not really ordered.
We also add the id in the event.event _order value, otherwise
when ordering on the event (for instance ordering on event_id
for event.event.tickets), the order is random for events
having the same date_begin. We prevent this from happening.
Also make description optional hide on event types.
Task-2997391
closesodoo/odoo#101384
Signed-off-by: David Beguin (dbe) <dbe@odoo.com>
With stored computed seat attributes, the database can be flooded with update
queries for the stored values for the event (ticket) seats computations (such
as reserved, expected, and available seats).
This can especially occur when a communication is sent to many people about
an event with a registration link, many users may want to register at the same
time, possibly resulting in concurrent_update errors.
In this commit, we remove the `store=True` attribute of those fields, and
therefore remove the Reporting/Event feature depending on them and rewrite some
domain searches and _compute fields in the event and event_sale modules.
This also impacts the way constraints are enforced on the number of
registrations vs defined maximum as no stored value is directly available.
For performance reasons, all events and tickets are now shown on backend form
views, with seat availability added in their displayed name.
Misc
To avoid delaying the inevitable, the Event configurator modal/wizard now
validates event/ticket consistency at closing.
The UI of the RegistrationEditor wizard is also improved:
* A warning alert will tell users that free registrations were not confirmed
because of insufficient seat availability.
* A first step to better explain the consequences of the actions taken on the
modal was to be taken, here via the description and buttons wording.
Tests
Query counts are (indeed reduced) and updated. However, as local testing with
`test-tags=/test_event_full` ("tef_only") is currently not reliable, these
values were updated by applying the same change from the commit as the one seen
for the runbots, while a "?" is appended to show this uncertainty.
Task-2654816
See odoo/upgrade#3118
Part-of: odoo/odoo#81583
When an attendee's registration was archived, their seat was still
considered taken, which could be problematic such as in cases of
limited seat availability.
Only non-archived registrations are now counted as seats. The same
error as with regular registrations will be raised if there are not
enough seats available to un-archive a registration. These ValidationError
messages now show the name of the fully booked event.
A few python tests are included to verify the impact of (un)archiving on
seats availability for events and for event tickets.
The appearence of archived registrations was also not different in form
and kanban views, which is somewhat confusing and inconsistent with the
aspect of archived records in Odoo. Actions buttons are not available on
archived records.
Filtering in the archived records needed to be simplified from a "Custom
Filter" to a one-click feature, already available for many models.
Task-2646298
closesodoo/odoo#77715
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Purpose
=======
Give the user a better experience when handling events by removing
useless views and using coherent names of fields.
Specifications
==============
Add placeholders in multiple fields, change names in event_event module
to be more consistent with each other, remove and add filters/measures
in events and tracks.
Task-2646692
closesodoo/odoo#77389
Related: odoo/enterprise#21294
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Issue: Sometimes, when changing the Maximum (seats_max) on one of
the tickets of an event, it triggered a recompute for the other tickets
Steps to reproduce :
Install Events
Settings > Event > Enable "Tickets"
Create an event template (or use Sell Online default one) with
Check "Ticketing" and set the line price to 0
Create an event :
with that template
and Autoconfirm checked
Add a line for the Tickets:
name: VIP
price: 10
Save the event
Create two attendees for the event, one for each
Event Ticket (event_ticket_id) and confirm them (on the form, not
Confirm Attendee)
Change the Maximum (seats_max) of one ticket and save
-> the Confirmed (seats_reserved) will be recomputed but the
confirmed for the other ticket will increase as well
Side-Note:
I haven't been able to find a deterministic way to reproduce the bug
but it seems that the bug appear the most when doing all the steps at
once, and trying to not log out or refresh the page.
Also it works best on a runbot or at least with runbot data.
Without my modification, the new test passes on my local odoo server,
but fails on a dump of a runbot on my computer, adding my modification
makes it work on either case
Why is that a bug:
The recomputation seems to fail for some reason, we are setting all
the event/ticket in self to 0, but only update the value of those by
fetching a SQL query so there might be a desync there
opw-2642555
closes odoo/odoo#78023
Forward-port-of: #76492
X-original-commit: f4c936c9dc141de27a77006fb87dd2b63d88ec97
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Nathan Marotte <nmarotte@users.noreply.github.com>
changed the start/end date fields to datetime fields, in order to allow more
flexibility for the user and enable them to set a precise point in time at
which ticket sales should start/end, because otherwise ticket sales/end would
always be set at midnight which is not very flexible.
Task-2431440
closesodoo/odoo#65133
Related: odoo/upgrade#2126
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Improve various event views, notably:
- Display ticket description on frontend even if there is only a single ticket
- Do not display search count on frontend agenda page when there is nothing
searched
- When performing a search, only check the text content of the track HTML
elements and not the entire HTML content, otherwise it would lead to incorrect search
results
In addition, we now also display an human readable error message when the user
tries to delete tickets that are linked to registrations.
This will help identifying the problematic tickets and remove the associated
registrations if necessary.
Task-2427778
closesodoo/odoo#64187
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit fixes the ticket sale start date to be considered inclusive.
Indeed, before this commit, if the sales of a ticket starts on the 1st of
December, people arriving on the website at that exact date will NOT be able to
buy tickets although they should be. They will have to wait for the next day to
be able to buy tickets.
A small test was added to ensure this behavior.
Task 2415917
closesodoo/odoo#63685
X-original-commit: ea6952fd7ec881b79a7294c40427ce9966997e66
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))
Old syntax is still compatible but starts the migration to the new
syntax that catches error.
One condition among other to determine if SOLD OUT should be displayed for a
ticket is start_sale_date < current date. However is start_sale_date is not
set a traceback is raised.
Moreover timezones are not taken into account when comparing dates, which may
create issues.
A tool method 'is_launched' has been added to overcome this problem. It works
like the already existing field 'is_expired'. Its value is computed based on
start_sale_date and event_id.date_tz. This will be changed into a not stored
computed field in master.
Task ID 2244487
PR #51503
X-original-commit: 9f81e126cdb1ce79ef26077a708cad8a7614031f
Rumors were heard of is_ongoing not working well. First try with playing
with timezones.
Task ID 2228189
Community PR odoo/odoo#48652
X-original-commit: d54faa336da29ff3167edb2331edd3e2508bc64f
PURPOSE
Change seats_availability selection field into a boolean field
and rename it to seats_limited for consistency.
SPECIFICATION
Change all the tests accordingly.
Task ID : 2198660
PR : #46659
Before this commit, _compute_sale_available would only take into account
the dates to set the field sale_available.
This commit makes it take into account the number of available seats
for the ticket as it is wrong to consider a sold out ticket as
being available for sale.
LINKS:
TaskID:2162438
PR: #43856
Indeed this field is notably based on tickets availability. Reading tickets
products is not necessarily granted to everyone. People reading events should
be able to know if the sale is available or not independently of their access
on product model. Let us therefore use a compute sudo.
Task 2188857
PR #44545
X-original-commit: cfabf12ef888a9dac48cbb19763740e2c65225d5
PURPOSE
This commit is part of ticket model support directly in event application.
SPECIFICATIONS 1: remove date fields from event.type.ticket
Coming from old ticket implementation there are several unused fields on
event.type.ticket, notably dates about selling. Indeed tickets defined on
event.type are templates and should not be time bound.
Previously those fields were available on event.type tickets but not propagated
to the event tickets. Now they are not available anymore, simplifying models.
We therefore remove them from event.type.ticket model.
SPECIFICATIONS 2: propagate seats definition from ticket template to tickets
Previously to the global feature this commit is a member of, only ticket name,
product and price were copied from event.type to its events. Description has
been added in a previous commit. In this commit we also propagate maximum
seats availability.
Use case is linked to event.type defining a recurring event in a given
location. As seats availability is known it can be copied on all events
linked to this event type.
SPECIFICATIONS 3: improve naming of event tickets
Before this commit, all tickets of an event were labeled the same way
by default, using simply ``<event_name>``. This is annoying when
having several tickets as they had all the same name.
In this commit we fix that behavior by setting the name
* directly from the ticket template when tickets come from an event.type.
Configuring Standard and VIP tickets on an event type will therefore
give Standard and VIP tickets on event;
* generic 'Registration for <event_name>' when adding manually a new ticket
for an event;
LINKS
Task ID 2177281
Community PR #43488
PURPOSE
This commit is part of ticket model support directly in event application.
SPECIFICATIONS
In this commit we add a description on event.type.ticket and event.event.type
models. Its purpose is to have a description to use notably in frontend
(website_event and website_event_sale).
Currently a ticket description is available only in website_event_sale and is
the description_sale field of the ticket product. As we now have tickets
independent from products, we introduce a real description field on ticket
that is either put by hand (event), either coming from the product with
event_sale.
Field is therefore also copied from event type tickets configuration to its
event tickets.
Naming on sale order does not take into account ticket description as we
consider this fields as being used for front-end mainly. SO line descripiton
is now updated as the following
* either we have a description_sale on the product, and SO line description
is 'product.description_sale \n event.display_name';
* either not and SO line description is 'ticket.name \n event.display_name';
LINKS
Task ID 2177281
Community PR #43488
PURPOSE
Integration between event and eCommerce is required only when users handle the
entire selling process online. However users may require ticketing support
while managing payments outside of Odoo. Purpose of this commit is to support
tickets directly in event application without need of sales.
RATIONALE
Remove the need to have event_sale installed to manage basic multi ticket
event type. Integration with eCommerce is needed only when one wants to handle
the entire selling flow online, i.e. order, payment, ... Integration with
Sales is needed only when one wants to create sale orders linked to attendees.
Many event users do not need all of this. Their attendees pay through bank
transfers or they simply manage payments outside of Odoo while still
requiring tickets management.
SPECIFICATIONS
Remove the need to have event_sale installed to manage basic ticketing on
events.
Move ticket model (event.event.ticket) directly into event, copying most
fields from event_sale. Only sale specific fields and behavior should be kept
in event_sale :
* keep product_id and price information in event_sale;
* keep sales analysis in event_sale;
We also split tickets model used for event type (event.type.ticket) and
events (event.event.ticket). Indeed previously to this commit both are
modeled in the same table, with the following issues :
* tickets on templates use only a subset of fields: name, seats availability,
product, price;
* a ticket has either an event_id, either an event_type_id, and there are
constraints to try to avoid having lost tickets. This leads to a strange
model where m2o fields are required only in some cases with a dual
behavior;
* tickets are not shared between event.type and event.event. They are copied
and having a single model is therefore not necessary;
We therefore choose to have a light model for event.type.ticket. It is linked
to event.type when configuring template tickets. They are copied in the
onchange copying event template configuration to the event itself, leading
to event.event.ticket creation.
Some tests are moved / completed accordingly.
Access rights are copied from website_event_sale to website_even concerning
ticket access for public / portal. Currently they are kept as they are with
some rewording as it is not the purpose of this commit to rewrite them.
LINKS
Task ID 2177281
Community PR odoo/odoo#43488