Commit Graph
151 Commits
Author SHA1 Message Date
Philippe Wauthy 5a05d7a89a [FIX] hr_holidays: fix test_leave_whole_company_07 test
test_leave_whole_company_07 test was failing due ot the hr_leave_date_check2
constraint.
This constraint check that date_from <= date_to for a leave.

date_from and date_to were not assigned any value before and had a default value
of fields.Datetime.now. Depending on which date_from or date_to is created first,
a few second difference can exist and this violates the hr_leave_date_check2 constraint

task-2726143

closes odoo/odoo#82192

X-original-commit: c51553405b727e0187c0cf27b0ef9e0cb6023056
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-01-04 08:47:11 +00:00
Philippe Wauthy dc0db19fc8 [FIX] hr_holidays: allocation not found in test_limited_type_days_left
In test_limited_type_days_left, a time off was created with:
- 'date_from': (datetime.today() - relativedelta(days=2)),
- 'date_to': datetime.today(),

The test fails beginning of January as the allocation created at the
beginning of the test is valid between Jan 1 and Dec 31

task-2726171

closes odoo/odoo#82179

X-original-commit: df71862e59943b83584c36b08acd9700998716e1
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-01-04 07:59:29 +00:00
Philippe Wauthy 79a8561f97 [FIX] hr_holidays: fix test_01_leave_request_flow_limited
In test_01_leave_request_flow_limited, a time off was created with:

- 'date_from': (datetime.today() + relativedelta(days=2)),
- 'date_to': datetime.today() + relativedelta(days=3),
The test fails during the end of December because no allocation is found.
The time is now frozen in the test

task-2726308

closes odoo/odoo#82178

X-original-commit: 1d6e736832b56a4c2bf1b9e335ed2bd8f929507a
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-01-04 07:59:26 +00:00
William Braeckman 0c2f518c58 [FIX] hr_holidays: fix end of year error
Fixes an error happening near the end of the year with one of the test.
The error was introduced with 254d6a71e8

TaskId-2724172

closes odoo/odoo#82028

X-original-commit: 1de3a4bee7b1df4960694d0851e72ef2eecb98a9
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2021-12-29 15:16:26 +00:00
Kevin Baptiste b600373abb [FIX] hr_holidays: fix accrual test
The test `test_unused_accrual_postponed` was expecting at least 25
holidays to be accrued, but started failing around mid-December.

closes odoo/odoo#81592

X-original-commit: c2865b7f5b654a61d4b2690133797aa39712b00d
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-12-17 13:40:06 +00:00
Christophe Monniez 0aa8dbd295 [FIX] hr_holidays: fix freeze_time usage
When Freezegun is used with the `start` and `stop` method and the test
fails before the `stop`, the time stays frozen for all the other tests.

When it happens on runbot, a lot of tests brake with a lot of noise as
they are false negatives.

X-original-commit: 048796dc125b0d494f3c2fcd12625a84ee5cd91d
Part-of: odoo/odoo#81592
2021-12-17 13:40:05 +00:00
Merlin (megu) ede7ae8e55 [FIX] hr_holidays: confirm allocation request with no validation needed
An employee could not confirm an allocation request of a type that doesn't need validation

Steps to reproduce:
1. Connect as admin
2. Install and open the Time Off app
3. Create a time off type in Configuration->Time Off Types with
	- Requires allocation: Yes
	- Approval: No validation needed
4. Connect as demo
5. Open the Time Off app and create an allocation request of the type created just before

Solution:
Add a condition before raising the error that checks the allocation validation type

OPW-2683477

closes odoo/odoo#81143

X-original-commit: d985b96ba77f45edee8001d1063f644c99a15ffc
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
2021-12-09 14:37:06 +00:00
Philippe Wauthy b6ef46f71c [IMP] hr_holidays: show conflicting time off in validation error message
Description of the issue/feature this PR addresses:
In hr_holidays, there is no information about the conflicting time off when a second time off is scheduled at the same time.
There is a validation error saying "You can not set 2 time off that overlaps on the same day for the same employee".
The validation error should display the conflicting time off

Current behavior before PR:
The validation error displays the following:
"You can not set 2 time off that overlaps on the same day for the same employee"

Desired behavior after PR is merged:
The validation error will display the following:
"You can not set 2 time off that overlaps on the same day for the same employee.
Existing time off: Mitchell Admin / Trip with Family : 24.00 hours / from 06/09/2021 to 08/09/2021 / To Approve"

task-2641682

closes odoo/odoo#76452

Related: odoo/enterprise#22490
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2021-11-25 08:29:21 +00:00
William Braeckman ecddd5f729 [IMP] hr_*: Improve tests execution speed by using setUpClass
closes odoo/odoo#79063

Taskid: 2669222
Related: odoo/enterprise#21920
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-10-27 13:16:42 +00:00
William Braeckman faefaf7c39 [IMP] resource: improve _attendance_intervals_batch perf
Improves on _attendance_intervals_batch to profit more from batching.
Resources are grouped by timezone since we know they will all have the
same result except for when there are resource assigned attendances.
Those have to be handled separately but are incoroporated in the same
routine.

TaskId-2674527

