Commit Graph
64 Commits
Author SHA1 Message Date
dht-odoo dbf1ab157d [IMP] calendar: improves field type from text to html
Replace text fields to html fields as we have our own 'OdooEditor'.
Indeed, it gives more options to users in the way they format their
content without weighting too much on the UI
(tools appear on demand and not by default).

Adding a new method convert_online_event_desc_to_text
Because online events have fixed format for the description,
this method removes some specific html tags, and converts it into
readable plaintext (to be used in external calendars).

Models -> Fields

1) calendar.event -> description

Task Id: 2499504

X-original-commit: 0d5ca6a6fe8821b4ec19dd603bde116518721792
2021-06-07 05:24:08 +00:00
Arnaud Joset 5c4ac1d016 [FIX] calendar: solve undeterministic bug on event acceptance
Before this fix, the runbot would fails randomly during the nightly multi-build in test_accept_meeting_unauthenticated and test_accept_meeting_authenticated.

```py
odoo.addons.calendar.tests.test_calendar_controller:36

FAIL: TestCalendarController.test_accept_meeting_unauthenticated
Traceback (most recent call last):
  File "/data/build/odoo/addons/calendar/tests/test_calendar_controller.py", line 36, in test_accept_meeting_unauthenticated
    self.assertEqual(self.event.attendee_ids[1].state, "accepted", "Attendee should have accepted")
AssertionError: 'needsAction' != 'accepted'
- needsAction
+ accepted
 : Attendee should have accepted

```

There was a hard coded index of a record in a many2one field and sometimes, the record order changed. The asserted value was not the one expected and therefore, the test failed.

closes odoo/odoo#69263

Taskid: 2497816
X-original-commit: 4632ee9a02e366dcb7da6b46f23a3cd367412ccb
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-04-14 15:16:31 +00:00
Jérémy Hennecart ac13964244 [IMP] calendar: improve the way calendar event are displayed
With this commit we try to improve the way the events are displayed
to the user. Now, an event is displayed for each attendee of the event
that are selected in the filter. These events are displayed correctly
based on the status of the attendee in the event.
The colors displayed for the events now represent the attendees and not the
organizer.

If an attendee edit an event, it is edited for all others attendees.
Also, when an attendee that is not the organizer try to delete the event,
then the event is now declined in place of being deleted. If the organizer
delete the event, it is deleted for all attendees.

In case of an event where all attendees have declined it but the organizer,
the organizer see now a danger icon before the name of the event and it's
outlined and not filled with color, no matter of the actual status of the
organizer in the event.

task-2196775
COM PR: odoo/odoo#55190
ENT PR: odoo/enterprise#12196
UPG PR: odoo/upgrade#1532
2021-04-15 16:07:12 +00:00
YOGRAJ TANDELandMohammed Shekha 7fb9c81296 [IMP] calendar,lunch: change field names
with this commit we changes field names for week days like su, mo, tu etc. to
sun, mon, tue and so on in calendar module, this is going to be used in
task 2317795 where we developed recurrency module for recurrency mixin.

Also with this commit we change field names of weekdays in lunch module to have
same name as we have in calendar and project module so that we can easily use
custom widget "web_weekly_recurrence" instead of defining boolean field in xml
for each day.

task-2335399

Co-authored-by: Mohammed Shekha <msh@odoo.com>
2021-03-26 12:25:44 +00:00
Julien CastiauxandRaphaël Collet 9a8cf18ddb [IMP] core: New 'capture_trigger' test helper
When testing cron triggers, it is common to get the newly created
triggers in order to validate they exist and are scheduled are the right
moment.

This new helper is a context manager that capture all triggers or
triggers created for a specific cron. The created triggers are
accessible via the context's object `records` attribute.

The various tests have been updated so they use that new helper.

closes odoo/odoo#68163

Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Co-authored-by: Raphaël Collet <rco@odoo.com>
2021-03-24 09:29:38 +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
Thibault Francois 888d1f300c [FIX] calendar: Fix access right issue on env.companies
Context
-------

