This error occurs when the user adds a new "Working Schedule" to the resource,
switches to the two-week calendar view, removes all the existing "Working Hours"
lines, and then attempts to add a new line under "Working Hours."
Steps to reproduce:
- Install "resource" module
- Settings -> Technical -> Resource -> Working Schedules
- New -> Switch to 2 week calendar -> Remove all "Working Hours" lines
- Click on Add a line
Traceback: ZeroDivisionError
float division by zero
This commit implements a check for the variable "number_of_days". If the value
of "number_of_days" is zero or not found, the function will return zero.
This ensures that the function behaves appropriately in cases where the number
of days is zero.
https://github.com/odoo/odoo/blob/5177e21aea68959eedc73e0034ed984992392dd7/addons/resource/models/resource_calendar.py#L185
sentry - 5108250957
closesodoo/odoo#159844
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
When we use the `|` (or) version of this rule the ORM generates two
sub-queries when checking the company. This causes sub-optimal and in
some cases really bad planning for the queries and thus PG takes hours
to complete them.
Example (formatted):
```sql
SELECT "mrp_routing_workcenter".id
FROM "mrp_routing_workcenter"
LEFT JOIN "mrp_bom" AS "mrp_routing_workcenter__bom_id"
ON "mrp_routing_workcenter"."bom_id" = "mrp_routing_workcenter__bom_id"."id"
WHERE "mrp_routing_workcenter"."workcenter_id" in (1)
AND ( ("mrp_routing_workcenter"."bom_id" in (
SELECT "mrp_bom".id
FROM "mrp_bom"
WHERE ("mrp_bom"."company_id" in (1))
)
)
OR ("mrp_routing_workcenter"."bom_id" in (
SELECT "mrp_bom".id
FROM "mrp_bom"
WHERE "mrp_bom"."company_id" IS NULL
)
)
)
ORDER BY "mrp_routing_workcenter__bom_id"."sequence",
"mrp_routing_workcenter__bom_id"."id",
"mrp_routing_workcenter"."sequence",
"mrp_routing_workcenter"."id"
```
If we use the single term version the generated query has only one
sub-query:
```sql
SELECT "mrp_routing_workcenter".id
FROM "mrp_routing_workcenter"
LEFT JOIN "mrp_bom" AS "mrp_routing_workcenter__bom_id"
ON "mrp_routing_workcenter"."bom_id" = "mrp_routing_workcenter__bom_id"."id"
WHERE "mrp_routing_workcenter"."workcenter_id" in (1)
AND ( ("mrp_routing_workcenter"."bom_id" in (
SELECT "mrp_bom".id
FROM "mrp_bom"
WHERE (("mrp_bom"."company_id" in (1))
OR ("mrp_bom"."company_id" IS NULL))
)
)
)
ORDER BY "mrp_routing_workcenter__bom_id"."sequence",
"mrp_routing_workcenter__bom_id"."id",
"mrp_routing_workcenter"."sequence",
"mrp_routing_workcenter"."id"
```
In this version PG is able to produce a better query plan resulting in
better execution times.
Also, the `company_id` field is required on some models, so the "= False" comparison is useless.
closesodoo/odoo#159123
X-original-commit: 1b5c41f36801fb886ec591f29dba42787d698526
Related: odoo/enterprise#59378
Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
Co-authored-by: Christophe Simonis <chs@odoo.com>
Steps to reproduce the issue:
- have an employee with an allocation with an end date
- remove the employee's calendar
- go on his dashboard
- his remaining leaves amount is 0
This commit implements a new method on the resource mixin to fetch a calendar
for the record even though it might not have one. The default behaviour is
to fall back on the company's calendar to ensure a value.
This is overrided in the `hr_contract` module so that the calendar of the
contract is prioritized.
task-3609738
closesodoo/odoo#155753
X-original-commit: ff58269600da857e46f83d9be94049e3f8a84294
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
For a first iteration, Russian translations were done using DeepL using
1 large .pot file of all the standard modules to translate (e.g. no
localizations, no test modules, etc). Unfortunately for some reason
doing a msgmerge with the existing ru.po files didn't seem to work, so
old "Translators" metadata at top of files were lost (maybe they will be
re-added during next Transifex sync?)
Part-of: odoo/odoo#152285
On N elements resource.calendar.leave and M elements resource.resource recordsets,
the __get__ calls to 4 leave fields were done M time per loop, aka 4*N*M times.
This commit reduces the number of call to 4*N times, reducing the method executing
time for grid_unavailability from 9 seconds to +- 4.5 on odoo.com while displaying
all timesheets on Month view.
closesodoo/odoo#150408
Related: odoo/enterprise#54830
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Currently when trying to change the company in the configuration of a working times, a traceback error occurs.
Steps to reproduce:
-------------------
* Select app ´Employees´
* Select ´Configuration´ -> ´Working Times´
* Select any
* Try changing the ´Company´ field
Why the fix:
------------
Result of [False, self.env.companies.ids]:
[False, [1]]
opw-3634123
closesodoo/odoo#148344
X-original-commit: 85bc53984b97e98ab8fe2cf966e32c0146891a88
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
Signed-off-by: Sarah Bellefroid (sbel) <sbel@odoo.com>
Steps to reproduce:
- Create Allocation for 20 days for Mitchell Admin and validate (12/01 to 12/31).
- Set Working Schedule "Standard 40 hours/week" to UTC timezone.
- Set Mitchell Admin's timezone to Europe/Zurich.
- Create a time off with type Extra Time Off with dates 12/29 - 12/29 and try to save.
- Receive Validation Error: There is no valid allocation to cover that request.
Issues:
You cannot request that leave due to a timezone mismatch, even though you should be able to.
Solution:
To solve the zone mismatch we use the employee timezone to compute the
attendance intervals.
opw-3619178
closesodoo/odoo#146938
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
Steps to Reproduce:
Create 2 companies > Create employee in 1st company > Enable both companies > Create public holidays company-wise> In company 1 create a public holiday for (13/11/2023) > In company 2 create public holidays (13/11/2023) and (29/11/2023).
Then switch to the one company (where the public holiday was created only for (13/11/2023))> Go to attendance > Configuration > Enable the count extra hours feature > Create attendance date (29/11/2023) for ex. 9 hours > Go to employee form > You may see the extra hour of "1 hour" > Because there is no public holiday on 29/11/2023.
Then enable both companies > Create attendance date (29/11/2023) for ex. 9 hours > Go to employee form > You may see the extra hours of "9 hours" > Because there is a public holiday in another company on 29/11/2023.
Bug Source:
commit 1407052 fixed the fact that public holidays are not taken into account when computing the overtime, but it doesn't cover the multi companies case.
Solution:
Verify that the public holiday company and the employee company are the same before applying the compute.
An optimization was also added to avoid searching for public holidays in db by filtering with the
employee company.
opw-3597287
closesodoo/odoo#146987
X-original-commit: 62494f5c7c80f2fafa56e397f2cd918e1a9e2648
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
----------------------Issue--------------------------
When calling get_work_duration_data on a calendar that contains adjacent calendar attendances,
we get a traceback in the method _get_attendance_intervals_days_data.
This is due to the fact that adjacent attendances (like 09:00 -> 13:00, 13:00 -> 17:00) will get merged into one single interval.
Which will generate an attendance interval with multiple resource.calendar.attendance records associated with it.
----------------Steps to reproduce-------------------
1) Create a Calendar
2) Create for a same day 2 attendances going from 09:00 to 13:00 and another going from 13:00 to 17:00 3) Try creating a time-off for that day
3) Associate that calendar with an employee
4) Try creating a time off on the day where we have adjacent attendances
---------------------Fix-----------------------------
Adapt _get_attendance_intervals_days_data to handle attendance intervals associated with multiple resource.calendar.attendance
task-3615723
closesodoo/odoo#144036
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
Issue :
- When you check-in/out on a day of time off,
all the time is logged as extra hours.
- When you do the same on a public holiday, it's not.
_leave_intervals_batch is used to get all leave for an employee but
the domain for the search only find leaves related to given ressources.
Public Holiday Leaves are not related to any specific ressources
and thus where never found.
closesodoo/odoo#142728
Task-id: 3465686
X-original-commit: 8d7100d08ecabe72dc9aedb036d7908fcd7a35bb
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
On the 'resource.calendar', attendance_ids is a computed field and
computation is triggered when company_id is changed.
Now, if we remove company_id, attendance_ids are left empty.
Instead, attendance_ids should be updated only when there is a new company set.
task - 3451264
closesodoo/odoo#141433
X-original-commit: af3bff0c578fdbd47a3584cf9e25f3e558cdefc0
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
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
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.
closesodoo/odoo#139314
Related: odoo/enterprise#49311
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
*:
- hr_holidays
- resource
- website_slides
Before this commit, the populate files for the listed modules
were calling the random python library.
As we don't want non-deterministic populate, this import has
been changed to use the odoo Random tool which allows deterministic
randomization through seeds.
This commit also changes the way populate works for leaves in hr_holidays
so that they fit the current way of defining leaves.
closesodoo/odoo#139150
Related: odoo/enterprise#49162
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Before this commit, owl was in the linter's accepted global variables.
This allowed direct access to owl global object.
For instance, to use xml from owl, you could do :
`const { xml } = owl;`
or you could use it directly:
`owl.xml`
Now, owl is not accepted on linter's global variables anymore, so to
import xml, now you need to use a proper import:
`import { xml } from "@odoo/owl";`
task-id 3498859
closesodoo/odoo#137517
Related: odoo/enterprise#48364
Related: odoo/design-themes#709
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
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
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.
closesodoo/odoo#121819
Taskid: 3251630
Related: odoo/enterprise#41257
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
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
closesodoo/odoo#131872
X-original-commit: 22c12db1f009686fa4c3861c398ba178b2785ead
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
As all the templates are now imported in the owl app, there is not need
anymore to specify the owl="1" attribute in the templates.
Part of task~3443861
Part-of: odoo/odoo#130467
-Display the state of a time off that you open from the dashboard
-Rename Stress Days into "Mandatory Days"
-My Allocations
Remove "Employee" from the Group By
Replace filter `Current Year` with `Currently Valid`.
-My Time Off
-Remove Employees from list view and kanban view
-Create an allocation / allocation request form
- Create an allocation ux : employee side- compute the name of the allocation.
- Make field `allocation_type` invisible if there is no active accrual plan in the database.
-Accruals
-Add an "archive" in the action menu of the accrual plan.
-Show Employee button in the form view of the Accrual Plan.
-Renamed stress day into the mandatory days.
-Renamed string of the menu Approval into the Management.
-Remove two legends in the time-off Dashboard
- Public Holiday
- Mandatory Day
task-3084232
closesodoo/odoo#116472
Related: odoo/enterprise#40576
Related: odoo/upgrade#4472
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
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
closesodoo/odoo#120834
Related: odoo/enterprise#40847
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>