closes odoo/odoo#78741

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-10-26 13:22:27 +00:00
Thibault Delavallée c0d16beb7e [FIX] various: update query counters to last runbot state
A lot of counters are not up to date. Seems some optimizations were done
allowing to lessen query counters.

Task-2661036 (Performance tests data cleanup)
Prepares Task-36879 (MultiCompany Aliases)

Part-of: odoo/odoo#77845
2021-10-05 16:53:45 +00:00
William Braeckman bd13371781 [FW][FIX] hr_holidays: Make accrual plan prorated
closes odoo/odoo#77342

Forward-port-of: #77311
Related: odoo/enterprise#21229
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-09-29 08:33:03 +00:00
Samuel Degueldre 5c78793a75 [FIX] hr_holidays: fix crash in mail_partner_format
We were trying to sort a list of date with potentially falsy elements in
the list, causing a crash while trying to compare a date object with a
bool. This commit just makes the check that all dates are not falsy
before attempting to sort.

closes odoo/odoo#77012

X-original-commit: 6bd2a86e37809b4d77aad4597e926e99f9d2b2ce
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Samuel Degueldre <sdegueldre@users.noreply.github.com>
2021-09-23 07:17:52 +00:00
William Braeckman fb3ac94ce8 [FIX] hr_holidays: count only valid allocations in dashboard
Since the recent time off B2B, time off validity has been moved from the
time off type to the time off allocation. Meaning that a company may use
the same time off type every year for their yearly time off.
This means that the dashboard must display currently valid data.
Remaining leaves and taken leaves will now be computed in function of
that data aswell in the dashboard.

This commit also fixes being able to take a leave if the current
allocation does not permit it if an expired one would have made it
possible.

TaskId-2636405

closes odoo/odoo#76366

X-original-commit: eeccd682124fe83d2c2342be0d8804aa2ca21146
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: William Braeckman (wbr) <Williambraecky@users.noreply.github.com>
2021-09-10 18:19:40 +00:00
254d6a71e8 [IMP] hr_holidays: Improve Accruals, dashboards and general UX (Back2basics)
Purpose
=======

Time Off : New Dashboard, Accruals feature, Public holidays, New time off type configuration view.

- Review of Dashboard
- Accrual feature : Currently, when you create an allocation, it's possible to create an
  Accrual, but there is no appraisal Plan. An Appraisal plan is use to define steps of accruals
  for each employee.
  In Belgium, we use accrual Allocation for European Leaves, or compensatory hours, it's a
  simple use case.  But in USA, it's possible to change the calculation mode each year.
  Also, in USA, it's possible to deal your accrual plan when you arrive on the company. It's a
  HR Officer task to create the right Accrual allocation for each new employee.
- Public Holidays :
  Improvement of global time off feature located on Working hours calendar. Now, Time off
  application have to manage Public Holidays.
- Review of Time Off type configuration

COM PR: https://github.com/odoo/odoo/pull/72511
ENT PR: https://github.com/odoo/enterprise/pull/19157
UPG PR: https://github.com/odoo/upgrade/pull/2791
TaskID:2475413

closes odoo/odoo#72511

Related: odoo/enterprise#19157
Related: odoo/upgrade#2791
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: William Braeckman <wbr@odoo.com>
Co-authored-by: Xavier BOL (xbo) <xbo@odoo.com>
Co-authored-by: Laurent Stukkens (LTU) <ltu@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2021-09-02 12:57:03 +00:00
Sébastien Theys 4cd70f164e [IMP] mail, hr, hr_holidays, *: batch mail partner format
* = test_discuss_full

Overall less queries.

Changes:

- Batch `mail_partner_format`.
- Batch `user.employee_id` compute.
- Remove query for current leave state, use fields (and prefetch) instead.
- Move current leave state in partner format instead of channel info.

Part of task-2622462

closes odoo/odoo#73174

Related: odoo/enterprise#20186
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-08-12 15:22:59 +00:00
William Braeckman ddef148260 [FIX] hr_holidays: half day outside of working hours
Fixes taking a hald day outside of working hours counting as half a day
instead of nothing.

See odoo/odoo#68977

closes odoo/odoo#74147

X-original-commit: 35a7308188d069465ad624d4199ec26b6d25d651
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: William Braeckman (wbr) <Williambraecky@users.noreply.github.com>
2021-07-23 09:29:23 +00:00
Nicolas Lempereur c900e40868 [FIX] hr_holidays: request date tz whole company
When setting the request_date_from and request_date_to when creating a
leave that will be used to show the range of days of the leaves, we are
using the current user timezone to determine it.

eg. in UTC+2 if the leave begins at midnight on the 6th, we will see 6
and not 5 which is the day in UTC.

When creating a leave in a mode different than employee, when it is
confirmed and a leave is created for each employee, we would use the UTC
day instead which is a little unexpected.

Without the fix, the added test fails with:

    AssertionError: datetime.date(2019, 5, 5) !=
    datetime.date(2019, 5, 6) : Timezone should be kept between company
    and employee leave

opw-2573730

closes odoo/odoo#73633

X-original-commit: eb5c4e9b8d32a10e460ac089794bf1ceb9b7b71a
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-07-13 12:46:38 +00:00
std-odoo 9183a86fde [REM] mail: remove "email_send" field on the mail channel
Purpose
=======