in the module website_calendar, the controller create
an event with alarm with the Public user and the company of the public
user
and set partner_ids that may belong to a different company

Issue
-----
The company of the user that create the event remains in the context
and _notify_next_alarm check for each user which event should be notify
using with user of the partner that may be notified and check the access
rules to filter the event the partner should actually see.

The check of the acces rules need env.companies that remains the company
of the user that create the event which the current user may not see
which trigger the following error.

"Access to unauthorized or invalid companies."

Solution
--------
Wipe the company in the context when calling get_next_notif

closes odoo/odoo#66999

X-original-commit: 7fe9012301f606e153ad2ad04c392aa193c182f3
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-03-01 12:05:16 +00:00
Nasreddin (bon)andLucasLefevre 81946543a7 [FIX] calendar: Add start week day to weekly recurrence rrule generator + unit test
Issue

	- Install 'Calendar' module
	- Create new event from Calendar view
	- Edit event
	- Set True to 'Recurrent' in options tab
	- Repeat every 2 weeks
	- Until : Number of repetitions 2
	- Save and go back to calendar view

	- Events are shifted (+ 1 week)

Cause

	The rrule.rrule (who create the generator with the recurrence ranges dates) use
	by default `calendar.firstweekday()` as first week day ('wkst').

Solution

	If recurrence frequency is 'weekly', get first week day based on user language,
	and add it as param ('wkst') to the rrule.rrule.

https://dateutil.readthedocs.io/en/stable/rrule.html#classes

opw-2448325

closes odoo/odoo#66311

X-original-commit: 5e85ee521edb70d4d2c7cdbf59c29794a8cd98b9
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
Co-authored-by: LucasLefevre (lul) <lul@odoo.com>
2021-02-16 19:11:04 +00:00
Julien Castiaux d960da8e54 [FIX] base: remove trigger coalescing
You have have a scheduled activity precisely at 8:12:34 AM (send an
email, anything). You trigger the cron using that precise moment. The
cron runs at 8:12:00 AM which is before the scheduled moment so the
activity is skipped. Imagine there is no other scheduled activity that
coudld trigger the cron, it is only run at worst 23h59 minutes later
thanks to the daily cron execution fallback.

The assumption of a29bb54 is wrong, it groups the moments the
cron should be triggered by grouping the moments on the rounded down
minute. This is not consistent with the trigger API that promises the
cron will run *as soon as possible but **not before*** the scheduled
moment.

closes odoo/odoo#65555

Task: 2452697
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-02-05 13:44:55 +00:00
Julien Castiaux a29bb54633 [IMP] ir.cron: trigger on multiple moments
Often the business want to trigger the cron several time at different
moments.  The typical use case is the business holds a recordset and
needs to trigger the cron for every record.  The current solution is to
loop on each record to call `_trigger` times.

We now allow to invoke `_trigger` with an iterable of `datetime`
objects, and isolate the implementation in method `_trigger_list`.

We also removed the `delay` argument as it was not used.

closes odoo/odoo#65459

Task: 2452697
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-02-04 08:55:23 +00:00
Julien Castiaux 193fee519c [FIX] calendar: missing cron compat fom sms_calendar
Fine tunning of c8f031ad77, this commit has the missing code
compatibility for sms_calendar.

closes odoo/odoo#65064

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-01-29 15:38:24 +00:00
Julien Castiaux c8f031ad77 [IMP] calendar: schedule reminders using triggers
The calendar reminders are emails or web notifications sent moments
before an event start. The mechanism to send web notifications is
controlled by the browser, it fetches all the future notifications and
uses `setTimeout()` to delay them. The mechanism to send emails was
controlled by a cron, every 30 minutes the cron would look for the
coming events and send the mail reminder.

The cron was running every 30 minutes even if there was no event. The
best precision was 30 minutes.

