Commit Graph
183 Commits
Author SHA1 Message Date
Rob Coekaerts a9b804b1ad [IMP] resource: add duration to resource_calendar_attendance
Before this commit, conversion between worked hours and days in
resource_calendar_attendance was calculated but in reality there is no
unambigous way to do this. Eg in Belgium the morning working period is
4 hours, the one in the afternoon is 3 hours 36 minutes, while both of
them are still counted as half days.

To mediate this, the duration in days is explicitely added to
resource.calendar.attendance, with sensible default being provided
(half a day for morning and afternoon periods, 0 for lunch).

task-3131517

Part-of: odoo/odoo#133145
2023-10-24 12:38:09 +00:00
Xavier Morel 9ebbfdac73 [FIX] *: incorrect translations markings
Fixes a large number of cases where strings are translated then
formatted, instead of letting `_()` do the formatting internally,
which allows it to recover from incorrect translations (missing,
broken, or extra placeholders).

Also

- removes translation markers entirely when there's nothing to
  translate e.g. `_("%s - %s")` is not useful
- fixes a few messes which lead to only partial translatability
  (DRY is generally a bad idea when translations are involved, even
  more so when you don't make the variable part translatable)
- fixes a few nearby issues noticed at the same time
- replaces a few `"%s"` by `%r`, which should automatically quote
  strings relatively appropriately
- fixes translated strings which use `\` to escape a newline (in order
  to fill-paragraph): `\` escapes only the newline, if the
  continuation string is indented this results in a bunch of spaces
  ending in the string to translate, which is pretty garbage for the
  translator, using implicit concatenation works much better

Note: some of the updates revert f-string parameters to %, because
babel (2.9) apparently has trouble with f-strings and blows up trying
to extract them.

Not in scope:

Helping translators fix translatable strings e.g. any translation
string with more than one placeholder probably should use keyword
placeholders

- Provides more context / data to the translator to make sense of the
  sentence.
- Allows reordering the translated terms, which can be necessary
  depending on the sentence and language.

closes odoo/odoo#139314

Related: odoo/enterprise#49311
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-23 16:45:09 +00:00
Yannick Tivisse d68696e11e [IMP] hr: Make work address computed before save
closes odoo/odoo#138381

Related: odoo/enterprise#48295
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2023-10-20 09:35:14 +00:00
Rob Coekaerts 6074d86b20 [IMP] hr_holidays: refactor leave duration
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
2023-09-26 09:32:27 +00:00
luve-odoo e96fc7d3fe [IMP] project : gantt view improvements
Before this commit, the group by in the gantt view of project didn't
allow the user to find records for which there were not scheduled tasks.
For example, if a Sale Order didn't have a scheduled task, when grouping
by Sale Order, the latter was not displayed. And searching for its name
was not displaying it either.

After this commit, when a user is searching for a sale order, even if
the latter does not have any scheduled task, it is displayed in order to
facilitate the scheduling of new tasks.

In order to do so, a group expand on sale_order_id for the project.task
model have been introduced.

closes odoo/odoo#121819

Taskid: 3251630
Related: odoo/enterprise#41257
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-09-06 14:42:14 +00:00
Gorash 5419d0ef7a [REF] base,all: Update modifier syntax: clean fields keys
Part-of: odoo/odoo#104741
2023-08-18 09:49:10 +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
Thomas Lefebvre (thle) 0f08587e6c [FIX] resource: manage two weeks calendar and company creation
Steps to reproduce:
-------------------
- Go to Working Time and modify a calendar using "Switch to 2 weeks calendar"
    (not the default company calendar);
- In the Employees App settings, change the "Company Working Hours"
    to the edited calendar;
- Create a new company.

Issue:
------
We have the error: "Attendances can't overlap.".

Cause:
------
When we create a company, we will use the `_default_get` method
to get the default values for the `attendance_ids`.
So we will copy the attendances from the current company,
but we won't copy the `week_type` value.
In addition, the `two_weeks_calendar` value will be `False`.

As a result, overlaps will be checked as for a one-week calendar.
This will trigger the error.

Solution:
---------
If you want to get the current company's attendances by default,
make sure it uses a one-week calendar.
If this is not the case, we take the default (hardcoded) attendances.

Note:
-----
Since the commit 292508e8a749bf32e40995454da6122cd3c1df77,
it was no longer possible to modify a company's default calendar.
It is reverted.

With this FIX, this is now possible.

opw-3446789

closes odoo/odoo#131872

X-original-commit: 22c12db1f009686fa4c3861c398ba178b2785ead
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
2023-08-14 14:52:12 +02:00
Hugo Carlier (Huca) 6875d23647 [REF] resource: improve filter_domain_leaf performances
In some methods, like group expand methods, it is not uncommon to
transform a domain designed for model A to search records from another
model B. In general this transformation requires two operations:
- Rename some fields in the domain
- Remove leaves from the domain that relate to fields not existing in
  model B
The current function filter_domain_leaf allows to realize this second
operation. It currently relies on a recursive implementation with a
complexity of order O(n²).

This commit introduces a re-writing of the function filter_domain_leaf
that:
1. Changes the recursion based implementation to an explicit stack
   implementation
2. Introduces a field mapping dictionary as argument

The explicit stack implementation allows to avoid stack overflow when
working with long domains. The complexity order is also improved to O(n)
instead of O(n²) which leads to performance gain. For a domain length of
~100 elements, the gain (timewise) is reaching 50%. It is >95% for
domain length over 10 000 elements.

The field mapping dictionary allows to avoid pre-filtering of domains
when using filter_domain_leaf. In cases where it is used, the domain
then just has to be browsed once in the filter_domain_leaf function.

task-3299357

closes odoo/odoo#120834

Related: odoo/enterprise#40847
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-06-29 22:38:49 +02:00
Rémy Voet (ryv) c5cb357d90 [IMP] *: add dependencies to display_name field
The previous commit introduced an optimization to reduce the number of
queries and fields fetched when we call `name_search`. But it works much
better when the dependencies of `display_name` contain field names used
in the calculation (on the same record/model).

Then, to improve the performance and the cache coherency, add `depends`
and `depends_context` depending on the custom `_compute_display_name`.
Add only the first level of dependencies (never traverse relational
field) because only these have a positive impact on the previous
optimization and the cost is very low (see `modified`).
About `depends_context`, we don't include `lang` because (when `_` is
used by example) it is unlikely to get the same display_name in the same
request with two different lang.

closes odoo/odoo#122085

Related: odoo/documentation#4639
Related: odoo/enterprise#42599
Related: odoo/upgrade#4780
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-06-28 17:41:19 +02:00
Rémy Voet (ryv) 3c62ca1eb9 [REM] core: remove name_get API
Rationale
=========

Since v8, the `display_name` field is present on all models. By default,
`display_name` uses `name_get` which has pretty much the same purpose
(return record name used by the web client). Gradually, many (backend)
developers (and the ORM: https://github.com/odoo/odoo/commit/6da1c3ac4c036eac289597602976538e243cb939)
started using `display_name` (more convenient than
`record.name_get()[0][1]`) but it still had the `name_get` override.
It becomes more complex than necessary and poeple start to misunderstand
the two (and sometimes override both, leading to inconstiencies between
`display_name`/`name_get`).

To simplify the ORM and the API, we decided to keep only one of them,
the `display_name` field:
- It is much more convenient from a backend point of view
(`record.name_get()[0][1]` vs `record.display_name`)
- It is cached during the same transaction (and invalidated if
its dependencies change)
- It can be overridden like any other compute field (override
`_compute_display_name` with any extra dependencies)
- `name_get` is replaced by `read(['display_name'])`
(API perceptive), which can actually be more efficient
(if `display_name`'s depends are correct, the ORM will only fetch the
fields it needs instead of every prefetchable field)

Changes
=======

- Deprecates `name_get` for the v17 and based the method on
`display_name` (the opposite of before)
- Converts all usage of `name_get`
- Overrides of `name_get` are now overrides of `_compute_display_name`
- For `res.partner`, rename the field store `display_name` into
`complete_name` because `display_name` context-dependent and it makes
no sense to have a compute store that is context-dependent.
- Previously, it was possible to return multiple names for the same
record with `name_get`, but it was tricky and most of the usage of
this `name_get` didn't take this into account. The only example of
this is the `name_get` of `product.product`
(now use `", ".join(<names>)`).

Part-of: odoo/odoo#122085
2023-06-28 17:41:19 +02:00
paso-odoo 85ce80f029 [FIX] resource: external id not found in the system base.user_admin
If applied, this commit will solve the external id issue of the base admin user.

Before this commit:
==========================
When we delete the admin user (base.admin_user) and try to login with a new user
or try to write in a new user, this error will come.

After this commit:
===========================
The issue will be resolved after this commit and authorize new users without
any errors.

sentry - 3973828005
see - https://tinyurl.com/2jm772jm

closes odoo/odoo#118681

X-original-commit: 567027b4d4e3efdbbabab3a7a3c5e090df51dbf8
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2023-04-17 11:47:01 +02:00
Kevin Baptiste de7d7a71ea [IMP] resource: show only company's calendars
To avoid any misconfiguration, only the current companies' calendars are
shown and not all the resource.calendar.

task-3254874

closes odoo/odoo#117663

Related: odoo/enterprise#39311
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-04-13 15:26:21 +02:00
dasz e0f3dd9e01 [IMP] resource: compute date_to for better ux
date_to is set to date_from 23:59:59 when date_from is set, because 99% of the time a public holiday
is for one day. date_to can be adjusted if necessary.

task 3162355

closes odoo/odoo#115688

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-03-31 15:52:23 +02: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
Thomas Lefebvre (thle) e448962785 [FIX] resource: prevent week switch for default schedule
Steps to reproduce:
In Working Times, click on "SWITCH TO 2 WEEKS CALENDAR"
for the default calendar used by the company.

Issue:
A ValidationError appears: 'Attendances can't overlap.'

Cause:
To create a two-week schedule, by default,
we will use attendances provided for the company's default schedule.

When we want to switch from a one-week schedule to a two-week schedule,
we first delete the attendances from the schedule to be modified.
However, if this schedule is the company's default schedule,
it will no longer have the default attendances
that we must use to build the two-week schedule.

So we end up with the two "fictitious" attendances
that are used to delimit the two weeks.

With only these two attendances, the constraint of not having
two overlapping attendances is not respected
(because the two attendances created will be modified
to belong to the same week).

Solution:
Check that the calendar to be modified
is not the default calendar used by the company.

opw-3127337

closes odoo/odoo#112912

X-original-commit: 2f56ffbc2f1d3a2afbf51a859a5a5730af06fd6f
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-02-16 17:57:23 +01:00
Yannick Tivisse 394014f679 [IMP] hr_work_entry_contract: Add method to retrieve lunch intervals 2023-02-03 10:25:00 +01:00
Yannick Tivisse 7bce5f3f95 [MOV] resource: Split files according to coding guidelines 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
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
Hugo Carlier (Huca) 20b8635737 [REF] resource, project: replace the function remove_domain_leaf
The function remove_domain_leaf is currently used for project burdown
chart. Due to an increasing need of such a function in multiple modules
for various functional cases, it has been decided to:
- Move this function in 'resource' that is imported in all the modules
where this function is needed.
- Implement extensive unit test to ensure that it address corner cases.
- Refactor the function to address the corner cases it was not
addressing until now.

The refactored function 'filter_domain_leaf' is used to transform a
given domain to a new domain using only the leaves that verify a given
check (more precisely, the leaves whose first element verify this check). To perform this transformation, the leaves that do not verify
this check are considered as undetermined. All the logical operators
dealing with undetermined leaves are ignored, which means:
- AND(leaf, ?) = leaf
- OR(leaf, ?) = leaf
- AND(? , ?) = ?
- OR(?, ?) = ?
- NOT(?) = ?
If the result of the operation is undetermined, it is returned as an
empty domain ([]).

closes odoo/odoo#105470

Related: odoo/enterprise#33657
Related: odoo/upgrade#4221
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-01-16 15:43:01 +01:00
Maruan Aguerdouh (magm) 30d8cfdf0e [FIX] resource: showing only company working hours for public holidays
Stepts to reproduce:

Go to Time-off app > configuration > Public Holidays.
Try to create a new holiday and select working hours.

Issue:

It will show up all the working hours available for all companies even
if we are not in that company at the moment.

Solution:

We need to take into account the company for this field in order to only
show the working hours available for this specific company. I've added
to the field the `domain="[('company_id', 'in', [company_id, False])]"`
in order to follow the same behavior as next versions.

This issue affects 15.0 and saas-15.2

opw-3068827

closes odoo/odoo#106981

X-original-commit: 65f2861bf2728a7f9f991c47edc77fc557dfde14
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-12-01 17:32:28 +01:00
Xavier BOL (xbo) 76cf429c83 [FIX] resource: get resource progressbar for planning user
Before this commit, when the user is just a planning user without any
access to the Employees and Contracts apps. A traceback is occurred
saying the user cannot access to the `hr.contract` model.

This commit adds a `sudo` in `_get_valid_work_interval` method to get
the resource calendar of resources within a interval (the one of the
gantt view). This sudo does not give any recordset in sudo since the
`_get_calendars_validity_within_period` method return a dict with
resource_id as keys and the intervals valid according the resource
calendar for the interval.

closes odoo/odoo#106138

X-original-commit: 0bf271eb41cd1622d8ba4c1882a8ea94f1bdb463
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2022-11-21 11:50:28 +01:00
Yannick Tivisse e1c011449c [FIX] fleet,product_margin,resource: Avoid using write on compute methods
Purpose
=======

Onchange methods are executed in "edit-mode", so you need to save to get the definitive
values saved on the DB, but if you do a write on it, that changes are immediately saved
to the DB, so if you discard the changes on UI, you will have inconsistent data. That's
why you have to do update instead, that only modifies the temporary dataset.

Courtesy of https://github.com/OCA/pylint-odoo/issues/356

closes odoo/odoo#104539

Taskid: 3046426
X-original-commit: 5f18f068e62ba6cf6296c5f818b2cdfabed1fdfb
Related: odoo/enterprise#33409
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2022-10-29 12:05:55 +02:00
Dhaval BaraiyaandMahendra Barad <mba@odoo.com>, Prakash Prajapati <ppr@odoo.com> 1e48724f8b [IMP] *.*: update the tooltips in various modules
The goal of this task is to review the copywriting of the tooltips
because some of them are not correct in English and others are not
valid anymore. This is also a good opportunity to make an inventory
of the tooltips we have and to add some that could be missing.

task-2860991

closes odoo/odoo#102179

X-original-commit: 5e4cf8f9f6a4372f45aa04a5965f8073bb4ea68a
Related: odoo/enterprise#32298
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
Co-authored-by: Mahendra Barad <mba@odoo.com>, Prakash Prajapati <ppr@odoo.com>
2022-10-05 12:04:48 +02:00
MerlinGuillaume eeecb6f7c0 [FIX] resource: show planning resource in its timezone
Work hours in a planning do not respect the timezone

Steps to reproduce:
1. Set your computer timezone to 'America/New_York'
2. Install Manufacturing
3. Go to Settings > Manufacturing > Operations and enable Work Orders
4. Go to Settings > Technical > Resource > Working Times and open
   'Standard 40 hours/week' (San Francisco)
5. Edit the timezone to 'America/New_York'
6. Go to Manufacturing > Planning > Planning by Workcenter and trigger
   the day view
7. The work hours are not correct as they do not respect the timezone

Solution:
Add the timezone of the resource's calendar when computing
unavailabilities

opw-2903591

closes odoo/odoo#102066

X-original-commit: c7ac0ec29d69abdd5eda8887b6ec194db53419fd
Related: odoo/enterprise#32250
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
2022-10-04 16:01:19 +02:00
Audric Onockx (auon) 62a7c0cee1 [FIX] resource: copy default company and calendar
Prior to this fix, when a ResourceMixin was copied
and a `company_id` set in its default values,
it was not taken into account, because
ResourceMixin.copy_data first copied self.resource_id
without default values, then set the company of it
into the default values for its own copy.
Same went with `resource_calendar_id`,
just copying the calendar of its resource.

With this fix, if present, we first set these two values
in the Resource default values (`company_id` and `calendar_id`)
and only then copy them in the ResourceMixin default values
(as `company_id` and `resource_calendar_id`).

closes odoo/odoo#93823

Related: odoo/enterprise#28490
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-09-16 19:16:45 +02:00
Yannick Tivisse f88a4c39b2 [FIX] resource: Fix date/datetime comparison
closes odoo/odoo#96632

X-original-commit: 4cea2adede45e51d5911278897e068bbf0abf792
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-07-27 04:53:13 +02:00
Yannick Tivisse 2f20ec501a [FIX] resource: Allow excluding leaves on list_work_time_per_day
closes odoo/odoo#92368

Taskid: 2862737
X-original-commit: 6fbbc0b6e090ea7209d9ecf37d21f3314b06c833
Related: odoo/enterprise#27809
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-05-30 18:43:47 +02:00
William Braeckman df984fff4e [IMP] resource: improve performance of _attendance_intervals
This commit aims to improve the performance of
`_attendance_intervals_batch`.

The complexity in space has been reduced by a lot.
Prior to this commit an intervals object was generated for each resource
request.
However every resource of the same timezone will share the same ending result.
The number of calls to `localize` and `astimezone` has also been reduced
as they get quite expensive with such a high volume.

Overall we can see a 10x improvement during `test_performance_attendance_intervals_batch`

closes odoo/odoo#90933

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-05-11 16:00:34 +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 b3869ab297 [IMP] resource, hr: avoid updating resources directly after their creation
Make sure related values are correctly propagated to the
resource.resource creation, and discard the inverse update post record
creation when it doesn't change anything

closes odoo/odoo#85601

Related: odoo/enterprise#25664
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-03-29 10:56:25 +02:00
Vincent Larcin d2716b3f6c [FIX] resource: update default calendar timezone on first admin login
When the admin user logs in for the first time, their timezone can be updated based on the cookies of their browser.
In such case, the timezone of the default working calendar should be updated too.

Related: https://github.com/odoo/odoo/pull/83262/

Task 2759592

closes odoo/odoo#87061

X-original-commit: 3c56be1732d219ed69efe5f18bd7931959b7c333
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-03-25 12:40:00 +01:00
Dossogne Bertrand 2bde9ebcc3 [IMP] hr_leave: improve leave ux
Small changes in the layout of the hr_leave form view,
mainly for the manager's view point

Task : #2734842 [Time Off] ux changes

closes odoo/odoo#82976

Related: odoo/enterprise#23896
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-03-04 14:07:50 +00:00
Victor Feyens cf6855995c [IMP] resource: batch calendar resources creation
closes odoo/odoo#85532

Related: odoo/enterprise#24843
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-03-01 10:53:43 +00:00
Vincent Larcin 690ac6bfb5 [FIX] resource: use admin timezone for the default working calendar
When creating a new working calendar, its timezone is set to the one of the user creating the record.

However, when first installing the resource app, the timezone of the default working calendar is always UTC regardless of the timezone of the users.

To fix this, this commit sets the timezone of the default working calendar to the timezone of the admin instead.

Task 2744201

closes odoo/odoo#83480

X-original-commit: 2ddddd0253db402542ab6359026888acd61c2464
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-01-27 13:04:04 +00:00
Audric Onockx (auon) 2933d5eb5b [FIX] resource : compute the correct default dates when planning a shift
Steps :
- Install Planning
- Users > Mitchell Admin > Preferences > Timezone :
	Europe/Brussels
- Settings > Employees > Company Working Hours > Timezone :
	Japan
- Planning > Gantt View > Week > Mitchell Admin x Friday > Click "+" button

Issue :
- Start date is set by default to Thursday 05:00
	whereas it is expected to be set on Friday 00:00

Cause :
- When we want to plan a shift on a day,
	we look into the 00:00 to 23:59 range for this day in calendar's tz
	to get the closest work time inside of it.
- Yet, this doesn't take the "resource user" into account.

Fix :
- Set these limits for the day in resource's tz.

opw-2678221

closes odoo/odoo#82555

X-original-commit: 1b248ebd58e0a57b070ebf7d67c6da78351a720a
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-01-12 16:43:24 +00:00
Prakash Prajapati 16246f8374 [FIX] resource: fix the maximum recursion depth traceback
Maximum recursion depth traceback occurs when the resource is created from planning.
This has been fixed.

Reproducing steps:
         - Planning
         - Schedule by Resource
         - Create new Resource

The issue occurs from this commit -https://github.com/odoo/odoo/commit/18952cdc76070f2a70789f2fa25e4fa0d546d470

closes odoo/odoo#81840

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-12-23 13:14:22 +00:00
Yannick TivisseandVictor Feyens 18952cdc76 [IMP] *: Convert single create method into multi
Taskid: 2703085
Part-of: odoo/odoo#80824
Co-authored-by: Victor Feyens <vfe@odoo.com>
2021-12-14 19:13:18 +00:00
Thibault Libioulle 74624f43ee [REF] resource,hr{,_contract}: obtain calendar validity per resource
This commit adds methods to easily obtain calendar validity per resource
for a given search period and get the work intervals per resource,
taking into account the validity of their calendars.

In hr, the create and departure date of an employee are taken into
account to compute the calendars validity.

In hr_contract, it looks for every contract of human resources with
employee of type student or employee existing in the search period and
consider the specific calendar of the contract as valid during the
contract-lifetime.

PR: #77362

task-2646630
2021-11-30 12:20:47 +01:00
Thibault Libioulle 6d41b7ec7e [IMP] resource: add the false key to work intervals batch
The False key is always added in attendance and leave intervals batch
but is not added in the work_intervals batch.

To give a more smooth API, this commit aligns work_intervals behavior
with the two other methods behavior, regarding the added False key.

Furthermore, we avoid to deal with a resource_list of two empty
recordsets, in the case where the resources parameter is None or empty
recordset.

PR: #77362

task-2646630
2021-11-30 12:20:31 +01:00
Bonis ModiandKartik Chavda f4c054e473 [IMP] project, hr_timesheet, *: improve generic ux
Purpose of this commit to improve generic UX for the project app.

So, In this commit done following changes:

- add 'subtask_effective_hours' and 'total_hours_spent' fields in the page of
subtask in task form view.
- change invisible attrs to column_invisible attrs for block_by page in task
form view.
- add 'task in progress' subtype for project.task and move 'stage changed'
subtype above 'task blocked'.
- remove the 'is_close' field and all its references from project.task.type.
- unarchive all of its tasks when the user unarchives the task stage.
- sort projects on 'is_favorite'.
- internal users following the project automatically follow its updates and
their notification preferences propagated accordingly.
- duplicating a task will duplicate all of its subtasks.
- move parent task field in extra info page of task form view.
- change the label of 'edit' to 'view' in the burger menu of project kanban view.
- user can delete task without sale_order validation error.
- add constraints for 'seller_ids' field.
- add remaining_hours_so field in task tree view.
- add unusual_days in task calendar view.
- add 'no content helper' in action of burndown chart.

task-2536044

closes odoo/odoo#74018

Related: odoo/enterprise#19880
Related: odoo/upgrade#2801
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
Co-authored-by: Kartik Chavda <kcv@odoo.com>
2021-11-23 12:04:00 +00:00
Philippe Wauthy da642c06e3 [IMP] resource: allow to use _adjust_to_calendar with or without leaves
Allow to use _adjust_to_calendar with or without leaves.
This PR adds a keyword argument to the _adjust_to_calendar, _get_closest_work_time and _work_intervals_batch to include or not the employee being on leave when searching for the start and end of the shift.

task-2632775

closes odoo/odoo#79127

Related: odoo/enterprise#21944
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2021-11-12 16:34:58 +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
William Braeckman 4fbff6a9d4 [FIX] resource: fix timezone being overwritten
If no timezone is given to _attendance_intervals_batch, the timezone was
overwritten by the first resource's timezone.

TaskId-2674527

Part-of: odoo/odoo#78741
2021-10-26 13:22:27 +00:00
Philippe Wauthy fd69a22410 [IMP] resource: assign a search_range for calendar_end
Assign a search_range for calendar_end in the _adjust_to_calendar method in all conditions.
The search_range was only assigned a value if the start and end are on the same date before.

The _adjust_to_calendar method receives a start and end from midnight to midnight in the resource timezone.
Start and end datetimes can be set on a different day via the Gantt view set in month or year for example.
This commit ensures that a search_range is always assigned to find the calendar_end and not only when start and end are on the same day.
This allows to find the end of a shift searched over two days if the employee is only working one day.

Task-2628876

closes odoo/odoo#78746

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-10-26 07:47:47 +00:00
Philippe Wauthy 3708c7982e [FIX] planning: fix sorting of records in Gantt view
Steps to reproduce:
Open the gantt view and add a few shifts for different resources

Observed behavior:
https://nimb.ws/1t38Jl resources are not sorted by alphabetical order

Expected behavior:
https://nimb.ws/NqIAG3 resources should be sorted by alphabetical order

task-2633936

closes odoo/odoo#76621

X-original-commit: 9c4ed2bcadc417a2927877902c4c275e5d9d16d5
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-09-16 07:18:15 +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
jdoutreloux a8e6b57fef [IMP] resource,web : modifies the timezone_mismatch widget
This modifies the widget to allow a title option.

Task-2352428
Closes #67021

Related: odoo/upgrade#2223
Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-08-31 19:54:19 +00:00
Kevin Baptiste fe161c2105 [IMP] resource: improve resources views
Improve the UX of the different resource.resource views.

closes odoo/odoo#73822

Taskid: 2566432
Related: odoo/enterprise#19695
Related: odoo/upgrade#2649
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-08-24 10:55:22 +00:00