Remove the "email_send" field on the <mail.channel> (mass_mailing named
on the JS side).

This feature will be introduced with a new model (<mail.group>) in a
new module in the next commit.

Remove the email notification support on the channel, so now the mail
channels work only by chat.

Remove the "subject" on the Discuss side because this was used only on
"email" channel.

Technical
=========

In the mail channel model we can drop the usage of the blacklist as well
as the usage of the "email_to" field. Those two features were mainly
used for mailing list and have no utility for "chat like" channel.

Links
=====

Task-2510267
See odoo/odoo/pull/71599
See odoo/enterprise/pull/19296
See odoo/upgrade/pull/2600
2021-07-09 11:16:38 +00:00
fw-bot 36bca6eb52 [IMP] calendar: Forward port of Saas 14.3 calendar perf yti
Forward port of https://github.com/odoo/odoo/pull/71808

closes odoo/odoo#72043

X-original-commit: 4f13a2214aed380c8aea984d3414caca506401bf
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Arnaud Joset <arj-odoo@users.noreply.github.com>
2021-06-11 12:11:14 +00:00
nounoubensebia d01e5c5cdb [IMP] calendar, crm, hr_holidays: move meeting stat button to calendar
Move the meeting stat button and kanban pill from CRM to Calendar, purpose is to
allow its usage even if CRM is not installed as this makes more sense since this
field is usually related to Calendar.

Increase query number limit in company leave test, in order to take into account
the newly introduced query in Calendar.

UPG-PR: https://github.com/odoo/upgrade/pull/2423

Task-2514473

closes odoo/odoo#69846

Related: odoo/upgrade#2423
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-04-28 14:05:07 +00:00
Goffin Simon de75260ba6 [FIX] hr_holidays: Leaves for partial time are wrongly counted
Steps to reproduce the bug:

- Let's consider an employee E that doesn't work on Monday morning
- Create a half day leave request LR for E on a Monday afternoon
- Save

Bug:

The duration of LR was counted as one day instead of 0.5

opw:2491784

closes odoo/odoo#70366

X-original-commit: b088abb95d9dac0a66c429f258a5e4f4e3a58501
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-05-04 20:44:52 +00:00
Jérémy Hennecart 7630b837b2 [IMP] hr(_work_entry)_holidays: increases queries count
Adapt queries count to the changes applied with the previous commits.

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
Jérémy Hennecart 4a616e1ab1 [IMP] calendar(_sms): add template selection on reminders
The purpose is to allow the user to have the opportunity to manage what is
going to be send as reminders. He can now access to the template or create
a new one when the type of reminder is email or sms. In case of a simple
notification, a new text field is added to add custom content.

Task ID-2191254
COM PR odoo/odoo#68443
UPG PR odoo/upgrade#2313

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-03-30 12:15:00 +00:00
Thibault Delavallée 7991118bfe [REF] mail, various: remove support of channels from message_subscribe API
RATIONALE

Channel model is a mail.thread enabled model behaving strangely with followers,
notifications and discuss. Its code should however be simplified to be more
self contained and avoid unwanted side effects on other models.

SPECIFICATIONS

Remove ``channel_ids`` argument and support from ``message_subscribe`` and
``message_unsubscribe`` API. Indeed we do not support adding channel-based
followers anymore. Only partners should be added or removed from followers.
It also allows to simplify API and understanding of both methods.

Various addons are updated to match the simplified (un)subscribe API. Some
enterprise addons may also be impacted.

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
2021-03-17 18:16:11 +00:00
Thibault Delavallée ca1ff19f55 [FIX] hr_holidays: make ooo tests less dependent on channel_info members ordering
Purpose of this test is to avoid failing tests due to list ordering not
being always predictable in channel_info.

Some out of office tests are dependent on channel_info ordering. Indeed one
test relies on members list ordering (using [0] and [1]) instead of fetching
the right member in the given result list. In this commit we

  * ensure members in channel_info effectively match expected members;
  * check content of the right channel info member instead of relying on
    list order;

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
2021-03-17 18:06:36 +00:00
Kevin Baptiste 07ccdb2e88 [IMP] hr_holidays: increase performance counter
The change introduced in odoo/enterprise#16664 for hr_appraisal
increases the query counter by one.

TaskID: 2464991
2021-03-08 07:17:59 +00:00
Raphael ColletandVictor Feyens 840609975a [IMP] core: better way to set/update magic fields
The goal of this change is to simplify the code managing `create_date`
and `write_date` in methods `create()` and `write()`, and also to remove
weird behaviors caused by the way those fields were updated.

Assume we update a simple field on a record.  This adds pending updates
for the field and `write_date`.  However, the value of `write_date` is
not known yet: it will be updated as `NOW() AT TIME ZONE 'UTC'` in SQL.
So `write_date` is actually given a dummy value in pending updates, and
it is invalidated from cache, until its value is flushed to the database
and fetched again.

Now assume we access another field on the record, and that field is not
in cache.  The prefetching mechanism will read all column fields,
including `write_date`, and flush them first.

    # this adds pending updates foo: 42, write_uid: 1, write_date: False
    record.foo = 42

    # assume 'bar' is not in cache; this prefetches all column fields,
    # which flushes the pending updates above before reading them back
    result = record.bar

