Commit Graph
81 Commits
Author SHA1 Message Date
Thomas Lefebvre (thle) f24f2d6384 [FIX] hr_work_entry_holidays: ensure the consistency of leaves
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

closes odoo/odoo#132144

X-original-commit: 249f8c836f606c0dfc5f3b6e64ad9b319b5a4602
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
2023-08-21 07:19:51 +02:00
Yannick Tivisse b9b165db7d [FIX] hr_work_entry_contract: Correctly compute work entries for edge timezones
closes odoo/odoo#124222

Related: odoo/upgrade#4699
Related: odoo/enterprise#41253
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2023-08-17 10:32:54 +02:00
Romeo Fragomeli 73e7c20573 [IMP] *,test_mail,test_mail_full: update query count
* = 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

closes odoo/odoo#127198

Related: odoo/enterprise#43577
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2023-07-19 18:24:10 +02:00
Wolfgang Taferner 945ed63bb8 [FIX] hr_work_entry_holidays: a leave can be of type other as well
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

closes odoo/odoo#128527

X-original-commit: 076d2179ad2f19c0ff8be043e492bdc7b780baef
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-07-15 12:00:42 +02:00
Martin Trigaux 2afdda2576 [I18N] *: export saas-16.3 source terms
closes odoo/odoo#123046

X-original-commit: 137f5ca0cb703ee953cb01db525362f7a778e6bd
Related: odoo/enterprise#41703
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-06-01 11:43:51 +02:00
Pierre-Yves Dufays c8b27bd3a0 [IMP] crm, hr_work_entry_holidays, test_mail{_full}: update query count
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
2023-05-10 13:21:07 +02:00
Rémy Voet (ryv) 234db70d86 [IMP] *: Use the new API of _read_group for backend use
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Kevin Baptiste efb5564fd5 [FIX] hr_work_entry: correct add item to list
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

closes odoo/odoo#117217

X-original-commit: a7914d43d7d1835a76486bb66de753b29a24dd70
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-03-31 08:50:55 +02:00
Louis Wicket (wil) 9afe7c74c9 [IMP] *: remove "French spacing" 👺
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.

closes odoo/odoo#114533

Related: odoo/enterprise#37853
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-03-14 15:52:10 +01:00
Raphael Collet e962860c6f [IMP] core: introduce search_fetch() and fetch()
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
2023-03-05 15:12:55 +01:00
Xavier BOL (xbo)andYannick Tivisse 1648c25cc9 [IMP] resource: make working schedule optional in resource model
closes odoo/odoo#110548

Related: odoo/upgrade#4248
Related: odoo/enterprise#36101
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2023-02-22 20:25:16 +01:00
Rob Coekaerts 7cd00c0702 [IMP] hr: simplify and correct the default data
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

closes odoo/odoo#112208

X-original-commit: dcc8bbf
Related: odoo/enterprise#36819
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-02-15 10:14:31 +01:00
Tommy (tong) dab107dd6e [FIX] hr_work_entry_contract: missing leave_id record on some work entries
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.

closes odoo/odoo#112641

X-original-commit: 66b65074671063e762e09589c3977dec311fc9b3
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2023-02-14 17:09:35 +01:00
Yannick Tivisse 3ee6b735fe [FIX] hr_work_entry_contract: Improve work entries generation perf 2023-02-03 10:25:00 +01:00
Yannick Tivisse 2eda54348d [IMP] resource: Add lunch attendance type
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
2023-02-03 10:25:00 +01:00
Denis Ledoux b4a7996e96 [IMP] base, *: change the API of init hooks to pass env
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
2023-02-01 10:25:01 +01:00
Kevin Baptiste 2a5b80a6d4 [IMP] hr,resource: automatically compute number of hours
- 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

closes odoo/odoo#109768

Related: odoo/enterprise#35718
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-01-26 10:16:53 +01:00
Kevin Baptiste d534bdc975 [FIX] hr_work_entry: make _error_checking faster
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

closes odoo/odoo#110987

X-original-commit: f54b7c34bc89140e2d31f0b602911ec9cda3ed0d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-01-25 17:50:14 +01:00
sofiagvaladze 93ad98bc6f [IMP] hr_holidays,hr_work_entry_holidays: change responsible_id from ma2o to m2m
task - 3060720

closes odoo/odoo#107804

Related: odoo/upgrade#4128
Related: odoo/enterprise#34926
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-01-25 17:50:05 +01:00
Thibault Delavallée 4775bd93a2 [REF] mail: cleanup post with {view, template} wrappers
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
2023-01-17 20:58:34 +01:00
Thibault Delavallée 418761e344 [LINT] mail, various: use explicit subtype in message_post_{with_...}
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
2023-01-17 20:58:33 +01:00
Thibault Delavallée 04a6b74d09 [FIX] mail, various: update query counters
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
2023-01-17 20:58:30 +01:00
Swapnesh Shah 97ec1f4ab3 [FIX] hr_holidays: correct date format on leave name
Before this Commit, dates was not formatted based on user's language.