The new mechanism use cron triggers, every time one add email reminders,
triggers are created to call the cron at the precise moment the alarm is
set. The cron no longer send emails for events in the coming 30 minutes
as those will be triggered too.

closes odoo/odoo#64560

Task: 2416741
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-01-18 15:57:41 +00:00
Kevin Baptiste b0d1cb23b3 [FIX] calendar: do not send updates on past events
Before this commit, a notification was sent to all the attendees
whenever a past event was modified.

Now the notification is only sent if the event is taking place in the
future.

closes odoo/odoo#63015

Taskid: 2409394
X-original-commit: e31819bccec604ba61c053015304abebdd189690
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2020-12-08 12:20:23 +00:00
Achraf (abz) 2bc6d668b7 [FIX] calendar, google_calendar, hr_holidays: lost attendees after sync
What are the steps to reproduce your issue ?

    1. Install "google_calendar"
    2. Log in with "admin"
    3. Create an eventX with "admin" and "demo" has attendees
    4. Run "Google Calendar Synchronization" from "Scheduled Actions"

What is currently happening ?

    eventX is successfully added to Google but without admin
    if you sync Odoo to Google one more time, Google will overwrite eventX
    and it will remove admin from attendees

What are you expecting to happen ?

    Sync Odoo to Google and Google to Odoo without lost attendees

Why is this happening ?

    Because there is a filter that prevent addition of current user to the attendees

How to fix the bug ?

    Remove the filter

This reverts commit 287ee0f83ae6fd457e5356860c8a8ab5a4e66754.

opw-2382443

closes odoo/odoo#62416

X-original-commit: f6a610d0b1379aa97ad97fb7494a5d269da87775
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-11-26 14:41:30 +00:00
Raphael Collet 1398b6b44c [IMP] tests: deprecate SavepointCase
closes odoo/odoo#62031

Related: odoo/enterprise#14872
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-11-24 13:23:32 +00:00
Christophe Monniez a431ee3f52 [FIX] calendar: use a contextual timestamp in test
When the test starts after 00:00:00 UTC, the test fails.

closes odoo/odoo#60891

X-original-commit: c62acb48ac3ae11180a6817321664fb01833d3bd
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2020-10-28 11:38:42 +00:00
Nicolas Galler bb9d5667b5 [FIX] calendar: accepting meeting invite from email
Behavior prior to the fix:

When accepting a meeting invite from the invitation email, if not logged
in, an Internal Server Error is received.  Additionally, if already
logged in, an Internal Server Error is also received (albeit for a
different reason)

Behavior after the fix:

Accepting (or declining) the meeting invite works and shows the
accepted/declined meeting.

opw-2366173

closes odoo/odoo#60617

X-original-commit: d44d9e58b2cd5530e15e2a8c5055b18d2d8395e7
Related: odoo/enterprise#14361
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: Nicolas Galler <nicocrm@users.noreply.github.com>
2020-10-23 12:28:45 +00:00
Achraf (abz) 4f28864617 [FIX] calendar: Dont send mail to attendees when the event date is past
Issue

    - Install "Calender"
    - Install "Google Calendar"
    - Try to sync google in "Calendar"

    Every created events will trigger the sending mail to attendees
    even if the event date is past

Cause

    'events' was not filtered

Solution

    Filter 'events' to get all the events that have not yet happened

opw-2358123

closes odoo/odoo#60414

X-original-commit: 3b1df8f57e0cd342fe7f9ff7bd34100b2c821569
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
2020-10-21 09:12:44 +00:00
Kevin Baptiste 194850bc06 [FIX] calendar: set attendees on quickcreate
When creating an event through the quickcreate, the user creating the
event was not set as attendee.

closes odoo/odoo#58631