We can avoid flushing pending updates if the values read from database
do not overwrite existing values in cache.  If you assume that the value
of a pending update is in cache (in the example, `foo: 42`), you don't
need to flush the corresponding field.  Indeed, the value of `foo` will
remain 42 in cache, whatever its value in the database.  This assumption
(pending updates are in cache) is true for all fields *except* for
`write_date`: it is invalidated from cache, and given a dummy value in
pending updates.  This branch actually makes this assumption true for
all fields.  The avoidance of flushing pending updates will be done in
another commit.

In order to directly assign `write_date` its value, we use a cache for
the value `NOW() AT TIME ZONE 'UTC'` from the database.  This costs at
most one query per transaction, and potentially saves a few queries.

Co-authored-by: Victor Feyens <vfe@odoo.com>
2021-02-22 16:20:55 +00:00
Raphael Collet 75d2f995e2 [FIX] *: query counts
Adapt some query counts to their optimal value, in order to measure the
effect of the following commits on queries.

In module test_performance, some query counts were actually not correct:
the initial flush() done by the context manager assertQueryCount() may
prefetch some data to the cache, and that prefetching is not accounted
for in the query count.  This is very true when assertQueryCount() is
preceded by a cache invalidation.  We have to move the invalidation
inside the context manager, so that the prefetching is now counted.
2021-02-22 16:15:28 +00:00
sofiagvaladze 21e2676b7a [IMP] hr_holidays: Allow to delete future time off
Allow to delete a non validated time off in the future to a simple user
Add some tests

Task - 2428789

closes odoo/odoo#65361

Related: odoo/upgrade#2127
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-02-16 09:44:15 +00:00
nie 37bc6b52a7 [FIX] hr_holidays: float representation issues with 38 hours schedule
Steps:
- Install Time Off
- Go to Employees
- Click an employee (A)
- Change Work Information > Schedule > Working Hours to "Standard 38 hours/week"
- Go to Time Off > Managers > Time Off
- Click Create
- Select employee (A)
- In the title, select Unpaid
- From 2020-12-20 to 2020-12-24

Bug:
Float representation issue: 4.00 Days (30.400000000000002 Hours)

Explanation:
Changing formatting of `number_of_hours_text` from '%s' to '%g'. This affects the way this value is displayed: 0.0 Hours is now 0 Hours.

opw:2418740

X-original-commit: 0bbd31ca0a2c24fac55e2f6277d727a1d0c58c54
2020-12-29 11:24:20 +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
Yannick Tivisse 7e24a95474 [FIX] hr_holidays: Remove contraint
Purpose
=======

The goal of this contraint is to prevent employees to take a time off
when he's not supposed to work (example: after the end of his contract).

But, in some conditions (example: we change the contract end date), the
number_of_days is not recomputed, and the constraint is raised
when unlinking the time off.

Move the chunk of code at the validation level, to prevent validating
a time off if the employee is not supposed to work.

closes odoo/odoo#62337

X-original-commit: c0e082ee1fba7cecc711f724974d79ed65bab29b
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-11-25 15:00:32 +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
Arnaud Baes c618561c03 [FIX] hr_holidays: write access for approvers
Without write permissions, Time Off Managers are unable to approve
nor refuse leave requests. It seems there was a mismatch with
`hr_holidays.group_hr_holidays_user` as "Approvers" and actual users
at some point.

Bug reported via p/feedback by CMO and LEM after v14.0 migration.

closes odoo/odoo#62084

X-original-commit: 7c32f977aa5233d47ba6aebef56dc70f7b7b9bac
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-11-20 11:06:34 +00:00
fw-bot 2be103239f [MERGE] l10n_be_hr_payroll: Validate the CP200 different payslips
Purpose
=======

In Belgium, the job market is divided into "sectors": chemicals, metals, banks,
department stores, pharmacies ... This breakdown is made on the basis of the
activities of the company. In order to be able to ensure the functioning of the
sectors, each sector has its own consultation body, called the "joint commission".

A joint committee is a consultation body in which representatives of employers
and unions set, after negotiation, the minimum wage conditions as well as the
working conditions in legal texts, called “collective labor agreements”. These
are applicable to all employees in a specific sector.

These are agreements that employers and workers in a given sector must make and
respect. These agreements may be different from one sector to another. Each sector
has its label and number.

The CP 200 is the auxiliary joint committee of employees (CPAE). About a quarter
of private sector companies and employees in Belgium are found in CP 200. This
makes it the largest and most diverse CP in the country!

TaskID: 2352568

Specification
=============

Most of the different use cases that we can face in belgian payroll for CP200
have been tested and validated by a fiscal expert.  Briefly, it covers the following
use cases:

- Unpaid time off
- Legal time off
- Credit time
    - Classical
    - With paid time off
    - With unpaid time off
    - With sick time off
    - Starting in the middle of a month
    - Full time (O hours / week)
- Half-days in working hours
    - Classical
    - With full-day time off
    - With half-day time off
- Low salaries
- Back-to-work - Sick time off
    - Relapse
    - Guaranteed salary
    - Long sick off (+1 month)
- Student contracts
- Posted Employess
    - Without ONSS
    - Wihtout withholding taxes
