Commit Graph
10 Commits
Author SHA1 Message Date
Arnaud Joset 24a36c6c8f [IMP] calendar: rename calendar.contacts model
Before this commit, the 'magic' model calendar.contacts name was misleading. This model is only used to save calendar view preferences in the calendar app.
As the calendar events are already mentionning attendees, partners, users, the 'contact' name for a technical field was confusing.

Taskid: 2484335
Part-of: odoo/odoo#68700
2021-08-26 10:20:59 +00:00
Damien Abeloos b0134452c0 [IMP] crm: add a reschedule action for activities
* Replace the "Snooze 7d" action for lead-related activities linked to
  a calendar event by a "Reschedule" action, which will redirect the user
  to the calendar view with the focus on the next event related to the
  opportunity
    - The "Snooze 7d" action only impacted the activity and not the meeting,
      and snoozing a meeting is not very logical anyway. The "Reschedule" fits
      better in this use case.

* It was discussed to show only a modal allowing to reschedule the next
  calendar event, but that could lead to inconsistent states (out of order
  sequence of scheduled events, if the first is rescheduled after the
  second).

* The reschedule option will be shown next to any activity related to a
  calendar_event regardless of its activity type. There are some edge cases
  that we may want to change in the future :
    - When changing the activity type of a 'meeting' activity associated to
      a calendar event to any other activity type, but without removing the
      calendar event, the reschedule action is still showing (since the event
      is still ongoing and was not deleted from the calendar).
    - Conversely, with a meeting which is not (yet?) related to a calendar event,
      the reschedule action will not be available.

* Add a new field to MailActivityMixin in the calendar module context. This
  field is the event linked to the next activity, if there is one such event.
  It is used to check whether the reschedule action should be available to the user.

* Add a test for this new field to validate the expected behavior.

* Add the priority widget to the priority field in the opportunity tree view

Task ID : 2410217
PR : https://github.com/odoo/odoo/pull/63370
2021-03-03 12:43:22 +00:00
Yannick Tivisse 3eec4d6a69 [FW][MERGE] resource,calendar,hr_holidays: Improve the performances
TL;DR
=====

Improve performances with nearly a factor of 2. Use case, call action_validate on hr.leave for 100 employees
- 1987 requests -> 844 requests
- 1300 ms -> 700 ms

Purpose
=======

The first purpose of this commit is to add a test ensuring the number of request while creating
a company leave for 100 employees, if 15 of them already have a leave during that period.

It includes, the mass leave generation, and the conflicts resolutions. (Cancelling/Splitting the
already existing one and adapting the dates accordingly).

The second one is to reduce the number of request for this test.

In term of requests, currently we have:
- 5154 requests without bypassing the mail tracking + the activities management
- 1987 requests when bypassing the mail post-process (this is the current value, the bypassing was
  already done several month ago)
- 844 requests with all the optimization done in resource/calendar/hr_holidays

In terms of execution time, we have a reduction from +- 1300 ms to call the method action_validate
to +- 700 ms

As the performances issues severity increases with the number of leaves to create and the real time access
to the database, on the production base, we reduced the execution time to generate more than 500 hr.leaves
from several minutes to 21 seconds. A fix to avoid deadlock was already made at
https://github.com/odoo/enterprise/pull/10740/files

Some contortions were made to avoid changing a signature method in a stable release and thus
introducing for each method a second one, with the "batched" implementation, to keep a retro-compatibility
for the existing custom code.

But surely this could be cleaned in the master version. The old one will be deprecated while waiting to be
removed in a few versions.

closes odoo/odoo#56534

Taskid: 2256705
X-original-commit: 8c96a887d3f05680c923dcd44f9c70c0e5e0bd32
Related: odoo/enterprise#12670
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-25 15:44:07 +00:00
Lucas Lefèvre a27afdb543 [REF] calendar: Materialize virtual recurring events
TL;DR A bit of magic and ... Pouf ... all virtual events are now real records.

Purpose
=======
The current implementation of recurring events uses "virtual events" to represents all
events in the recurrence. Only one event is stored in the database. All other events are
dynamically built and sent to the web client which sees them as real records.
This implementation is old, difficult to read (6 years of changes and bug fixes) and
has become more and more difficult to maintain.
A fresh start would be welcome.

Specification
=============
When creating a recurring event, a `calendar.recurrence.rule` record should be created.
This model holds the rrule configuration and is responsible to manage events that result
from the rrule.
When a new recurrence is created, all resulting events are also created (stored in the
database). No more virtual events.
To avoid an explosion of events, a maximum of 720 events is created. With 720 events,
a daily recurrence lasts for 2 years and a weekly recurrence lasts for 15 years.
This strategy is used by Google Calendar and seems acceptable in most cases.
A cron job could eventually be introduced to generated more events as the end comes.

This allows to introduce an new rrule end type: 'Forever'. This is actually a shortcut
to create a recurrence running for 720 events.

