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>
Currently the progressbar computation are not contract-aware, we fix this here
task-3777971
closesodoo/odoo#156040
Related: odoo/enterprise#57902
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
Purpose
=======
Take the last expired contract end date if there is not open contract
for the related employee.
closesodoo/odoo#156326
Taskid: 3610709
X-original-commit: c6ddecc09361cde4580242dc4f87594e78e51a57
Signed-off-by: Yannick Tivisse (yti) <yti@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>
This will add options for month, quarters and year selection to the start and end dates filters.
closesodoo/odoo#154577
Task: 3725209
X-original-commit: ac21aa953b19ba2e7bdb33b52a2616a50362d2e6
Signed-off-by: Yannick Tivisse (yti) <yti@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
Versions
--------
- 17.0+
Steps
-----
1. Go to Employees app as admin;
2. clear the "Working Hours" field & save;
3. go to Time Off app.
Issue
-----
Odoo Server Error.
Cause
-----
Commit 8f87e102a9 added the
`_get_consumed_leaves` method to `hr.employee`, which calls on
`resource.calendar` methods with `ensure_one()` active. The
`resource_calendar_id` is not a required field for employees, so an
error occurs when these methods are called on an empty record.
Solution
--------
Default to `company_id.resource_calendar_id` where a calendar is
expected.
Also fixes a potential issue in `hr_contract` when getting attendances
between a time interval that includes multiple contracts using different
calendars.
opw-3665412
closesodoo/odoo#149908
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
do not compare types, for exact checks use `is` / `is not`,
for instance checks use `isinstance()`Flake8(E721)
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
Before this commit, _get_calendar_attendances was calling
the calendar method get_work_duration_data without specifying
the company in the domain, ending up in wrong data if global
leaves that don't concern the employee are concerning the calendar.
This commit adds a domain for that method call so that only
relevent global leaves are taken into account.
closesodoo/odoo#148043
To reproduce (on runbot):
- Enable "debug" mode
- Switch to company "My Begian Company"
- Go to: Payroll / Configuration / Contracts / Template
- Create a new contract template:
* Name: Student contract template
* Salary structure: Belgian Student
* Job position: Student
- Create a new applicant for job position (Student)
- name: John Doe
- email: john@example.com
- Click "Generate Offer":
- Contract Template: Student contract template
- Click "Save"
- On the offer, click "Salary Configurator"
=> by default student has only 1 benefic in kind (regular pay) but on
the salary configurator you see many more entries listed (ex: 13th Month)
that are coming from another salary structure (Belgian Employee).
During the simulation as no employee exists (it's an applicant), a new
"temporary" employee is created and assignee to the contract; this
update the company which trigger a recomputation of the `structure_type_id`
field (since odoo/odoo@21aca4704) resetting its value to the country's
default.
This commit ensure we only reset that field when the country do change
closesodoo/odoo#147079
Signed-off-by: Sofie Gvaladze (sgv) <sgv@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 issue:
1. Create two companies, **A** and **B**.
2. Create employee *X* in **A**.
3. Create a contract, assign it to *X* and change its state to Running.
4. Duplicate *X* to create employee *Y*
5. Change *Y*'s company to **B** (bypass warnings and errors).
6. Try to access Payroll Dashboard.
7. A Multi-Company access errors is raised
Explanation:
When duplicating *X*, the value from `contract_id` is copied to *Y*.
After *Y*'s company is changed to **B**, Payroll Dashboard tries to retrieve data from its `contract_id` and, the contract still being related to **A**, a Multi-Company access error occurs.
Suggested fix:
Preventing the value being copied solves the problem. It also lines up with the `contract_ids` not being copied.
The root issue existing in *v15.0*, the fix will be implemented in that version too.
opw-3623483
closesodoo/odoo#146890
X-original-commit: 703863d86c603a4cbbd6115713cd5d49e1887a22
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Stroobant Paul (stpa) <stpa@odoo.com>
If someone wants to show the label of the state_selection field then
it can be shown
like-
<field name="xxx" widget="state_selection" options="{'hide_label': False}"/>
task-3475416
closesodoo/odoo#136901
Related: odoo/enterprise#48060
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
Change adds missing helpers and alters some of their messages
in differents parts of HR apps.
task-3522163
closesodoo/odoo#145268
X-original-commit: a2238763d4fad99da69a96104adf26b6d8eca938
Related: odoo/enterprise#52261
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
When we create public holidays, we can create global ones that will
apply to all 'Working Hours' of the company.
When you create such a public holiday, it is displayed as a an unusual
day for all employees of all companies that have a contract.
The issue comes from the the fact that we use a sudo to get the contract
of the employees and then we call '_get_unusual_day' on the Working
Hours of the contract in sudo. So when we catch the global ones (wihtout
Working Hours) it takes them from all companies as we are in sudo and it
won't apply the record rule.
closesodoo/odoo#144981
X-original-commit: 349762e28461f795d4e8bd3110556b5a80f92d49
Signed-off-by: Pierre Masereel (pim) <pim@odoo.com>
In Odoo, incoming contracts are defined as having state == 'draft' and
kanban_state == 'done'.
Currently, the employee contract calendars are synced when incoming
contracts are created, and incoming contracts' calendars are changed.
However, in many cases the incoming contracts are made for the future
and do not reflect the current employee's working schedule. This causes
there to be a calendar mismatch whenever incoming contracts are
created/updated, despite being set only for the future.
This fix checks the contracts_count field on the employee before
syncing the calendar, since the only time an incoming contract should
reflect the *current* calendar is if it's the only contract for the
employee.
closesodoo/odoo#142142
X-original-commit: 885f554c80028539415c294120c379ded33cd9ae
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
The following summary view of the record in the activity views have been
improved:
- project_task: task state added
- project_project: project manager added
- event_event: responsible and the dates (date_begin_located and
date_end_located) added
- account_move: total amount, customer and state added
- sale_order: total amount and the state added
- purchase_order: total amount and the state added
- crm_lead: customer and stage added
- hr_applicant (hr_recruitment): recruiter added
- survey_survey: responsible added
- maintenance.request: added equipment and responsible
- stock.picking: added scheduled_date
- repair.order: responsible, schedule_date and product_id added
- mrp.production: added responsible
- hr_leave (hr_holidays): status is added and default deadline modified see
below
Ensures that "Schedule activity" is in one line by adding a colspan.
hr_leave activity: When a time off approval activity is created as a
consequence of the creation of a hr.leave, the deadline of the activity is set
to the date_from of the hr.leave minus activity type delay_count (default 15)
except if it leads to a date anterior to today. In that case it is set to
today. That way, in the activity view, the time off approval activities are
more or less sorted by related hr.leave date_from and the cell date is an
indication of when the time off is planned.
Technical note: on most activity view, the activity record was not occupying
all the horizontal space. To solve that problem the css has been modified and
the max-width (200) that was imposed on the sub div has been removed. And as
it was impossible to impose a max-width for a flex div (which is the common
case for the activity record), the max width is imposed on each text that might
be too long using the class o_text_block. That class has been modified to
impose a max-width. That's why that class has been added in most view.
Alternativly, we could have modified the activity compiler to add that class
when the attribute full was set (not done because not sure of the consequence).
Task-3300854
Part-of: odoo/odoo#138135
Previously, without the payroll app, the menu item for contracts in
the employee app was not available. To improve accessibility and
user experience, the contract menu item is now kept and visible
when hr_contract module is installed.
closesodoo/odoo#133586
Related: odoo/enterprise#46541
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>