- Public Holiday
    - Classical (during the working hours)
    - Compensation (during the week end)
    - After the end of the contract
    - Note: Variable compensation is not handled yet, but it's planned
- Brief Holiday (In french: "Petit Chômage")
    - 1 day
    - 1 week
    - Note: Variable compensation is not handled yet, but it's planned
    - 1 day for unpredictable reason
- End of contract in the middle of the month
- Half-days time off
- New design of the payslip to improve readability

The detailed list of the fixes/improvements is the following:

- 1/ hr_work_entry_contract: Define 1 leave work entry per presence

    Purpose:
    Some sick time off have to be defined into different work entry types, according
    to the type of sick leaves.

    Example: after 30 calendar days of sick leaves, the employee is not paid by the
    same organism and therefore, the time off should be reported into different work
    entry types.

    Specification:
    Instead of creating a big work entry per time off, create as many work entries
    as there should have been presence work entries.

- 2/ hr_work_entries: Prevent users deleting work entries

    Prefer to archive them instead.

- 3/ hr_work_entry: Display work entry type on calendar views

- 4/ web: Add styling classes for report

    Purpose:
    Those classes are useful for the payslip printed pdf reports, but some
    of them are useless for any kind of report, and thus the classes have
    been defined in the web addons.
    Task-2341886

- 5/ resources: Take company attendances/global leaves on creation

    Purpose:
    When creating a new calendar (38 hours/week) on a Belgian company,
    the new calendar is prefilled on a 40 hours/week basis, even if the
    company calendar is correctly defined.

    Specification:
    Copy the global time off + the attendances on the company calendar
    on company modification

- 6/ hr_holidays: Allow to refuse overlapping time offs

    Purpose:
    It's normally not possible to create 2 time off that overlaps on the
    same period.

    But, if for a given reason it happens on a production database, it should
    be possible to refuse those time off. Otherwise, the user is stuck with
    this wrong configuration.

- 7/ hr_holidays: Prevent creating time off of 0 hours

    Purpose:
    It makes no sense + it could cause conflicts when generating the work
    entries

- 8/ resource: Add method to retrieve the longest work day

    Purpose:
    Add a method on the calendar to retrieve the maximum number of hours
    an employee is supposed to work.

    Example:
    Monday: 8-12, 13-17
    Tuesday: 8-12, 13-17
    Wednesday: 8-12
    Thurday: Off
    Friday: Off

    The method will return 8

- 9/ hr_holidays: Adapt query counter due to changes on hr_payroll

    See: https://github.com/odoo/enterprise/pull/13848/

- 10/ hr_payroll: Update translations

    Lots of new terms have been added on the printed reports, etc...

- 11/ l10n_be_hr_payroll: Consider out of contract public holiday

    Purpose:
    If there is a public holiday less than 30 days after the end of the
    contract, the employee should be paid for that day too

- 12/ l10n_be_hr_payroll_posted_employee: Add an easy way to create a public time off

    Purpose:
    Public time off should be created via the calendar (at least for belgian companies using payroll).

    The reason behind this is that there should be a resource.calendar.leaves available even if the
    employee ends its contract. If it's created using a hr.leave, there won't be any
    resource.calendar.leave as the employee is not supposed to work anymore at that time.

    When an employee leaves the company, it's possible that he's paid for public time off if it
    occurs less than 30 days after the end of his contract.

- 13/ l10n_be_hr_payroll: Rename bank holiday into Public holiday

    Purpose:
    A bank holiday is a specific holiday name, not the generic one.

- 14/ hr_work_entry_contract: Add menuitem to access calendars

    It shouldn't be required to enter debug mode to access this information.

- 15/ l10n_be_hr_payroll_posted_employee: Add support for posted employees

    Purpose:
    https://www.socialsecurity.be/citizen/fr/travailleur-salarie-occupe-en-belgique-detache-a-l-etranger

- 16/ l10n_be_hr_payroll: Implement guaranteed wage/relapse for sick leaves

    Purpose:

    Guaranteed salary for employees:
    The employee who is incapacitated for work as a result of a work accident, an accident on
    the way to work or an occupational disease retains, at the employer's expense, the right to
    his remuneration for the first 30 days of incapacity for work. The daily allowances relating
    to this period are paid to the employer by the body responsible for industrial accidents or
    by the Fund for Occupational Diseases.

    Successive disabilities - relapse:
    It is possible that a worker will be unable to work during different successive periods.

    When two incapacities follow one another without interruption (for example, accident followed by
    illness; successive illnesses of a different nature), there is only one period of incapacity and
    the guaranteed remuneration is not due again. time.

    On the other hand, we talk about relapse when a new disability occurs after the worker has returned
    to work normally.

    In this case, the guaranteed remuneration is not due again when the new incapacity for work occurs
    within the first 14 days following the end of a period of incapacity for work giving rise to the
    payment of the guaranteed remuneration.

    However, there is still a right to the guaranteed salary for the part remaining to run, if the first
    period of incapacity has not exhausted the entire right to the guaranteed salary during the first
    period of incapacity. A new guaranteed wage is also due again when the worker establishes by a
    medical certificate that this new incapacity for work is due to another illness or to another
    accident.

