When setting users on the appointment type as staff, we want to consider
their resource_calendar_id (work schedules) only if they correspond to the
current company and are linked to employees, not the ones linked to the users
directly. In order to display those work hours correctly, we use a new related
field on the employee_id in res_users model as it will return the employee of
the user in the current company, if any.
Therefore, we add the new field employee_resource_calendar_id directly in
hr module (in res.users model) to reduce diff and centralize the fields as
close as possible to the employee_id definition.
--- Links ---
Task-2499566
closesodoo/odoo#82234
Related: odoo/enterprise#17934
Related: odoo/upgrade#2578
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Before this commit users were not able to edit their settings if they
had a linked employee for a company that was not currently active for
them.
This is due to the fact that since the employee_ids field is considered
`safe` to read/write by your own user the fields were loaded in sudo and
thus bypassed the security rules that were meant to prevent that issue.
The security rule is now enforced as a domain on the `employee_ids`.
TaskId-2715341
closesodoo/odoo#81612
X-original-commit: b5b105eabd90419a5856e8279e277743c5915fc9
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
Before this commit, the computed field _compute_is_system make a write which
one is a bad practice and trigger a lot of others calls on res.user model.
opw-2716468
closesodoo/odoo#81555
X-original-commit: f85a67935c5dfa660e94f9bed8e8058c8df256cc
Signed-off-by: Jérémy Kersten <jke@odoo.com>
* = test_discuss_full
Overall less queries.
Changes:
- Batch `mail_partner_format`.
- Batch `user.employee_id` compute.
- Remove query for current leave state, use fields (and prefetch) instead.
- Move current leave state in partner format instead of channel info.
Part of task-2622462
closesodoo/odoo#73174
Related: odoo/enterprise#20186
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Currently, in My Profile all the users have access to language settings
even when the user does not have the rights to activate/deactivate
languages. Also, the language setting list is not user friendly which
needs to be imporved.
so in this commit hide "More Languages" button in My Profile for users
that does not have the rights and the language settings list is
improved by adding seperate buttons to "activate", "disable" and "update" a
language.
PS: groups does not work on My profile so added the compute field based
on group.
closesodoo/odoo#69292
Taskid: 2466771
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
The work location of an employee was previously a fields.Char. That was
changed to a Many2one field to a the new model called work.location.
That had some consequences in other modules that had to be slightly
adjusted. The modules impacted were hr, hr_appraisal, hr_payroll.
Task id: 2335646
closesodoo/odoo#63192
Related: odoo/enterprise#15235
Related: odoo/upgrade#2020
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Prior to this commit:
* All employees were treated the same way regarding the contractual point of vue.
From this commit on:
* Three employee types will be created:
- Employee, which is supposed to be under contract
- Student & Contractor which are both not supposed to have an employee contract (but are still use the employee as working for the company)
* Employee view and Contract History will take this consideration into account.
closesodoo/odoo#64931
Taskid: 2446000
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
The field is defined on the private address (address_home_id) of the
employee.
It would be more convenient to allow the configuration directly on the
employee view and to allow the employee to change it by himself.
closesodoo/odoo#64949
Taskid: 2410407
Related: odoo/enterprise#15918
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Purpose
=======
The goal of this commit if double:
- Prevent employees to change the m2o address_home_id, that could lead
to future inconsistencies on future HR processes
- Allow the employee to modify it own private address, even if the
access is restricted to administrators for private addresses
closesodoo/odoo#62891
Taskid: 2412387
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
The open_action_with_context was not using _for_xml_id, producing an
error when reading the action content.
In open_action, the action_name was taken from the context and needs
sanity checks. Ensure only actions from the account module can be
read and only if the user has access to the target model.
This is a limitation of the previous behaviour but, at the moment, all
known calls are made refering to an action from the account module.
Limit the scope of this method while the 14.0 is still early to avoid
having a door open to ready any action, and difficult to close later.
Remove old action fetching from the context in create_move that is no
longer used.
closesodoo/odoo#61602
X-original-commit: a39e94f7e4dc74e850650ac90bbc5f85af130bc8
Related: odoo/enterprise#14695
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Co-authored-by: Xavier Morel <xmo@odoo.com>
Purpose
=======
Some fields weren't editable, even when the option is enabled on
the settings.
closesodoo/odoo#57842
X-original-commit: 57d595e87642fa6f7bec62cbb88a39c35cc72589
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Make the method `_search` return a `Query` object, and make that object
generate a subquery when used on the right-hand side of a condition.
closesodoo/odoo#52403
Related: odoo/enterprise#10945
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
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.*
Purpose
=======
By using the user's related company to create a employee, we prevent
creating several employees for the same users on the basic flow.
But this is exactly the way we want people to use the system.
Example: Jojo is working in Belgium, has a belgian employee liked
to a belgian user in the system.
Now Jojo is about to work during 1 year in another company, based in
the USA. Jojo wants another employee, to manage the HR things
properly (payroll, ...), but he doesn't want to have 2 users, he
prefer to manage all its notifications in the same place.
We create another employee for Jojo, in the US company.
So instead of creating the employee in the user's company (Belgian),
as it would raise an error for the second employee, we should use the
contextual company instead, allowing to create the second employee
smoothly.
closesodoo/odoo#51435
X-original-commit: 0318f0acc5e98950c274c90a86a94d4588d2966d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Before this commit, Creating New Employee from User's form was taking default company from the current logged-in User instead of the User for which it Employee is being created.
With this commit, We take default company from User for which employee is created.
closesodoo/odoo#51014
X-original-commit: 9206cc4db2a8dc5a7fbc281c1574f09bfba76544
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Issue
- Install Employees
- Create a new user
- Click on "Create employee"
Traceback
Cause
In 999ced42989f, we add the user_id key but we
already have in the action_create_employee method
The key is duplicated so this is why there is a
traceback
Solution
Remove the key in action_create_employee since
we have it in _sync_user
OPW-2205354
closesodoo/odoo#46375
X-original-commit: e0c29f1a4cd8d95654963b024fd0b0e1b0578776
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
Only one employee per company and per user is allowed.
Based on the company the user is logged in, "My profile"
should redirect to the employee profile of the current
company.
If the user has no employee in the current company,
"My Profile" redirects to the simple "Preferences" screen.
Currently, it always redirects to the employee in the user's
main company (`user.company_id`)
This issue is a consequence of a5b6f31 which uses the context
to know the current company instead of `user.company_id`.
Specification
=============
Un-store the employee_id field on the res.users model.
To achieve this, we need to implement a _search method for this field.
That way, each time we try to access to the employee_id value, the
returned employee depends on the context.
Currenty if the self edit setting is deactivated, a user has to be
hr_user in order to change its employee image through the employee
profile.
The problem is that if the image on the employee is currently
not set, we should copy it through the employee profile whatever the
setting value
closesodoo/odoo#35542
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Currently, a simple user no longer see fields protected
by groups in his profile.
When retreiving the view arch, `sudo()` is used to bypass
the group protection.
But since commit 1e6c3be, `.sudo()` no longer changes the user.
Hence, groups are still checked for the simple user.
To fix the problem, the view arch should be retrieved with
a user with all groups (SUPERUSER). This assumes that
SUPERUSER has effectively all groups.
closesodoo/odoo#35486
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.
The following models are already using big images, or they might need big images
in the future:
- partner
- hr employee
- shop category
- lunch product
- gamification badge and karma rank
PR: #34925
1/ web: adapt formatDate to handle NaN values
DashboardRenderer might return NaN for `Date` or `DateTime` fields if
their original value is null or incorrect.
2/ hr: add job_title in demo data
3/ hr_recruitment: link employee in the chatter for new recruits
4/ hr: remove employee documents in the model
5/ hr_attendance: improve resiliency of relative_time
6/ hr: display manager on res_users
7/ hr: change Address Book to Employee Directory
TaskID: 2009111
closesodoo/odoo#34180
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.
Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
Purpose
=======
There are currently multiple ways to determine if an employee is presence
or absent:
- login state (user status on chat)
- checkin/checkout from the Attendance app
- leave
- hr_presence (email, ip)
Those states are displayed in several different places and can be inconsitent.
e.g. Logged in -> green in the chat
Not checked in -> red on the employee kanban view.
The multiple ways to determine employee presence described above
should be aggregated together to have a better consistency.
Specification
=============
There are 3 presence states (previously defined in module `hr_presence`),
namely `present`, `absent`, `to_define`. They are now defined as soon as
`hr` module is installed.
The state computation can have several behaviors according to which apps
are installed:
1. `hr` is installed
Check employee presence based on login by default (only for employees with
a user).
Kanban state (private and public): should be green when logged in, red when logged out and
orange when the user is away.
Private employee form: Display a stat button "Connected" on the form view
when the user is logged in or "Last Activity xx/xx/xxx" otherwise.
2. `hr_attendance` is installed:
when the user is logged out, the state
is determined from the checked in/out state. But when the user is logged in,
consider the user as present (even if he checked out).
Kanban state: green for checked in, red for checked out
Private form view: attendance stat button.
3. `hr_holidays` is installed:
Has the highest priority if the employee is on leave.
Kanban state: red if employee is on leave.
Private form view: stat button "Absent Until xx/xx/xxxx" if employee
is on leave.
4. `hr_presence` is installed:
Two additionnal presence checking option: emails sent and IP address connected.
Once a user sent an email or the IP address was connected, he is considered
present for the entire day.
There should be at most one stat button on the employee form view, with the
relevent information.
Task id: 2024482
closesodoo/odoo#34933
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
- On the HR module, the field `parent_id` is added on `res.users`.
The issue here, is that `res.users` inherits the fields from
`res.partner` where `parent_id` is already defined.
This causes issues when trying to read the parent `res.partner`.
Issue found by @rrahir
closesodoo/odoo#34059
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
- The added field `phone` on `res.users` shadow the field `phone`
inherited by `res.partner`.
The issue is that the field `phone` on `hr.employee` can be read only
by the employee or the HR team.
A lot of views tries to display the field `phone` expecting the one
declared in `res.partner` which should be readable by everyone.
But the one declared in `res.users` shadows it.
closesodoo/odoo#33569
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
General Purpose
===============
We want an 'Employee profile' gathering every data about an employee.
The main form view is modified to become this employee profile.
A user can also see his own profile through the Preferences menu.
The new profile replaces the current Preferences view if the hr module is installed
and the current user is linked to an employee.
A user should be able to see and edit his own profile.
*Problem*:
Many fields on hr.employee are protected by groups="hr.group_hr_user".
Therefore, a regular user cannot see or edit those fields.
This protection must be bypassed to allow read/write access
to the regular user's own data.
A similar mechanism already exists for res.users (for Preferences)
The better (least worst) solution found is to reuse this mechanism by adding related fields on res.users.
Pros:
- Don't change security access on hr.employee
- Don't implement yet another custom security layer, risking to add new security breaches
- A lot of fields are added by other modules on hr.employee.
It would have required to integrate them with the custom security layer.
- Fields added by other modules on the user's preferences view (normal view, not the profile)
are automatically included in the employee's profile view.
- Allow the hr.employee form view to be different than the user profile accessible
through the Preferences menu.
E.g. add custom buttons only relevant to the logged in user such as "Request a leave".
Cons:
- Each field from hr.employee that you want to appear on its profile
must be added as a related field on res.users
- Those related fields must be added to user's preferences view (duplicate views)
- They also must be added to SELF_[READABLE | WRITABLE]_FIELDS
Note:
When the front-end loads the views it gets the list of available fields
for the user (according to its access rights). Later, when the front-end wants to
populate the view with data, it only asks to read those available fields.
However, in this case, we want the user to be able to read/write its own data,
even if they are protected by groups (groups are kept on the related fields on res.users).
The front-end need to be made aware of those fields by sending all field definitions.
hr_attendance
=============
This commit integrate attendance in the new employee profile.
It also adds a stat button to this employee profile showing
the number of hours worked last month.
Remove the boolean computed field 'manual_attendance'.
This field is just a shortcut to add/remove the employee's user
in the "Manual Attendance" group.
The checkbox is confusing on the employee's form and this should
be done through the normal group management screens.
hr_presence
===========
Display the presence status on the employee kanban template.
The status is a colored chip which can be green (present),
orange (to define) or red (absent).
Currently, the presence status is only computed when accessing
the report view. As this commits displays it on the employee kanban,
it should be updated more frequently.
The state should not be updated every time the kanban view is loaded
since the computation is a bit heavy. Instead: add a cron to update
status every 15 minutes.
-> The status is accurate on the report view (status is still updated
when loading the view)
-> The status in accurate at 15 minutes on the kanban view
[ADD] hr_attendance_presence
============================
Bridge module between hr_attendance and hr_presence.
This commit integrates hr_presence module in the employee
profile and adds the presence status on the employee kanban view.
But hr_attendance adds at the same place a similar status icon for
checkin/checkout.
This bridge module makes the status from hr_presence invisible as
hr_attendance should be the main presence control mechanism.
Also, this commit adds the ability (through a new setting option)
for hr_presence to take into account checkin/checkout to determine
the presence status.
l10n_be_hr_payroll
==================
integration with employee profile
On user form view, when no employee is linked to the user, we want
to display a message to the HR Officer (only) with the possibility
to create the employee profile with prefilled information.
Task-1916925
closesodoo/odoo#29659
Signed-off-by: Jérome Maes (jem) <jem@openerp.com>
Since d77ce4c2a9, the feature of editing own employee profile was
added. It was complicated with the access rights point of view because the
hr.employee fields are protected (groups="hr.group_hr_user"). To allow editing
its own hr.employee, it was required to `sudo` the field_view_get of res.users
(as the profile form view is a res.users form view, with related field from the
employee).
- Bug
The problem is that calling `fields_view_get` as `sudo` each time breaks the `groups`
mecanism on res.users views (not only form view). For instance, adding a field
on the form view with a group will always make it visible as the `groups`check
is done in sudo mode.
- Solution
This commit tries to fix this matter but reducing the `sudo` usage to
- only form view (we don't want this to applied to every res.users view type)
- only for internal user
- only in the flow of the "self editing profile", by checking the current action
- only for the current user (avoid to get the profile of other res.users by
using the same action)
- Side effect
The `groups` mecanism is still breaking on the "my profile" form view, as the
`sudo` is still applied in that case. We might tolerate this as the view should
only be accessible for the current user.
This is not perfect at all, but cleaning that properly might involve to redevelop
this sensitive feature.
Task-1916925
Currently user name is synchronized with employee name. However it is
interesting to synchronize other fields like image, email and timezone.
Changing an user linked to an employee through the UI already updates those
fields. This commit ensure code handles synchronization like UI. When
updating an user its related employees are updated. When changing the
user linked to an employee through code all fields are also correctly
synchronized.
This commit is linked to task ID 1876795 and PR #26571.
Purpose of this commit is to improve settings by improving labels and
section titles. Purpose is to ease use of settings by users and make
it easier to understand.
This commit is linked to task ID 47221 and PR #26483.
The reified view on the res users will be dropped in the following commit.
The previous commit adds support to define each group as a computed field on the res users.
This commit defines:
- A boolean field for each 'isolated' res.group, i.e. a group in the hidden category.
- A selection field for each 'Application' res.group, i.e. a group in a application category.
Example:
- The group to manage pricelist in sales becomes a boolean field
- The groups project user/manager become a selection field
Posting on users is not supported anymore. It was implemented in a time
we thought having a twitter-like behavior in Odoo was a good idea.
Posting on users was redirected on its related partner in mail. It was
redirected on its related employee in hr. It does not make sense anymore
as employee are records with limited access and partners used for other
purpose than discussing notably in accounting.
Now that we have chat channels it makes no sense to have this kind of
behavior still implemented. Let us remove it. No functional change
should occur with this commit.
As message_post is defined on mail.thread abstract class its api.returns
is not automatically added on overridden versions of the method. This
commit add missing api.returns on all overrides of the method.
- Rewrite the code to new api without changes
business behavior
- Remove old v7 backward compatibility method
- Regroup view definitions in the same xml file
- Use read_group for computed fields