Taskid: 2334943
X-original-commit: 07d799a5f676ed68fd2ffd9cd9bac3269f947ad1
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2020-09-28 10:46:17 +00:00
Jorge Pinna Puissant b88a9116f5 [FIX] calendar: note on meeting planned activity lack new line
- In a res.partner;
- Schedule activity;
- Choose 'meeting' as activity;
- Set a summary : 'test summary';
- Open Calendar;
- Chose a date and an hour;
- Edit the meeting;
- Add a description with a line break;
- Save the meeting;
- open the res.partner view;

Before this commit, the note on the planned activity lack the line
break.

Now, the note in the planned activity has the same output as the
description of the calendar meeting.

opw-2236838

closes odoo/odoo#50226

X-original-commit: 2e9cc92fb45f9328c45520275ab11c7a486a2590
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2020-04-27 13:52:55 +00:00
Lucas Lefèvre 7e09f71ae4 [FIX] calendar: Aggregate field when grouped
Commit b0f1086 forgot that `read_group` supports
aggregation functions (e.g. "start:month") and that
`groupby` could be a single field or a list of fields.

+ add some tests

Task 2238100

closes odoo/odoo#49550

Related: odoo/enterprise#9878
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-04-15 11:14:52 +00:00
Yannick Tivisse 1a9be3a869 [REF] calendar: Lint + Clean code 2020-04-09 10:59:34 +02:00
Lucas Lefèvre 6bafd7c677 [REM] calendar: Remove useless time fields
The fields `start_datetime` and `stop_datetime` are the exact miror
of fields `start` and `stop` respectively.

The field `display_start` is never used.

Hence those fields are removed.

Task 2126717
PR #42031
PR Enterprise odoo/enterprise#8006
2020-04-09 10:56:37 +02:00
Lucas Lefèvre 7159f657a0 [REF] calendar: Refactor calendar attendees management
This commit refactors the event attendees and notifications according
to the recurring event refactoring.

Some (very) basic reminder tests are also added.

Task 2126717
PR #42031
PR Enterprise odoo/enterprise#8006
2020-04-09 10:56:37 +02: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
Thibault Delavallée 69ccabb212 [FIX] mail: restrict access to mail.mail model
From now on mail.mail is considered as a technical model. Indeed people should
not really manually craft mails by hand. Instead various functional flows
should either send mails, either craft mails based on some user input.

We therefore make mail restricted to admin users. Flows creating mail.mail
are updated to use sudo, and ensure it was done in a context that makes
sense to delegate this power to the user.

Task ID 1853147
PR #32243
2019-11-29 13:35:14 +00:00
Yannick Tivisse 47a2be94cb [IMP] calendar: Adapt tests to work with/without demo data 2019-11-05 13:08:03 +01:00
Julien Castiaux 4f03a5f136 [FIX] *: remove old deprecated modules/functions
PEP-594 is deprecating a bunch of modules. As part of the cleanup, we
are also dealing with long deprecated modules, functions and aliases.

* `assert_` -> `assertTrue`
* `assertEquals` -> `assertEqual`
* `assertNotEquals` -> `assertNotEqual`
* `assertAlmostEquals` -> `assertAlmostEqual`
* `assertRaisesRegexp` -> `assertRaisesRegex`
* `assertRegexpMatches` -> `assertRegex`
* `base64.encodestring` -> `base64.encodebytes`
* `base64.decodestring` -> `base64.decodebytes`
* `inspect.getargspec` -> `inspect.signature`
* `inspect.formatargspec` -> `inspect.signature`
* `logging.warn` -> `logging.warning`

closes odoo/odoo#36863

Task: 2003936
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-09-17 11:36:42 +00:00
Christophe Simonis 5a273e74f0 [MERGE] forward port branch saas-12.4 up to fe59754c52
closes odoo/odoo#36721

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-13 13:32:51 +00:00
Christophe Simonis 4528f75cb0 [MERGE] forward port branch 12.0 up to 82c0e9b620 2019-09-03 12:41:08 +02:00
Andrea Grazioso (agr-odoo) b8c7eddb34 [FIX] calendar: invitation for deleted event (recurring)
From calendar create a recursive event and add some guests. Delete one
event of the chain.