- 17/ hr_work_entry_contract: Define 1 leave work entry per presence

    Purpose:
    Some sick time off have to be defined into different work entry types, according
    to the type of sick leaves.

    Example: after 30 calendar days of sick leaves, the employee is not paid by the
    same organism and therefore, the time off should be reported into different work
    entry types.

    Specification:
    Instead of creating a big work entry per time off, create as many work entries
    as there should have been presence work entries.

- 18/ test_l10n_be_hr_payroll: Add test for full time credit time

- 19/ test_l10n_be_hr_payroll: Add test for out of contract credit time

- 20/ test_l10n_be_hr_payroll: Avoid undeterministic bug on generated tests

- 21/ hr_payroll: Don't display out of contract line on pdf

- 22/ test_l10n_be_hr_payroll: Fix undeterministic test crashes

- 23/ payroll : Improve the printed payslip report

    Improves the design of the payslip report
    Generates the report in the employee's language (add a message if the lang is not official)
    Adds some data to Laurie Poiret
    Task-2341886

- 24/ test_l10n_be_hr_payroll_account: Add test for unjustified reasons

- 25/ test_l10n_be_hr_payroll_account: Add tests for small unemployment

- 26/ test_l10n_be_hr_payroll_account: Add tests for half days time off

- 27/ test_l10n_be_hr_payroll_account: Fix false positive

- 28/ hr_holidays: Prevent creating time off of 0 hours

    Purpose:
    It makes no sense + it could cause conflicts when generating the work
    entries

- 29/ test_l10n_be_hr_payroll_account: Add test for end of contract

- 30/ test_l10n_be_hr_payroll_account: Add tests for public holidays

- 31/ hr_payroll: Display amount if hourly wage

- 32/ hr_work_entry_contract: Allow creating record on gantt view

- 33/ l10n_be_hr_payroll: Add new structure for student employees

    Purpose:
    Also bring some fixes on fields display + hours/days counts
    TaskID: 2347843

- 34/ test_l10n_be_hr_payroll_account: Add test for low salaries

    Ensure the correct computation of the employment bonus.

- 35/ l10n_be_hr_payroll: Make separate lines for half/full worked days

    Purpose:
    Worked days should be separated between the complete full days and the
    half days.

    Example:
    I work on Monday, Tuesday, Wednesday (half day)

    The calculation is OK, but the number of days is, in principle, 14 in the month of
    September 2020 (9 full and 5 in half-days). This number of days should be the subject
    of 2 separate lines:

    9 days - 68.4 hours - € 1,100.77
    5 days (in the form of half-days) - 19 hours - 224.33 €.

    In this case, we cannot use the hourly formula since the monthly salary must always be
    the same, without having an identical number of working days.

    The worker benefits from 14 meal vouchers. The number of days must however correspond
    to the number of meal vouchers so that the worker can check.

- 36/ test_l10n_be_hr_payroll: Test credit time with sick leaves

- 37/ test_l10n_be_hr_payroll_account: Test credit time with unpaid leaves

- 38/ l10n_be_hr_payroll: Don't consider time off as credit times

    Purpose:
    When generating the work entries, we compare the standard attendances
    (i.e. the full time contract) and the credit time attendances to
    deduct the intervals on which the employee is on credit time.

    But if the employee is on a time off during a period, those intervals
    will be removed from the supposed attendances, and then those periods
    are considered as credit time.

- 39/ l10n_be_hr_payroll: Fix credit time amount on payslip computation

    Purpose:
    The time credit days must not include a corresponding amount.

    In fact, no remuneration is linked to the taking of time credits. The necessary modifications
    are:
    Code LEAVE300 -> no amount

- 40/ hr_payroll: Export standard calendar if needed on payslip export

- 41/ l10n_be_hr_payroll: Fix worked days lines amount computation

    Purpose:
    The amount was computed as a simple ratio based on the number of days.

    To be correct and compliant with the law, we should consider the hourly
    equivalent wage, and compute the amount based on the worked hours.

- 42/ l10n_be_hr_payroll: Fix unpaid worked days amount computation

    Purpose:
    Don't use the normal wage which is an integer btw.

    Compute the worked days amount using the classic hourly computation formula

- 43/ l10n_be_hr_payroll: Fix unpaid leaves retenues formula

    Purpose:
    Unpaid leave must be deducted from the usual gross monthly salary
    up to the number of working hours concerned.

    The formula is in principle the following:
    gross monthly salary * 3/12/38 -> “usual” hourly salary.

    So, in the case of 2 days of unpaid leave, corresponding to 15.2 hours,
    the formula is as follows: 2650 * 3/13/38 * 15.2 = 244.61 €.

    The gross for the days actually worked is € 2,650 - € 244.61, or € 2,405.39

- 44/ hr_payroll: Generate python test from arbitrary payslip

    When the payroll is incorrect, the feedback that we receive is
    generally: "this doesn't work".

    This commit add a route in the controller of hr_payroll, to export
    in a python file, all data useful to reproduce the exact employee
    situation about the incorrect payslip.

    Before testing and fixing the incorrect payslip, we need to anonymize all
    sensitive data about the employee. This commit converts all sensitive
    data into demo data.

    This commit add a button in payslip form view to use the new route to
    export all data about the incorrect payroll.

    This button is only displayed when we are in debug mode and the current
    user is a payroll manager.
    task-2337786

