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>
Users and employees can now define their usual worklocation
for a day of the week aswell as define unusual ones from the
calendar app. The worklocation is then displayed in the calendar
in two different ways: when only one person is selected, there
is a circle with an icon in it, and a ray that extends to the right
if the person is at the same location for multiple days. If there
are multiple persons selected there is no ray, instead the circles
are grouped by location type and colored accordingly to the filters
in the left panel.
closesodoo/odoo#129585
Task: 3060685
X-original-commit: c74ac3f698d4ea4c9b7a5e060fba4cf77cc9a6d7
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Co-authored-by: dasz <dasz@odoo.com>
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.
closesodoo/odoo#122085
Related: odoo/documentation#4639
Related: odoo/enterprise#42599
Related: odoo/upgrade#4780
Signed-off-by: Raphael Collet <rco@odoo.com>
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
This traceback raises when user not selected 'Employee' and only selecting
'Check In' and 'Check Out', while creating a new attendance.
To reproduce the issue:
1) Install hr_attendance
2) Open Attendance and create a new record
3) Give values to only 'Check In' and 'Check Out'
Error: "AttributeError: 'bool' object has no attribute 'upper'" appears.
On '_compute_worked_hours' method calendar variable is getting value from
employee_id and that calendar timezone is used to get timezone.
https://github.com/odoo/odoo/blob/937d207028ab9bc1d3d332dc6dfe25f0de045026/addons/hr_attendance/models/hr_attendance.py#L50-L60
Therefore in the above use case, when triggering the compute method,
because of 'calendar' is depending on 'employee_id' and when
employee is not selected, it will leads to the above traceback.
Sentry-4274226351
closesodoo/odoo#126465
X-original-commit: 31491e40d2505c03d76e6c802435ad1dafa71c52
Signed-off-by: Kevin Baptiste <kba@odoo.com>
As the leave is deducted from the needed time to work
in case for example Home Office which is configured as
working time (other) is handled like a real leave (absence)
which will lead to an extensive overtime instead the difference
to the work entry defining the work time.
A domain clearing out this missing link and variation
cleans up this misalignment and therefore overtime will
be computed correctly.
closesodoo/odoo#126373
X-original-commit: 02a679d6ab7db49c8338471e5fc85c1141f8e877
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: Wolfgang Taferner <w.taferner@wtioit.at>
Employee presence is not a sensitive data and should be available for all db users
this commit moves the computations from attendance, holidays and hr_presence to the
employee_base model, which is how it was originaly made in the hr module. This way
the presence marker does not depend on the user's hr rights
closesodoo/odoo#118437
Task: 3267790
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Issue:
A user has write access rights to modify his own attendances.
However, he can modify the `employee_id` field.
This can cause attendances to be moved to other employees.
opw-3280850
closesodoo/odoo#120632
X-original-commit: 1c25a9b964e9e2acf9d431897e83cf72ecdca1cb
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: Lefebvre Thomas (thle) <thle@odoo.com>
Remove lunch hours from work intervals so that overtime is not calculated when it's not due
tests adapted to take into account lunch period
task 3217799
closesodoo/odoo#120455
X-original-commit: 97c052432a25a1461de23fd8ab0c73ffe9b084ff
Related: odoo/enterprise#40677
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Fixes a situation where users who are part of the Attendances Officer (or Manager) group but
without access to private employee data would see the following error when trying to book time
off.
`ValueError: Invalid field 'last_check_in' on model 'hr.employee.public'`
Other instances of the same ValueError were observed by managers trying to approve employee leave
and employee expenses.
As per hr/models/hr_employee.py:22-26 fields not available on hr.employee.public should have
groups='hr.group_hr_user' and this was not the case in hr_attendance.
closesodoo/odoo#120324
X-original-commit: ff4e7d6a414097d000e62825cf43425ea14bd77e
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Enforce strict types for returned values for
* create
* write
* unlink
* default_get
to make those methods more consistent and reliable.
Also make sure they can be called with empty self/values,
i.e. that they follow the same behavior as the base methods
defined in the main orm Model.
closesodoo/odoo#116809
Related: odoo/enterprise#38880
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
The function write must return True when it ends.
opw:3121809
closesodoo/odoo#109713
X-original-commit: 6adeabf6445c72e7ddfd540ceaea8c01473e062d
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Simon Goffin <sig@odoo.com>
*: base, account, crm, hr, hr_attendance, test_access_rights
The various public methods of the ORM can be override in other models,
those overrides sometime don't implement the exact same signature as the
original method in the ORM. In this work we sanitize all the overrides
to ensure a better compatibility. The background objective is to make it
possible to call any public method using kwarg: `search(domain=[...])`.
* `search`, the first parameter was renamed from `args` to `domain` in
0e9adf7 but the overrides were not updated.
* `invalidate_models` and `invalidate_recordset`, a new `flush=True`
parameter was introduced in 9c3b9a4 but the overrides were not
updated.
* `update`, there is a clash between the `update` method responsible for
writing on a record and `update` in bus responsible to update the user
presence. The bus method has been renamed so it doesn't clash with the
ORM.
This sanitization comes with a new linter that verifies that all
overrides of BaseModel public methods share a compatible signature. The
linter has been disabled for `create`, `write` and `default_get` as too
many overrides don't respect the signature of BaseModel.
closesodoo/odoo#106999
Related: odoo/enterprise#34991
Signed-off-by: Julien Castiaux <juc@odoo.com>
1/ When approving / refusing a leave spanning multiple days, the
overtimes were only recomputed for the starting date and not the
whole period.
2/ Overtimes should be computed whatever the kind of time off that's
been taken (Absence or Other).
task-3073155
closesodoo/odoo#106751
X-original-commit: 116d7cb46132404354e00e67a2364b8239fcdce5
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Add new settings to allow the user to select which camera to use for the
barcode scanner and to allow/disallow the manual identification of
employees.
task-2973809
closesodoo/odoo#99622
Related: odoo/enterprise#31082
Signed-off-by: Kevin Baptiste <kba@odoo.com>
The icon that is displayed in the employee kanban view is determined by the
field hr_icon_display, computed in the method _compute_hr_icon_display. This
method is overridden in multiple modules such as hr_holidays, hr_attendance
and hr_homeworking.
Currently this field has a state to show no icon (presence_undetermined). In
this change this state is extracted into the a separate field
show_hr_icon_display with the default state of hr_icon_display being
presence_to_define. In this way a module such as hr_attendance, which only
overrides _compute_hr_icon_display to show the default icon for everyone as a
default, now only needs to change this separate field and does not need any
knowledge of what other states exist. This reduces coupling between modules.
Revision 7fd7422647
takes care to prevent employees to modify manually their attendances,
by removing the edit button from the attendance list.
This is only visual, this doesn't actually
prevent users to change their attendances,
for instance through XMLRPC.
Besides, with the group comment:
```xml
<record id="group_hr_attendance" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="base.module_category_human_resources_attendances"/>
<field name="comment">The user will gain access to the human resources attendance menu, enabling him to manage his own attendance.</field>
</record>
```
To me:
- Employees should be able to sign in and sign out only
- Attendance users should be able to modify their own attendances only
- Attendance managers can modify attendances of anybody.
Hence, instead of removing the edit button on the view,
change the ACLs so employees do not have the rights to modify their
attendances at all.
Part-of: odoo/odoo#98551
To Reporduce
=============
1. Create employee with Standard Working Schedule (100% presence / 40 hours / 08:00 - 12:00 & 13:00 - 17:00)
2. Create Time off type: Paid time off with following settings:
- Take time off in: Hours
- Deduct Extra Hours: No
3. Create a time off request for half a day for this employee (8/17/2022; morning)
4. Approve Time Off Request
5. Create an attendance record for this employee for the afternoon on this day (13:00 - 17:00)
Problem
=======
On the attendance report, this employee has -4:00 Extra Hours, which means that the leave wasn't taken into
account when computing Extra Hours
Solution
=========
to solve the issue we take into account the Employee's leaves when computing Extra Hours
opw-2956895
closesodoo/odoo#98969
X-original-commit: 3da24993f5ad6d7b56ee332589ff822eac8ada5c
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit aims at removing unuseful help message to:
1/ reduce translators work, to focus on more useful translations
2/ not sending unuseful information in load_views
3/ reduce help message to useful messages, so that we can mark
fields having a tooltip in the future UI.
4/ some cleanup of existing messages too
The main use cases:
- REMOVED: help redundant with the field name, providing no extra info
- MOVED TO COMMENT: technical help messages, that should not be in UX
closesodoo/odoo#97279
Signed-off-by: Fabien Pinckaers <fp@odoo.com>
Reproduction:
1. Install Attendance app
2. Create a new internal user “kiosk”, with only access right “Kiosk
Attendance” for app “Employee”, other places as blank
3. Make sure the Settings for Attendance app, Employee PIN is unchecked
4. In an incognito tab, log in as kiosk, go to Attendance, click “kiosk
mode”, then “identify manually”
5. Choose an employee, with a warning message “Wrong pin”
Reason: A recent update refined the user group check for the
attendance_manual function. Checking if the user is an officer in the
Attendance app can be over strict. However, after discussing with yti,
we decided to pop up a warning message for security reasons when the
user would like to use Kiosk mode without pin code.
Fix: Add a warning message for higher access right requirement
opw-2898452
Related fix in V15: https://github.com/odoo-dev/odoo/commit/2975c0539d8c2781ff56a9f8be8e302d45b7d80bclosesodoo/odoo#96230
X-original-commit: 82f2966ed5b3afd30ac5b18c32af7993746fc681
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
The kanban view was recently improved to add the support of 'action' and
'type' attributes on the kanban arch. This commit takes advantage of
that change to simplify a few views in various addons.
Part-of: odoo/odoo#92071
Purpose
=======
Several actions are done even if nothing has changed on the configuration.
Example:
Writing on a cron the same value makes a dummy write-lock on the table
...
Part-of: odoo/odoo#82999
Since the Time Off B2B, the deduct extra hours didn't work anymore due
to an invalid domain.
This commit fixes the traceback but also the behaviour as the domain did
not make any sense anymore.
Also changes the default order for overtime records.
TaskId-2658077
X-original-commit: 13c57cdb3b797e56a164e5049b9f9d799ad127c9
Part-of: odoo/odoo#79498
Improves on the display when closing an attendance to display today's
overtime aswell as the total overtime the employee has.
Also small cleanup, remove unused variable.
TaskId-2655689
closesodoo/odoo#77841
Signed-off-by: Kevin Baptiste <kba@odoo.com>
When computing the overtime hours we use localized datetimes in order as
much as possible but we were localizing UTC datetimes to the wrong
timezones without converting them first which caused issues with company
thresholds.
Task ID: 2607436
closesodoo/odoo#74241
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Previously the default time off type computed when pressing the deduct
extra hours button would not always be valid, this commits aims to
change that behaviour.
The form would also not recognize the fact that we are in a overtime
deductible context when the time off type was not bound to a company.
Task ID: 2607436
`attendance_state`, `hours_today` and `last_attendnace_id` are required
to open up the attendance app, but were not available to the public user
since commit b429fce0e6
Task ID: 2607436
Fixes minor problems encountered while doing task : 2607436.
A traceback when disabling the setting and the checks weren't disabled
if the option was completely disabled.
Task ID: 2607436
This commit adds a new model `hr.attendance.overtime`.
When an employee checks out, an overtime entry will be created when:
- the option is enabled on the company;
- the employee worked more or less than the number of hours they
were supposed to work that day.
TaskID: 1904850
Steps to reproduce the bug:
- Go to Attendances > Manager > Attendances
- Remove Check in value of an hr.attendance record A
- Set Check out to A
Bug:
A traceback was raised
opw:2513143
closesodoo/odoo#70088
X-original-commit: c462782f66d720266e7e8e7f616fc26c23f009c8
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Users with the rights 'Manual Attendance' get (read-only) access to their
own attendances.
closesodoo/odoo#66934
Taskid: 2438863
Related: odoo/upgrade#2216
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Currently, when you create a employee when hr_aattance is installed
then it will create traceback due to falder timiezone
so in this commit, Fix the issue and if timezone is not set on
employee then pass the 'UTC'
TaskID: 2283753
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.
Add sudo for other operations on ir.actions.*
Before this Commit, Datetime on warning was not formatted based on User's lang.
With this commit, we use `format_datetime` to correctly format Datetime.
X-original-commit: b1bc2ba4a986bf7bce242496f822f9891937c9cf
Make the employee presence icons more descriptive.
Allow to quickly filter the Presence Reports based on the user status.
closesodoo/odoo#54527
Taskid: 2246447
Related: odoo/upgrade#1488
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Issue
- Attendances > Manager > Attendances
- Create a line for any employee
check-in 30/04/2020 12PM
check out 01/05/2020 12PM
- Go to Employees > the employee
Last month worked hours = 0
but it should be 12
Cause
We only take into account records
checked_out the previous month
Solution
Rethink the whole method to
take into account records
checked_in last month and
checked_out this month
And adding timezone handling
OPW-2259533
closesodoo/odoo#51919
X-original-commit: 7918cccf0c6e28c25e909b1355eb7fda5373edb2
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
Lable for the field `barcode` is `Badge ID`.
With this commit, We display the correct field name in the Warning.
closesodoo/odoo#50700
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
The user for the kiosk mode must have access to personal information of
the employees. To avoid easily leaking information, prevent grouping.
Fixes#34231
opw-2079330
closesodoo/odoo#38120
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
hr:
-rename btn 'generate badge ID' to 'generate'
-When the badge ID is set, replace the button Generate by "Print Badge"
hr_attendance:
-Rename menu 'Manage Attendances' to "Manager"
-Add a column "Work Hours" to attendee tree view
-Add a <br> after "Welcome to"
-add class text-muted on "or"
-remove class "text-muted" on "scan your badge
-Rename the primary btn into "Identify Manually"
Task-2040884
Closes: #35473
Signed-off-by: Romain Libert (rli) <rli@odoo.com>
The `private_email`, `last_check_in` and `last_check_in`
fields were added by e9d9898 to the
profile view but not in `SELF_READABLE_FIELDS`.
A simple user was therefore not able to read the field and
access his profile.
To avoid any similar oversight in the future, a test is added
to ensure a simple user is able to read all fields in
the profile view.