During a credit time period where the employee works zero hours,
the employee should still be able to take maternity leave.
Before this change this was only possible if you manually set the
duration of this leave for it to be non-zero, which was kind of a hack.
Now that durations are computed correctly automatically, maternity (and
paternity) leaves were added to the list of exceptions of leave types
that can be taken even if their duration is zero.
Part-of: odoo/odoo#119317
The idea of current date_{from,to} computations is as follows:
The user selects the request_date_{from,end} (and optionally
request_hour_{from,to} and these inputs are then processed into a
date_{to,from}, taking into account the type of leave, the work schedule
(resource_calendar) and time zone (since date_{to,from} are saved in UTC
while the request_dates are stored in the user's timezone.
However, in practice this computation is very messy, resulting in
date_{to,from} needing to be specified in all demo data and test cases,
even though it should be derived from the request dates. Various
superfluous or poorly named methods also exist in this flow
(eg _get_start_or_end_from_attendance which really performs a timezone
conversion, the logic of which resource calendar to use is scattered
across the whole model etc).
date_{to,from} are used many times as inputs throughout the code, with
code being present te inverse compute request_date_{from,to} from these
values. However in reality this is not possible to do consistently.
Therefore with this commit, we restore request_date_{from,to} as the
sole possible inputs, with date_{from,to} being derived from them. In
addition, the timezone and resource calendar are consolidated into their
own fields, with a single computation method computing them.
task-3081565
Part-of: odoo/odoo#119317
Removed this test because
1. What it was testing doesn't make sense, namely the behaviour of
resource leave creation when you explicitly set the resource
calendar id of the employee to a different one than the one on the
current running contract, which is an inconsistent state that
generates warning messages when you try to do so.
2. The test wasn't testing that correctly because it was only testing
whether two resource leaves were created, but not whether they were
actually created in the two different calendars, which was not the
case.
Part-of: odoo/odoo#119317
Update (some) query counters according to runbot state.
Also make some tests deterministic when involving company name.
Task-36879 (Mail: Support MultiCompany Aliases)
closesodoo/odoo#135288
Related: odoo/enterprise#47345
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit changes the behavior of the avatar card preview so that it
is now triggered on click instead of on hover and the previous behavior
of the click event (open chat) is therefore removed. It also adds the
functionality to the Message and Activity components of discuss so that
clicking on the avatar inside these components will also show the card.
It also makes sure that the id of the user is added to the persona even
if nothing indicates that it should.
task-3442819
closesodoo/odoo#131355
Related: odoo/enterprise#47084
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
psycopg2.extras.execute_values was introduced in PR #101237
however it pypasses the override logic for cr.execute. As a result
1. --log-sql cannot log these queries
2. assertQueryCount cannot notice these queries
...
This commit create a new api cr.execute_values to support the same SQL feature
without losing the override logic for cr.execute
closesodoo/odoo#131190
Related: odoo/enterprise#47374
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
Steps to reproduce:
- Install Attendances app and Employee app
- Setup an employee with a contract which work entry source is from
attendance
- Change the working schedule to different timezone, for example
Asia/Hong_Kong
- By default the working schedule should be start to work from 0800 to 1700
- Now create an attendance in the first day of the contract, i.e.
1st May 2023, check in time 0700, check out time 2000
- The total work hours should be 13
- However, in the work entry, the genearted work entry is 0800-2000, only
12 work hours.
Current behaviour:
The generated work entry mismatches the value of the attendance
Expected behaviour:
The work entry should match the attendance
Explanation:
This issue is casued by the timezone issue. When the system generate
the work entry, it will calculate the date_from datetime and date_to datetime.
Then it will compare between the attendance and the date_from datetime to choose
the larger datetime to put inside the work entry as start time.
However, the date_from datetime didn't consider the timezone of the working schedule.
In the above example, Asia/Hong Kong time is UTC+8 time. Therefore if we convert
the attendance time back to UTC time. It is check in time 30 April 2023, 2300 to
check out time 1 May 2023, 1200. In the mean time, if we compare between the date_from
datetime (1 May 2023, 0000) and the attendance check in time (30 April 2023, 2300).
The system will take the date_from time and therefore the generated work entry time
is incorrect.
task-3468012
closesodoo/odoo#134533
X-original-commit: 2baf4e3ebcd9ce3beb47ee2881aa3e8bd8a74cbf
Related: odoo/enterprise#47007
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
If the duration time off is greater than or equal to 1 day, then it
should be displayed as a whole day event.
Now it's not a case and can be misleading.
Moreover, this change increases querycount for the following reason:
When we create allday calendar event, on top of usual queries -
"calendar_event"."stop_date" and "calendar_event"."start_date" are read.
Note, start_date and end_date are only set for allday events.
task-3103848
closesodoo/odoo#113865
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Steps to reproduce:
-------------------
- install `hr_work_entry_holidays` module
- create an employee and add two contracts:
- from 2023-01-01 to 2023-06-30 with a full time (5/5) resource
which is expired
- from 2023-07-01 to 2023-12-31 with a partial time (4/5) resource
which is running
(doesn't work on Wednesday)
- create an allocation with 10 days
- with the employee, create two leaves:
- 3 days during the first semester with one Wednesday
- 3 days during the second semester with one Wednesday
Issue:
------
Leave duration is based on the current contract.
If we change the type of leave by modifying its days/hours unit,
we will get inconsistencies between days and hours for leave taken
in a period belonging to another contract.
Cause:
------
Expired contracts are not taken into account
when calculating the number of days and hours.
Solution:
---------
Add `close` state to contract search.
opw-3419380
closesodoo/odoo#132144
X-original-commit: 249f8c836f606c0dfc5f3b6e64ad9b319b5a4602
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
* = crm,hr_work_entry_holidays
This commit changes the value of the "QueryCount" as `mail_enterprise`
executes a new query to search for devices associated with the partner.
Task ID: 3123678
closesodoo/odoo#127198
Related: odoo/enterprise#43577
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
The previous domain fix 84d8bf8167
was skipping all potential leaves of type other left out for work entries
therefore properly inherit instead of overriding and add the proper domain
closesodoo/odoo#128527
X-original-commit: 076d2179ad2f19c0ff8be043e492bdc7b780baef
Signed-off-by: Kevin Baptiste <kba@odoo.com>
In order to display the unfollow link or not in emails or in the inbox, the
system need to query the followers of the document. This is what explains the
added queries.
See odoo/odoo#107978
Task-3061864
The fix introduced in #110559 was partially wrong, the employee ID was
not properly added to the list and would crash.
> TypeError: 'int' object is not iterable
closesodoo/odoo#117217
X-original-commit: a7914d43d7d1835a76486bb66de753b29a24dd70
Signed-off-by: Kevin Baptiste <kba@odoo.com>
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.
The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.
closesodoo/odoo#114533
Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This fulfills the goal of searching and fetching fields in a single SQL
query. We introduce the new method search_fetch() for that purpose.
Also introduce method fetch() to fetch some fields for a recordset if
they are not in cache yet.
The call graph is as follows:
search() calls search_fetch()
search_read() calls search_fetch() and _read_format()
read() calls fetch() and _read_format()
search_count() calls _search()
search_fetch() calls _search() and _fetch_query()
fetch() calls _search() and _fetch_query()
The methods _search() and _fetch_query() are usually the ones to
override to implement business-specific logic. The method _search()
returns a Query object to retrieve the records that satisfy the given
domain and are accessible for reading. The method _fetch_query() uses a
Query object to retrieve fields from the database and store them in
cache.
Also use search_fetch() to save one query in search_read() and the
reading of one2many fields.
Part-of: odoo/odoo#112126
Some changes were made to the default/demo/test data to be more
consistent:
- Duplicates of "Paid Time Off" time off types are consolidated into
one type (inluding year specific versions, ig "Paid Time Off 2019"
- Annual Time Off is renamed back to Paid Time Off (both for the
work entry type as the time off type) to be consistent everywhere.
- All mentions of years in work entry types and time off types have
been removed, as this is no longer relevant with the new allocation
rules.
- Time off types in the default data have been explicitely made
company agnostic, in order for them to be available to all companies
and not just the one company that was select when installing
hr_holidays. This was already the case for the be_payroll data, but
not for the standard hr_holidays ones.
- Various small cosmetic / functional fixes and simplifications
(eg deduplication of data)
- expense_other_input has been made country agnostic, in order for it
to be available in all countries.
task-2978513
closesodoo/odoo#112208
X-original-commit: dcc8bbf
Related: odoo/enterprise#36819
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Steps to reproduce:
- Add a pubic holiday record, i.e., From 6 Feb 2023 to 7 Feb 2023
- Add a leave with the date conflicting the public holiday, i.e. From
3 Feb 2023 to 8 Feb 2023
- Regenrate the work entries and check the work entry in form view.
Current behaviour:
Missing leave_id on some work entries
Expected behaviour:
It should linked to the corresponding leave for the work entries that is
created by the leave, while public holiday work entries should keep leave_id
empty.
Explanation:
After calling contract._get_interval_leave_work_entry_type, the leaves should
be filted out the not related leaves so contract._get_more_vals_leave_interval
can get the correct vals. Otherwise public holiday will always return
{'leave_id': false} in contract._get_more_vals_leave_interval which will replace
the correct leave_id value.
closesodoo/odoo#112641
X-original-commit: 66b65074671063e762e09589c3977dec311fc9b3
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Purpose
=======
Add a new type on the working schedule, adding "Lunch" to Morning and Afternoon. It's mandatory,
because, if you don't do that, you can't assume the difference between a time that should be
recorded as extra hours and a time that should not be counted because it's lunch time.
A company is not another, so to be clear, they will define what are the imposed lunch time
where the employee is not paid during the week.
Specification
=============
Lunch between Morning and Afternoon
When a time period is under Lunch :
- There is no working entry generated for that period of time.
- If you work before the lunch time and after it, it's not considered as extra time.
- The employee is not paid for the Lunch time.
TaskID: 3102363
This is mostly a cleaning/refactoring change.
The current API for init hooks (pre, post, uninstall) is to pass
`cr, registry`.
But the first thing which was done by most
post init and uninstall hooks was to create an env using
the cr passed
e.g.
`env = api.Environment(cr, SUPERUSER_ID, {})`
and the `registry` argument was unused in all these hooks,
completely.
By changing the API of hooks to pass `env` instead
of `cr, registry`, we gain in average two lines in every
hooks:
- the line creating the env `env = api.Environment(cr, SUPERUSER_ID, {})`
- the line importing `api` and `SUPERUSER_ID`
Therefore removing ~250 lines of repeated code lines accross odoo/odoo and
odoo/enterprise.
In addition to these lines removed,
it also ease the API of init hooks for Odoo developers,
who are used to that `env` and not so much how to create an `env`
from a cursor.
Part-of: odoo/odoo#108254
- Automatically compute the average number of hours per day on
resource.calendar;
- Don't allow to change the working hours of an employee when they have
a current running contract;
- Seperate smart buttons on resources to distinguish Material / Human.
task-3102517
closesodoo/odoo#109768
Related: odoo/enterprise#35718
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Calls to `_error_checking()` would look for every work entries between 2
dates, even if we were only modifying one employee's.
Because of that the leave creation on big production database would take
a long time.
Now the method allows for filtering to the employees.
task-3142610
closesodoo/odoo#110987
X-original-commit: f54b7c34bc89140e2d31f0b602911ec9cda3ed0d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
RATIONALE
Purpose of this commit is to cleanup main post helpers and have a more easy
and understandable way of calling them.
SUMMARY
We now have two main API methods, based on business flow: either posting
on documents, either sending a mass mailing. Indeed those two flows are
different
* post: create message, then launch notification process by taking into
account subtype, followers, ...
* mail: create mails in batch with recipients being based on template or
given partners. No notifications is involved, only maybe traces if a
mass mailing is linked
Delegate QWeb rendering to the render mixin (i.e. _render_template_qweb_view)
in order to have a single point to forge evaluation context and re-use
existing rendering code.
SPECIFICATIONS
Main API helpers are now
* ``message_post_with_source``: (batch) post on records, using an ir.ui.view
(given a record or its xml id) or a mail.template record (given a record or
its xml id). When using a template, a composer is called to post on each
record (as batch post is not yet supported). When using a view, a direct
call to message_post using the rendered bodies is done, one record at a
time.
* ``message_mail_with_source``: send a mass mailing on records, acting like
invoking the mail composer in mass mode. Same arguments are valid, either
a reference to a view, either a reference to a mail template.
Other helpers are
* ``_message_log_with_view``: (batch) log on records, using an ir.ui.view
to render the body using QWeb (no notification process);
* ``_message_log(_batch)``: (batch) log on records (no notification process);
* ``message_notify``: notify partners on records (creating notifications
specifically for some people while message itself is not displayed in
chatter);
Code migration
* ``message_post_with_template`` in "mass mode": use ``message_mail_with_source``
and set the template record as source;
* ``message_post_with_template`` in "comment" mode: use ``message_post_with_source``
and set the template record as source;
* ``message_post_with_view``: its main usage was to post on a document, in which
case it generally can be replaced by ``message_mail_with_source`` using
the view reference as source;
Task-2710804 (Mail: Clean MailThread Posting API)
Part-of: odoo/odoo#99482
RATIONALE
Purpose of this commit is to be explicit in subtype chosen when invoking the
message composer / calling message_post. As default value may not always be
clear, better be explicit in case the composer default value changes.
SPECIFICATIONS
Add explicit references to subtype when it is not obvious what will be the
final subtype, notably when using helpers (post_with_view or template which
uses the composer that is not crystal clear in its subtype management).
In this commit we also add support of XMLID-based subtype when invoking the
composer. A ``default_subtype_xmlid`` context key is transformed into a
``default_subtype_id``, to be used notably in JS where we cannot easily
use a ``ref``-like statement. Post API now also supports 'subytpe_xmlid'
argument allowing to give the xml id and ease calling the methods.
Use ``_xmlid_to_res_id`` to get directly the ID of subtypes in order to
avoid useless queries from ``ref`` that does an exists.
Also remove useless values given to post API, notably author_id that is by
default the current users' partner.
Task-2710804 (Mail: Clean MailThread Posting API)
Part-of: odoo/odoo#99482
Update counters according to latest runbot counters. It allows to better spot
side effects of upcoming changes.
Task-2710804 (Mail: Clean MailThread Posting API)
Part-of: odoo/odoo#99482
Before this Commit, dates was not formatted based on user's language.
With this commit, we use format_date to correctly format dates.
closesodoo/odoo#108442
X-original-commit: 4da7129695f2619711f08ed7c36a37543deaa31d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Before this commit, creating a leave for multiple employees
from the manager's page allowed to create leaves regardless
of the concerned employee's allocations.
After this commit, an error message will be displayed to inform
which employee cannot take that leave.
Also removes unused imports.
task-2995120
closesodoo/odoo#103733
X-original-commit: 636a8276e6797c1d8fe43da61d2fd26b558bfa45
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Probem:
With some time off type as default type in an allocation request
you get a traceback as soon as you try to open the allocation
request form.
Cause:
FIX commit [1] introduced the issue as it didn't consider the
possibility of a false date_from
Improvement 1:
Having a date_from False sets a False in the leave request name
displayed on the form, we change that to have an empty string
instead
Improvement 2:
The timezone bug fix in commit [1] is only applied on a specific
configuration, we applie it to all configuration of leave request
name
[1] 5a50dea2652cff014d9198f59265cf36a3ec1865
opw-2961344
closesodoo/odoo#99454
X-original-commit: 3b9a012e4a0839bc5da2daf51d56591d2863b4be
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: Fockedey Martin (mafo) <mafo@odoo.com>
As part of hr_holidays B2B, the holidays allowances were moved from hr_leave_type to hr_leave_allocation.
This didn't allow to take a leave longer than the maximum duration of an allocation. Also, despite all the
allocations could have enough days for a certain leave, it was not possible to use all available days without
splitting the leaves across the different allocations.
This commit moves the holidays allowance to the hr_leave_type to remediate the issues described above.
task-2834887
closesodoo/odoo#98317
X-original-commit: 8c37d5c7cc397e517c43c1ec13a131b4b35e48b7
Signed-off-by: phwa-odoo <phwa@odoo.com>
This commit aims at removing unuseful help message to:
1/ reduce translators work, to focus on more useful translations
2/ not sending unuseful information in load_views
3/ reduce help message to useful messages, so that we can mark
fields having a tooltip in the future UI.
4/ some cleanup of existing messages too
The main use cases:
- REMOVED: help redundant with the field name, providing no extra info
- MOVED TO COMMENT: technical help messages, that should not be in UX
closesodoo/odoo#97279
Signed-off-by: Fabien Pinckaers <fp@odoo.com>
In module mail, invalidating 'message_ids' on a mail thread also
invalidates its inverse field 'res_id' on messages. If you haven't
flushed it before, your cache will be inconsistent, as shown by the test
/mail:TestMailgateway.test_message_process_bounce_records_channel.
In module purchase_stock, add depends on report.stock.quantity. This
ensures that when the model is queried after changes in other models,
the data on which the SQL view depends is flushed to the database before
querying that model's table.
closesodoo/odoo#66938
Related: odoo/enterprise#16722
Signed-off-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Purpose
=======
Currenlty an error is raise saying that a leave cannot be set accross
overlapping contracts.
But in this special case we could split the time off and allow this simple
action.
Taskid: 2836901
X-original-commit: 1012a7ea8033675b6ebab96922e124b04e5ed884
Part-of: odoo/odoo#94885
Purpose
=======
We currently prevent leaves overlapping several contracts to avoid messing
with the generated resource.calendar.leave.
In case the contracts are on the same resource calendar, this shouldn't be
an issue actually.
Taskid: 2836901
X-original-commit: 4e87c30bb136083153091e67e6dd9d9f64fa94c2
Part-of: odoo/odoo#94885
Prior to this commit if work entries/payroll was installed you could not
cancel a time off in the future if the work entries were generated for
that period, however you should still be able to cancel a time off as
long as the work entries have not been validated yet.
TaskId-2791386
closesodoo/odoo#94165
X-original-commit: 975ac8d2a1809bf7725d577b0fa9143a5b255e0d
Related: odoo/enterprise#28673
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Prep work to allow work entries to be created from multiple sources when
using contracts.
The end goal is to be able to generate work entries from attendance as
well as the planning app.
After that the plan is to make sure the implementation works well with
payroll for hourly wages.
This commit contains the necessary changes for the next work_entry
modules to work.
TaskId-2466871
Remove most values uselessly specified because giving the same value as
the default one (see _DEFAULT_MANIFEST in odoo/modules/module.py)
* auto_install is Falsy by default
* author is Odoo SA by default
* summary & description are empty strings by default
* application is False by default
* test, demo, depends and data are empty lists by default
This will reduce noise/inconsistencies between manifests specifications,
simplify analysis of manifests content, ...
closesodoo/odoo#90209
Related: odoo/enterprise#26807
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
When creating a global time off in one resource.calendar A , it will be
propagated on any new resource.calendar B.
However the reverse is not true, if I delete the global time off in
calendar A it will not be deleted in calendar B.
During the work entry generation this is not taken into account, a
contract using calendar A will generate leave work entries because of
the global time off in calendar B.
This is due to a change in PR odoo/enterprise#15091.
The domain is now correct and will only fetch the right leaves.
TaskId-2627378
closesodoo/odoo#88725
X-original-commit: 0bac1d33a25e37ebece69de030b9fd72caa43a02
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>