closes odoo/odoo#60136

X-original-commit: 60eaecb749ad68429e4d8ba00ff0200c3360cdcb
Related: odoo/enterprise#14147
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-10-15 19:54:53 +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
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
Yannick Tivisse 4afdebbb7e [FIX] hr_holidays: Fix undeterministic crashing tests
The tests in hr_holidays/tests/test_company_leave.py seem like they randomly fail if the default value for
date_to is computed on a different second than the date_from (it's a dict of fields so not ordered).

Cfr https://runbot.odoo.com/runbot/build/3727451 2020-07-30 08:28:32 vs 2020-07-30 08:28:31
for which date_from > date_to.

I imagine the call to leave._onchange_request_parameters() is meant to fix it, but it occurs after
the create() which is flushed immediately, so it's too late and the date_from/date_to SQL constraint
still triggers.

It could happen for real production usage too, so we might want to do something about that outside of tests.
Options include:

1/ making the date_from/date_to fields writeable computed fields, with the compute method setting
   better defaults on both fields at once
2/ alternatively, remove the default=fields.Datetime.now and override default_get instead for
   deterministic defaults on both fields at once

The second solution seemed to be the better one.

closes odoo/odoo#55880

Taskid: 2312029
X-original-commit: 6908ea471dd18182f83c81046f0000a00898fb66
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-14 09:29:30 +00:00
Sébastien Theys c2918c139b [IMP] web, *: improve mock server and replace most mail mockRPC
Improve mock server:

- add support for mocked `fetch`
- add support for `active_test`
- add support for x2m `in` in domains
- add support for default values computed from a function
- implement a more natural "next id" compute
- allow initial data without ids
- ensure write and x2m commands integrity
- improve bad data/bad commands error messages
- always warn for failing RPC, not only in debug mode
- fix all existing tests that had inconsistency data

Other changes done in mail (or dependents) that are not just related to tests:

- remove `direct_partner` from formatter result
  ->`correspondent` can be computed from other keys, especially `members`

- fix `livechat_visitor` convertData
  -> only process if there is value

- add `current_partner` and `current_user_id` as `init_messaging` result
  -> easier to mock than session

- remove usage of `need_moderation`
  -> that was just a search indirection to `moderation_status`

- adapt `partner_id` -> `res_partner_id` key in `_notification_format`
  -> to be consistent with field name

- add name in result of `mail_partner_format`
  -> sometimes display_name is not the same

- remove usage of `is_moderator`
  -> that was just an indirection to `moderation_channel_ids`

Enterprise counterpart: https://github.com/odoo/enterprise/pull/11523
task-2287171

closes odoo/odoo#55854

X-original-commit: 7ba3fecb3377a720d1eb70e7515a0c45da73836d
Related: odoo/enterprise#12391
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-08-13 16:26:35 +00:00
Yannick Tivisse d2238de576 [IMP] hr_holidays: Improve the general usability (back2basics)
closes odoo/odoo#55568

Taskid: 2282495
Related: odoo/upgrade#1574
Related: odoo/enterprise#12272
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-11 09:10:49 +00:00
Victor Feyens 71ab12840b [IMP] *: do not specify unwanted defaults in default_get
When default_get is called, the wanted fields are specified through the
fields_list arg.  It is useless to fill the values for unwanted fields.

As default_get is called for nearly all records creation, simplifying
the default_get overrides:
* remove potential wrong side-effects of the values
* remove some useless or wrong  defaults computations (searches, refs,
...)
2020-07-23 16:38:17 +00:00
Thibault Delavallée 4a2ac044f8 [IMP] (test_)(mass_)mail(_full): rename and reorganize mail related test classes
Modules holding tests and helpers

  * link_tracker: mainly mock, asserts and tools for link tracker tests
    (MockLinkTracker);
  * mail: mainly gateway mock and base for mail tests
    * MockEmail -> mocks for mail gateway;
    * MailCase -> tools and asserts for mail tests;
    * MailCommon ->     base for mail functional tests);

  * sms: mainly SMS gateway mock and base for sms tests
    * MockSMS -> mocks for SMS gateway;
    * SMS Case -> tools and asserts for mail / SMS tests;
    * SMSCommon -> update of MailCommon with SMS capabilities);

  * mass_mailing: mainly asserts and tools for mass mailing tests
    * MassMailCase -> update of MailCase for mass mailing tools and asserts;
    * MassMailCommon -> update of MailCommon with mass mailing);

  * mass_mailing_sms: mainly asserts and tools for mass SMS tests
    * MockMassSMS -> update of MockSMS for mass SMS tools and asserts;
    * MassSMSCommon -> update of MassMailCommon with SMS capabilities);

Modules for tests

  * test_mail: module for mail app tests (TestMailCommon);
  * test_mass_mailing: module for mass mailing app tests (TestMassMailCommon);
  * test_mail_full: tests integrating all discuss features, currently mainly
    mail and SMS (TestMailFullCommon);

Enterprise: update test_mail_enterprise and test_marketing_automation

Task ID 2247037
Community PR odoo/odoo#50384
Enterprise PR odoo/enterprise#10266
Upgrade PR odoo/upgrade#1122
2020-05-26 10:35:58 +00:00
Ipsita Borisagar 5a166fc448 [IMP] hr_holidays: ensure out_of_office_date_end is always set
After this commit, out_of_office_date_end will always be set for consistency
even in create mode with default partners.