Invitations (Mail) will be created for the deleted event, and should not
be the case because the event has been deleted.

This happens because the recursive event is really just a record in the
database representing all the generated events. When the user want to
delete an event in the chain, a new event, copy of the "parent" event
has to be registered and subsequently disabled.
In the process of creating the event the mail is sent as
side effect. Note that the code to prevent this was partially there
because a context flag "dont_notify" is sent by the unlink in
Calendar.Meeting but was ignored from the mail subsystem.

opw-2039576

closes odoo/odoo#36270

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
2019-09-02 09:45:51 +00:00
Raphael Collet b7fd679a6c [FIX] *: sudo() -> with_user() 2019-07-04 11:32:22 +00:00
Christophe Simonis 6faad524cf [MERGE] forward port branch 12.0 up to bc744a1da4 2018-11-16 19:30:20 +01:00
Christophe Simonis eafda0469a [FIX] calendar: adapt test version 12
*/ Use existing partner name
 */ correctly compare dates
2018-11-16 16:29:21 +01:00
Christophe Simonis 4b8bd36219 [MERGE] forward port branch saas-11.3 up to bab2a191d2 2018-11-16 15:39:02 +01:00
Lucas Perais (lpe) c8133d7133 [FIX] calendar: activity deadline from event date
Be in the timezone Australia/Brisbane

On an object, create a Meeting activity

Create the calendar event and set a start date "tomorrow" at 7:00am

Now go back to the object to see the activity

Before this commit, the activity appeared as due "today"

After this commit, it is due "tomorrow"

OPW 1891110

closes odoo/odoo#28576
2018-11-12 12:48:07 +00:00
Christophe Simonis b106b7ce0b [MERGE] forward port branch 12.0 up to dd70c68426 2018-11-06 16:40:07 +01:00
Christophe Simonis 5e055a2afd [MERGE] forward port branch saas-11.4 up to f6ca72b3ce 2018-11-02 10:52:55 +01:00
Christophe Simonis a299517f83 [MERGE] forward port branch saas-11.3 up to 6136f0c02e 2018-10-29 11:56:32 +01:00
Lucas Perais (lpe) eeae211176 [FIX] calendar: recurring event around DST
Be in timezone Europe/Brussels, where, in 2018, the DST switch
happens on 2018-10-28.

Create a recurring event starting on 2018-10-27 until 2018-10-29
at say, 8am

For the days before the 28, the time of the event will be correct

Before this commit though, for the days after the 28,
the meeting time will be shifted by one hour
This is because the rrule took a TZ aware datetime, and generated recurring
event dates with that same TZ, i.e. the one in STD time

After, this commit, all the meetings are well scheduled at 8am,

OPW 1895315

closes odoo/odoo#27985
2018-10-23 14:00:18 +00:00
Lucas Perais (lpe) eef4c3b48b [FIX] calendar: all day event shouldn't store in UTC
With a user in a distant timezone, like UTC +/- 11

Create a all day event.

Before this commit, the event was displayed across the wrong days
This was because the dates were converted from the user's timezone
into UTC before being stored.

Which is:
- start date at december, 12
- if the user's tz is utc-11: the date becomes december, 11 (at 1:00pm)
- at rendering, it becomes december, 11 (at 7:00am)

After this commit, we store the datetime field "as if" it were a date field
that is, we don't convert it to any particular tz

It is worth noting that, if one removes the allday mapping in the xml view,
an event that has been created as allday will get its start and stop date converted
to the browser's timezone, and will NOT be displayed as from 8am to 8pm as one could expect
This is considered as a limitation of the code, that was present before this commit anyway.

In any case, please do not revert this commit :D

OPW 1891110