With this commit, we use format_date to correctly format dates.

closes odoo/odoo#108442

X-original-commit: 4da7129695f2619711f08ed7c36a37543deaa31d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-12-22 10:39:28 +01:00
Dossogne Bertrand 774ca9da1a [FIX] hr_holidays: fix multiple-employee leave
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

closes odoo/odoo#103733

X-original-commit: 636a8276e6797c1d8fe43da61d2fd26b558bfa45
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-10-21 12:06:04 +02:00
Kevin Baptiste c84fba790a [IMP] hr_work_entry_holidays: add Work Entry Type to Leave Type
Adds the work entry type in the list view of the leave types.

task-3031983

closes odoo/odoo#103517

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-10-21 09:16:58 +02:00
Damien Bouvy aadf7ca9f8 [FIX] hr(_*): update for grid views
X-original-commit: ea6497a73f4e20d02d02376bf766080735d8ec52
Part-of: odoo/odoo#102508
2022-10-06 22:22:42 +02:00
Martin Trigaux 1a8772769e [I18N] *: export 16.0 source terms
closes odoo/odoo#100573

Related: odoo/enterprise#31507
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-09-20 13:48:49 +02:00
mafo-odoo 4e6e3e6261 [FIX] hr_holidays: no date_from creates error
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

closes odoo/odoo#99454

X-original-commit: 3b9a012e4a0839bc5da2daf51d56591d2863b4be
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: Fockedey Martin (mafo) <mafo@odoo.com>
2022-09-02 15:27:59 +02:00
Kevin Baptiste 1974f1a385 [FIX] hr_work_entry_holidays: bump query counter
odoo/odoo#96545 added an extra query - the query count needs to be bumped.

closes odoo/odoo#98348

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-08-18 12:24:46 +02:00
Philippe Wauthy d57aba65fa [FIX] hr_holidays: remove allocation_id on hr.leave
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

closes odoo/odoo#98317

X-original-commit: 8c37d5c7cc397e517c43c1ec13a131b4b35e48b7
Signed-off-by: phwa-odoo <phwa@odoo.com>
2022-08-18 00:23:40 +02:00
Yannick Tivisse d2291a4f90 [FIX] hr_work_entry_holidays: Fix work entry generation on company time off
closes odoo/odoo#98058

X-original-commit: 6fd3c6640c3bb15ce181b14119aec7c2d851cf1d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-08-16 09:19:24 +02:00
Fabien Pinckaers 3363e55cac [IMP] cleanup of help messages in all modules
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

closes odoo/odoo#97279

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-08-02 00:26:53 +02:00
Thibault Delavallée 40f4ea486b [UPD] various: update query counters
closes odoo/odoo#95556

Related: odoo/enterprise#29247
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-07-08 14:34:04 +02:00
Raphael ColletandVincent Schippefilt eb67feb590 [FIX] *: cache consistency
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.

closes odoo/odoo#66938

Related: odoo/enterprise#16722
Signed-off-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2022-07-05 11:35:01 +02:00
Yannick Tivisse 0d4a621e5a [IMP] hr_work_entry: Improve error message to be more user friendly
closes odoo/odoo#94885

X-original-commit: 77c0dc3eb75b568b4e6aab9bc26f6e5b5f0f8d4b
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-07-01 16:35:34 +02:00
Yannick Tivisse 4cf496a190 [FIX] hr_work_entry_holidays: Split existing leave when opening a contract
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
2022-07-01 16:35:34 +02:00
Yannick Tivisse 3f5e3b0513 [FIX] hr_work_entry_holidays: Allow overlapping leaves if same schedule
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
2022-07-01 16:35:34 +02:00
William Braeckman f38ff9754d [FIX] hr_work_entry_holidays: prevent not being able to cancel time off
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

closes odoo/odoo#94165

X-original-commit: 975ac8d2a1809bf7725d577b0fa9143a5b255e0d
Related: odoo/enterprise#28673
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-06-21 16:52:02 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
William Braeckman f51afa1ed4 [IMP] hr_work_entry_contract: prep work for multiple sources
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
2022-05-11 11:23:04 +02:00
Victor Feyens 42bad1a6d2 [IMP] *: remove useless keys from manifests
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, ...

closes odoo/odoo#90209

Related: odoo/enterprise#26807
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-05-03 13:31:16 +02:00
William Braeckman 84d8bf8167 [FIX] hr_work_entry: fix multi calendar issue with global time off
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

closes odoo/odoo#88725

X-original-commit: 0bac1d33a25e37ebece69de030b9fd72caa43a02
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2022-04-13 20:42:46 +02:00
Leonardo Pavan Rocha e0c922c82a [IMP] google_calendar, hr_holidays, hr_work_entry_holidays: update query count
In 2685472 new computed fields were added in calendar_event. This commit
updates the query counter tests that were failing.

task-2685472

closes odoo/odoo#79654