Task 2172420
PR odoo/odoo#44454
2020-04-30 08:51:06 +00:00
Anh Thao Pham (pta) 3bd345597f [REF] hr*: convert onchange methods to stored-editable computed fields
Impacted modules:
hr, hr_contract, hr_recruitment, hr_payroll, fleet, hr_skills, hr_appraisal, ....

Several onchanges have been converted to computed fields in the following modules :
    Community :
        - hr
        - hr_contract
        - hr_recruitment
        - hr_work_entry
        - hr_maintenance
        - hr_expense
        - hr_expense_check
        - hr_holidays
        - sale_expense
        - account_analytic_default_hr_expense

    Enterprise:
        - hr_contract_salary
        - hr_referral
        - hr_payroll
        - hr_payroll_expense
        - test_l10n_be_hr_payroll_account

There are still 2 onchanges with complex behavior that couldn't be converted easily:
- an onchange that updates "tz" (timezone) that is defined as a related field
  to "resource_id.tz". Apparently it is useless except to initialize the default
  value of "tz".
- an onchange that updates "name" that is defined as a related field to
  "resource_id.name".
  the applicant.

closes odoo/odoo#45414

Taskid: 2169099
Related: odoo/enterprise#8572
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-04-20 10:32:45 +00:00
Kevin Baptiste b8a8ad27de [FIX] hr_holidays: "Everyone" view on calendar_event
Purpose
=======

Avoid to show to much information to leave responsibles.

Specification
=============

- Dynamically add/remove the leave_manager_ids on the group
  group_hr_holidays_responsible, on employee creation/modification
- Retrict the available employees when creating a leave. For
  manager/users : Everyone. For responsibles: The employee for
  who the user is responsible. Otherwise: Only me.
- Don't obfuscate the leave name on employees for who I'm the
  responsible.
- Add a new SQL view for "Everyone" report. To select only the
  information we want to share instead of showing the hr.leave
  model directly.

closes odoo/odoo#47659

closes odoo/odoo#49765

Taskid: 2206862
Related: odoo/enterprise#9239
Related: odoo/enterprise#10021
X-original-commit: 781147dcaf1552b8f2ab687ed73034b8fd1f7352
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-04-20 09:19:48 +00:00
Yannick Tivisse d12808bb9f [FIX] hr_holidays: Split existing leaves for company leaves
Purpose
=======

Currently, when setting a global leave for a company, the
leave validation raises an UserError if there is already a
leave on those dates.

Specification
=============

Manage the conflicts for easy tests cases:
- The global time off is taken in days
- The conflicting leaves are all in days/half days

For those use cases, refuse all the conflicting leaves
and recreate other one before and/or after the global time
off, according to the use case.

Taskid: 2230549
X-original-commit: 20ef422fea7793fc87dbf51c43699bb7872036f9
2020-04-08 16:02:08 +00:00
Joren Van Onder 81f3c4e81d [FIX] hr_holidays: make _onchange_request_parameters handle timezones
At the end it constructs date_{from,to} (Datetime) by combining:

- request_date_{from,to} (Date) local to the user
- UTC time from date_{from,to} (extracted using time() into hour_{from,to})

This doesn't work in all cases, e.g.:

A leave in US/Pacific for one day (with request_unit_custom = True):
- request_date_from: 1st of Jan
- request_date_to:   1st of Jan
- hour_from:         15:00 (7:00 local)
- hour_to:           03:00 (19:00 local) <-- this happens on the 2nd of Jan in UTC

Before this patch it resulted in:
date_from: 1st of Jan 15:00
date_to:   1st of Jan 03:00

The correct value for date_to is:
date_to:   2nd of Jan 03:00

_adjust_date_based_on_tz takes care of adjusting the date based on the
hour and the user's timezone.

opw-2169863

closes odoo/odoo#44534

closes odoo/odoo#45746

X-original-commit: 523fd6e3c4ea3a4c153616bf6bdba9573501127f
Original-signed-off-by: jorenvo <jorenvo@users.noreply.github.com>
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-02-20 01:14:03 +00:00
Joren Van Onder 2e490f1c95 [FIX] hr_holidays: default date should be local to the user's timezone
Before this the following happened:

- Be in PST (UTC -8)
- Create a 1 day leave starting Jan 1 (clicking in the calendar view)

The default request_date_from is Jan 1, default request_date_to is Jan
2.

It happens because the dates are extracted from the UTC time, which in
this case are different (15:00 AM Jan 1 - 3:00 AM Jan 2).

To solve it set dates local to the user.

opw-2169863

X-original-commit: 740f39d31f2480ee7ae9cd3472b733087f1cf280
2020-02-20 01:14:02 +00:00
Nicolas Martinelli f99c2520a9 [FIX] hr_holidays: modify validated leave
- Create and validate a leave
- Go to Time Off > Everyone
- In the Gantt view, move the leave

Nothing prevents the modification of the leave while is it validated.

opw-2179839

closes odoo/odoo#44214

X-original-commit: 05257fc75211ea4b34b35c94eeb42ee5b55bfd5b
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-01-29 14:47:04 +00:00