closes odoo/odoo#27949
2018-10-23 11:26:28 +00:00
mreficent 4f9afa6a64 [REF] calendar: rename calendar.alarm type to alarm_type
Purpose of this commit is to rename type column to something matching the
the real business use of the field. That way it is easier to find and grep
in the code. It also lessens potential conflicts with type build-in python
function. It also lessens conflicts when using the field in JS as type
is a build-in attribute.

Renaming type column is a long-living issue. We choose to do it at the
beginning of the v13 development to catch errors as soon as possible.

This commit is linked to task ID 1896245. It is also a subpart of community
PR #27599.
2018-10-19 09:12:55 +00:00
Christophe Simonis a0901237f2 [FIX] calendar: correct recurring date timezone conversion 2018-09-14 17:23:29 +02:00
Christophe Simonis 9c77066f34 [MERGE] forward port branch saas-11.4 up to 6c103589c1 2018-09-14 16:00:17 +02:00
Christophe Simonis f3fa5a5ef7 [MERGE] forward port branch saas-11.3 up to 1e0a92c996 2018-09-13 19:30:33 +02:00
Nicolas Lempereur 3d09560ffc [FIX] calendar: keep recurring after edited one
Since 76b7242 if we have a recurring event with 3 occurences:

 [4th 4:00-4th 5:00] [14th 4:00-14th 5:00] [24th 4:00-24th 4:00]

And we detach the first one to modify it, then when getting the
info of reccurring events not detached the system get:

- starts: [14th 4:00] [24th 4:00]
- stops: [4th 5:00] [14th 5:00] [24th 5:00]

And wrongly apply the current filtering over:

 [14th 4:00-4th 5:00] [24th 4:00-14th 5:00]

So the issue hides recurrences of event wrongly if:

- they have not been detached
- they don't have a duration of 0
- one or several previous events have been detached
- the stop date of the nth previous event occurrence (nth equaling
  number of detached previous events) is not in the current filtering.

With this change, the stops are also filtered based on start of
occurrence + duration.

Without the change, the added test fails with:

 False != '27-20120301120100' : Last event should be found searching it by date range

note: 11.0 version of 10.0 #26887

opw-1866151
closes #26901
2018-09-11 16:27:58 +02:00
Raphael Collet 960360afe4 [REF] *: use native date/datetime for Date/Datetime fields
From this commit onwards, Date fields will return datetime.date objects and Datetime fields will return datetime.datetime objects, this implies a number of things that are clearly explained both in the ORM API for master.

This commit also introduces a number of helper functions for dates and datetimes that are exposed in tools.date_utils and fields.Date[time], explained in the documentation as well.

Task-ID: 47189
2018-08-06 14:37:19 +02:00
XavierDo f74f5edc77 [FIX] calendar: correct domain computation for recurring events
The custom computation for domain applied on recurring event
was assuming that a leaf value was true. This can lead to miscomputation.

Context:
For a domain like
'|',
	('start', '>=', '2018-06-28 23:59:59'),
	('allday', '=', True),

the domain will be transformed into
'|',
	'|',
		('start', '>=', '2018-06-28 23:59:59'),
		'&',
			('recurrency', '=', 1),
			('final_date', '>=', '2018-06-28 23:59:59'),
	('allday', '=', True],
In order to fetch recurring event with date that COULD match the domain.

Then, the custom evaluation will filter the generated virtual ids with
the base domaine, replacing leaf not specific to bounds by true,
leading to a domain like:
'|',
	('start', '>=', '2018-06-28 23:59:59'),
	True,
Also well known as "True"
Therefore, all recurring event virtual ids will be kept.

Solution:
This fix proposes to fetch the leaf values from the database to ensure
the consistency of the domain.

Thanks to RLI for the help.
Task: #1858076
PR: #25544
2018-07-11 10:11:14 +02:00
Christophe Simonis 6c2ab192ea [MERGE] forward port branch saas-16 up to 88a9980b0c 2017-10-10 16:49:59 +02:00