Related: odoo/upgrade#3182
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-04-01 10:36:10 +02:00
Yannick Tivisse 4807ec389b [FIX] hr_work_entry: Compute work entries duration in batch
X-original-commit: ae165f48178d89ad1b74961c7d4829f1ff5ca0c4
2022-03-30 17:04:47 +02:00
Gorash 880954ebfc [IMP] *: remove _render from ir.ui.view and simplify report
There were inconsistencies in the calls to `_render`.
* the view context could contain information that misled developers.
Indeed, the context and value of the view are not supposed to be found
in the rendering. Thus by calling `ir.qweb` with the name of the
template, we ensure that there is no unwanted information and in
addition the cache key is that of the name of the template which saves
a query.
* the context used for rendering was modified by a method on
`ir.ui.view`, except this is not information used by this model. There
is now a `_prepare_environment` method residing on `ir.qweb`. This
method allows to modify the value dictionary as well as the context in
which the rendering will be done. This preparation of the data as well
as my security check is done only once per rendering. This also saves
some queries
* Freeze options for rendering were inconsistent. It could be that
options on which rendering depends were not part of the cache key. Thus,
depending on the user who generated the generation of the rendering
function, there was or was not information in the template. For example
for automatic branding. This is no longer possible, because it is the
context that is used. The options serving as a cache key are only
recorded for information (for the profiling system for example). A
simplification of the `ir.qweb.field` models could be made.

The report rendering and call `ir.qweb` instead of `ir.ui.view`.

Part-of: odoo/odoo#85110
2022-03-29 10:56:15 +02:00
William Braeckman e8129cd0e7 [FIX] hr_holidays: fix multi company issue in days calculation
Prior to this commit, the multi company rules were bypassed due implicit
sudos (compute_sudo and self.env.user).
The function computing the number of days will now make sure to include
the right domain.

TaskId-2791030

closes odoo/odoo#86361

X-original-commit: dbcb37ec80bb0fef0115c879c15bdc7073894290
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2022-03-14 16:36:12 +00:00
Thibault Delavallée 1fb856a980 [UPD] various: update query counters (and comments)
Purpose is to update counters according to current runbot's state. This eases
checking impact of future performance improvements done.

Task-2631088 (Appointment: profile and add performance tests)

closes odoo/odoo#85838

X-original-commit: b0c7a6397526ad2698fac0701e4323c019ea8bf6
Related: odoo/enterprise#25002
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-03-07 10:41:47 +00:00
Vincent Schippefilt 05fc9a6733 [IMP] *: use _read_group instead of read_group
This commit modifies most of the usages of read_group and uses
_read_group instead. _read_group doesn't join automatically on the
many2one fields when no order_by is specified, making it more performant
when the "name" of the many2one is not relevant, which is the case for
most back-end cases

closes odoo/odoo#84908

Task-id: 2479334
Related: odoo/enterprise#24877
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-03-02 17:10:48 +00:00
Thibault Delavallée ef9429231c [IMP] various: update query counters
Notably after odoo/odoo@f9442f47eb query counters are heavily impacted
and a lot of them has lessened.

closes odoo/odoo#83832

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-02-02 18:14:54 +00:00
Rémy Voet (ryv) 5a573c6f18 [IMP] base: don't prefetch translate field by default
Issue
-----
Via the field prefetch mechanism, when we need a value of one field
(not in cache of course), the ORM will prefetch all fields
(which has the attribute to `prefetch=True`, the default value of this
attribute is `True`) for all record ids in `_prefetch_ids`.
Then, for each translate fields (where translate is not a callable)
the ORM need to make a `LEFT JOIN` on the `ir_translation` to fetch the
translated value. For big model, it leads to a simple `SELECT` with
several `LEFT JOIN` on ir_translation but each LEFT JOIN have a cost
in the planner time (a small cost in the execution time) of PostgreSQL.

By example, for `product.template` (stock/sale/purchase installed),
there are 6 LEFT JOIN to get all translated fields (5 of this
fields are rarely used).

Proposed solution
-----------------
Deactivate the prefetch by default for all translate fields expect if
this field is the `_rec_name` of the model (which is more likely to
be used).

In the example on the `product.template`:
Without prefetching the translated fields, there is only one LEFT JOIN
(the name, which is translated but is the `_rec_name` of the model).
With the 6 translated fields to fetch, the
query takes 5 ms to plan and 2 ms to execute VS with 1 translate field,
it 1 ms to plan and 1.5 ms to execute.

Side change note
----------------
- All translate of fields of `website.seo.metadata` should be prefetch
to avoid lot of website errors (it is because, website put in cache data
in sudo before reading it without sudo)
- `description` (`mail.message.subtype`), `subject` (`mail.template`),
`body_html` (`mail.template`) should be prefetch to avoid lot of extra
query from mail module.
- `vat_label` (`res.country`) should be prefetch to avoid a extra query
for each website page.
- Increase some queryCount (when it is legit, due to `subtitle` of
`blog_post` or `description` of `event.type.ticket`, etc)

task-2738029

closes odoo/odoo#82896

Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-28 14:09:56 +00:00