Inspired by Google Calendar, new possibilities are introduced when modifying a recurring
event (e.g. change the name, add an attendee):
- Modify only this particular event (the event is still part of the recurrence)
- Modify this and following events (events are still in the same recurrence)
- Modify all events

In a similar way, when updating the rrule of an event (e.g. from every Monday to every
Tuesday), the user can choose to:
- Modify this and following events: the recurrence is split. The first part remains
  unchanged but now ends when the second recurrence begins. The second parts is the
  updated rrule.
- Modify only this particular event.
- Modify all events: Forbidden (same as Google Calendar)

Note: when events are "moved" because the rrule changed, the events are not actually
moved. They are unlinked and new events are created (See "Some design choices explained"
section).

Some design choices explained
=============================

Where to store the rrule?
-------------------------
Two options were considered.
1) Store the rrule on an event, each event of the recurrence having a Many2one
to the parent_id, aka the Master Event of the recurrence.

2) Store the rrule on another model: `calendar.recurrence.rule`. Each event in the
recurrence having a Many2one to the recurrence record.

Both options have pros & cons. But there is no clear winner.
However the actual business logic of handling the recurrence creation/update
would be the same.
Where the rrule configuration is stored is the only main difference between both options.
And this is probably the easiest part of implementing recurring events.

With that in mind, option 2) is chosen. It allows to clearly separate recurrence
logic from the events themselves. It is also the "correct" way of modeling data to avoid
many empty columns for most records.

Reusing events on rrule update
------------------------------
When an rrule is modified, events should also be updated.
In most cases, current events are unlinked and new events are created from scratch.
Only events exactly at the same time before and after the rrule update are kept.
Trying to reuse other events would require an obscure and arbitrary heuristic.
(Imagine an rrule every Monday that is changed to every Tuesday and every Friday.
What would you do?).
This implies that any change to a specific event (name change, attendee added, chatter
messages) is lost. This tradeoff seems acceptable as updating an rrule should not be
that frequent. Moreover, Google Calendar also works that way so why not Odoo?

Reusing events on events shifts
-------------------------------
On the calendar view, drag and drop an event to shift the entire recurrence.

One way to handle the recurrence shift is to apply the same timedelta to all events.
Now events are correctly positioned... except for events that were specifically
moved. Those outliers needs special handling.
This also introduces some behavior inconsistencies:
when an rrule is directly modified, events are not reused, but when the rrule is
modified by drag & dropping an event, events are reused. This option needs more code to
handle the shift and the behaviors are not consistent.

The chosen option is to find the rrule configuration from the dragged event (this is
easy) and update the recurrence with those new rrule values. This brings us back to
an rrule update (see above): code reusability yeah; one behavior to rule them all yeah.
One downside is that outliers are lost (but Google Calendar also works that way).

Task 2126717
PR #42031
PR Enterprise odoo/enterprise#8006
2020-04-09 10:56:37 +02:00
Lucas Lefèvre 7799120074 [MOV] calendar: Split models in their own file
Apply Odoo guidelines[1].
Each model should be in a different file.

Task 2126717
PR #42031
PR Enterprise odoo/enterprise#8006

[1] https://www.odoo.com/documentation/13.0/reference/guidelines.html#file-naming
2020-04-09 10:53:46 +02:00
Barad Mahendra 4a59f93d15 [IMP] mail, calendar: add today meetings in systray
Purpose of this commit is to display today meetings in the systray. This will
help people in their daily job to have quickly access to their meetings.
It is displayed along with activities and reminders to have all current work
to do in the same place.

Displayed meetings are ongoing or not yet started ones of the current day.
All-day meetings of the current day are also shown. Done meetings are not
displayed to lessen noise.

Clicking on the systray will open the calendar view of meetings in a day
mode. This is done by a small modification in the calendar view allowing
to choose the display mode from context in addition to the mode attribute
of the action definition.

This commit is linked to task ID 60593. Closes #24438. Thanks to @ged-odoo
for quick reviewing.
2018-05-31 16:49:56 +02:00
Akash Bhavsar 9568b1525b [IMP] mail, calendar: integrate meeting activities with calendar
This commit improves the use of mail activities by allowing their
integration with the calendar. Activity types now have a category
field that can be used to trigger some specific behavior. First
specific behavior is to have activity types of meeting category.
Creating activities of this type trigger a jump to the calendar to
schedule the meeting. Meeting activities and calender events are
linked to be able to easily navigate through the document, its activities
and its meetings.

Configuration is done using a category on activity types instead of some
hardcoded "meeting" activity to avoid issues with master data and to be
able to choose which activity type should trigger this behavior.
2017-09-07 17:55:57 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Jérome Maes fe42986ee2 [MOV] calendar: split models in multiple files 2016-07-14 14:04:33 +02:00
Jérome Maes b535461e47 [MOV] calendar: reoganize module directory 2016-07-14 14:04:33 +02:00