Commit Graph
68 Commits
Author SHA1 Message Date
Yannick Tivisse d0e2d1365c [IMP] hr: Expose Social Security Number of employee forms
Part-of: odoo/odoo#124222
2023-08-17 10:32:50 +02:00
william-andre 0479b2b594 [IMP] account,*: manage subsidiary companies
Allow sharing records between company
* accounts
* taxes
* fiscal positions
* products
* ...and some related models

These records can be read and used in children companies.

This can be used to
* have different branding for different businesses
* allow more complex security rules
* consolidate branches differently
* manage different tax reports with different tax ids in the same
  country

task-3371677

closes odoo/odoo#125642

Related: odoo/enterprise#43215
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-07-20 11:49:06 +02:00
Yannick Tivisse e8c48f824e [IMP] hr: Remove address_home_id field
Improve usability of employee form. It is confusing for end users
to create another record to encode the employee address.

Move all the private information on the hr.employee record itself.

Remove the M2O address_home_id.

TaskID: 3101400
2023-07-05 14:21:28 +02:00
Kevin Baptiste 58b77d5b8a [FIX] hr: open correct employee view from settings
Clicking on the 'Employee' smartbutton on a res.users form view would
lead to a traceback if the user was not part of HR Officer.

task-3279347

closes odoo/odoo#120804

X-original-commit: b5fc8a4bacdf2964f71f2ad5c7d0c6ac30a4a9b5
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-05-09 06:07:53 +02:00
dasz 8451eabb67 [IMP] hr: focus employee smart button on main flow
The current smartbutton is Employee(s) and it redirects to kanban view by default, no matter how many
employees a user / partner has. 9 out of 10 times a user / partner only has one linked employee, this
change renames the label to 'Employee' and redirects to the form view if there is only one employee
if there are more, the previous action is called

linked upgrade: odoo/upgrade#4363
this closes odoo/odoo#111439

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-03-07 18:02:37 +01:00
Martin Trigaux 93af90cc1d [IMP] hr: better log message
Before this commit the message was only containing a message 'Personal
information update.' but it was not clear why the person was receiving
this message nor why he was receiving it.

closes odoo/odoo#113550

X-original-commit: de0061326bbd9e2fc5319c05448395afa5b71afe
Related: odoo/enterprise#37492
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-02-24 08:12:04 +01:00
Jeremy Kersten 7ce1c614ae [FIX] hr, hr_holidays: avoid useless write on res.group or res.users
hr_holidays:
Portal user don't have responsibles group by default. But on each new
portal user we call the `_clean_leave_responsible_users` and make useless
write on res.groups.
After this commit, we only call it if at least one user (of self) have
the group to be removed.
If a user has the group, now we remove the group from the user, instead
to remove the user from the group; it reduces the risk of concurrent
update, and have more readable log.

hr:
Avoid writing on employee model if no employees match the current user.
Calling write on empty recordset call all the override for no reason.
In the case e.g. of the first connection of a portal, the tz will be set
on the res.users which will trigger all the overrides of write (including
the _clean_leave_responsible_users which update group for nothing before
this commit), while we have no employees linked to this portal user).

closes odoo/odoo#111870

X-original-commit: d8d74e6247c359e94584014adb9aeda7179f6f96
Signed-off-by: Jérémy Kersten <jke@odoo.com>
2023-02-03 16:32:37 +01:00
Yannick Tivisse 18dacd13d9 [IMP] hr: Notify HR officers on personal info update
Purpose
=======

Notify HR when an employee changes their own info and check that everything is logged on the chatter

closes odoo/odoo#102069

Taskid: 3029662
Related: odoo/enterprise#32253
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-10-31 11:41:54 +01:00
sofiagvaladze 39c14368a2 [FIX] hr: hide create_employee on create user form
Set the default value for create_employee to False.

When coming from employee form, hide the create_employee field.

task - 2990426

closes odoo/odoo#100661

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-10-03 17:18:18 +02:00
Kevin Baptiste 980a9f0cd6 [FIX] hr: make 'My Profile' available again to non-HR
It was no longer possible to load the My Profile for users with an
employee that were not HR Officer.

In the `get_views()` method, the 'search' view was requested after the
'form', thus it omited the fields requested as SUPERUSER in
`get_view()`.

closes odoo/odoo#99750

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-09-08 10:42:44 +02:00
William Braeckman 3dada389d4 [FIX] hr: Fix automatic employee creation
Introduced by #85428

closes odoo/odoo#99672

X-original-commit: e6cef5ab9ec189f1f0b86e21a1400859f021ba06
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2022-09-07 07:20:41 +02:00
Denis Ledoux 2dccc0d031 [IMP] base: faster get_bindings
The cache key of _get_bindings was not super efficient.
The result of _get_bindings is cached,
but its performance was altered by the cache
key which requires to fetch the user groups for each call to
_get_bindings.
Besides, as there is a lot of possible group
combination, this resulted in a lot of possible cache keys,
and therefore a lot of cached values.

This revision aims to make _get_bindings more efficient
by:

- do not use the groups in the cache keys (less cached values)
- filter out actions not available to the user groups after
  retrieving them from the cache
- use has_group to do the above, which is itself cached as well,
  and therefore do not need to fetch the user groups
  at each call to get_bindings.

In addition, move get_bindings from `get_view`
to `get_views`. If there was 3 views asked by `get_views`
(let's say kanban, list, form)
`get_bindings` was being called 3 times, through `get_view`
with each time the same arguments and therefore the same result :-).
Moving it to `get_views` allows to call it only once for all view types
requested, and for the web client it doesn't change much,
as it always request the toolbar/get_bindings through `get_views` only.

In addition, add the lang to the cache of _get_bindings.
it was actually a bug not to put it: if you had 2 users
with the same group set, using 2 different languages,
the user accessing first the get_bindings would cache
the action names within his language, and then the second
user would see the action name within the language of the first user
:-).

Before
```py
In [1]: %time for i in range(1000): self.env['ir.actions.actions'].get_bindings('res.partner'); self.env.invalidate_all();
CPU times: user 790 ms, sys: 104 ms, total: 893 ms
Wall time: 1.7 s
```

After
```py
In [1]: %time for i in range(1000): self.env['ir.actions.actions'].get_bindings('res.partner'); self.env.invalidate_all();
CPU times: user 23.5 ms, sys: 9.12 ms, total: 32.7 ms
Wall time: 36.9 ms
```

Part-of: odoo/odoo#99417
2022-09-05 16:54:01 +02:00
Francisco Alejandro González Luna 6c874fb297 [IMP] hr: make inheritable user fields to sync with employee
By enabling the method '_employee_values_sync' the original behavior is
keep. Furthermore, by overriding the method now is possible to decide
either a field is synced or not into employee.

closes odoo/odoo#96609

X-original-commit: 46c12cc0f72b2a6aba907fe903a255aed61a1695
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-07-27 03:35:14 +02:00
Denis Ledoux b03c227e88 [REF] models: refactor fields_view_get, load_views
Refactor the `load_views` API so it no longer sends multiple times the same
fields description.

e.g.
When `load_views` is called to get the kanban, tree and form views,
the list of fields of the model was sent 4 times:
- Once for each view, with only the fields used in the view,
  in `['fields_views']['kanban']['fields']` for instance
- Once globally, with all the fields of the model, in `['fields']`

The goal of this revision is to change that so it sends the list of all fields
only once.

In addition, if a view contains x2many fields,
the fields description of the comodel is also sent.
It was sent in the `views` key of the view fields dict.
e.g.
When calling `load_views` of `res.partner` to get the kanban,
tree and form views,
the `res.partner` fields description was actually sent 6 times:
- Once for each view
- Once globally
- Once for each view of the many2many field `child_ids` of the form view, in
  - `['fields_views']['form']['fields']['child_ids']['views']['kanban']['fields']`
  - `['fields_views']['form']['fields']['child_ids']['views']['form']['fields']`

The change suggested in this revision is to:
- Remove the fields description for each view in `['fields_views']`.
  As it no longer contains the fields,
  the key becomes `['views']` instead of `['fields_views']`.
- Replace the dict key `['fields']` by `['models']`,
  which is a dict with as key the model name and as values
  the model fields description. It contains the fields description
  for all models implied in the view:
  the model of the main view and the model of all one2many and many2many fields.

With this change, the fields description will only be sent once by model
implied in the view.

In addition, the web client was getting the information about the fields
sometimes in the global fields description list (e.g. `['fields']`),
sometimes in the fields description list of the view type
(e.g. `['fields_views']['form']['fields']`),
making it a pain to try to make changes / performance gain
in these field description dictionaries, because you never knew in which dict
the web client was getting its info.
Now, as there is only one place to get the fields description from,
it's clearer and cleaner.

- one2many and many2many fields views are passed directly in the main view
  architecture rather than being put in the `views` key
  of the field description.
  This is actually easier to treat by the web client,
  and this will allow in a future work to cache an entire view in one block
  of text rather than having to combine multiple cached blocks of text
  to return one view.
- one2many and many2many fields which do not have directly embedded views
  have their views directly injected in the architecture,
  so the web client doesn't have to do RPC calls to `load_views`
  for each one2many and many2many fields not having embedded views.
  For instance, this allow to reduce the number of RPC calls to `load_views`
  from 8 to 1 when loading the form of `product.product`.
  Currently, this behavior is limited to 1 level deep but we consider making it
  go all the way down in future works. We did not do it for the moment because
  in certain cases it rises the processing time and the size (bytes) too much.
  e.g. the sale.order view can be 5 levels deep,
  meaning you can reach 4 dialogs on top the main view.
  ```
  sale.order form > order_line > sale.order.line form > invoice_lines >
  account.move.line form > asset_ids > account.asset form >
  depreciation_move_ids > account.move form.
  ```
  This will also benefit in future works to cache an entire view in one block
  of text rather to having to combine multiple cached block of text
  to get one view.
- `fields_view_get` becomes `get_view`.
  As it no longer returns the fields description,
  keeping the `fields` in the name `fields_view_get` no longer makes sense.
  Hence removing `fields` from the method name, it becomes `view_get`.
  As it gets renamed anyway, we take the opportunity to rename it `get_view`,
  which is more in line with the general getter/setter guidelines
  in the model object world.
- `_fields_view_get` becomes `_get_view`. For the same reasons than above.
- `load_views` becomes `get_views`.
  This is not mandatory, there is no technical reason to rename `load_views` as
  it practically sends the same info as before,
  the view architectures and their fields description. Just in another way.
  We just take the opportunity of this pull request to suggest a cleaner API:
  `_get_view`, `get_view` and `get_views`.
- Arguments `toolbar=False, submenu=False` fo the methods
  `_fields_view_get` and `fields_view_get` are converted to a kwargs `**options`
  in `_get_view` and `get_view`.
  The rationale is that submenu was already no longer used (deprecated)
  and the mobile options is introduced.
  The mobile options is necessary to tell the server to send the mobile views
  for x2many fields (kanban instead of tree).
  Instead of adding a new argument each time we add a new option to
  `fields_view_get`, it seems wiser to have a kwargs `**options` to avoid
  to re-write all overrides each time a new option is introduced.
- `_fields_view_get` returned a dict containing the arch in text and some of the
  view information. Now, `get_view` returns a tuple with the view architecture
  as an `etree` node, and the view as a browse record. The rationale is that all
  overrides of `_fields_view_get` were about modifying the arch only
  (e.g. changing the address format/re-organizing the address related field
  nodes of the partner according to the company country).
  To do so, all these overrides were doing `etree.fromstring` to parse the arch
  which was sent in text to convert it to an `etree`,
  then operations were done on the `etree`,
  and then `etree.tostring` was called to convert back the arch to string.
  With this change of signature to send the arch as an `etree`,
  all these back and forth `etree.fromstring` -> `etree.tostring` are avoided,
  allowing some performance gain and less code in the end.
- A cleanup of the keys returned in the dict of `fields_view_get`
  has been performed in `get_view`:
  - `fields` is removed, as explained above,
  - `view_id` is renamed `id`,
  - `name` is removed, it was unused by the web client,
  - `type` is removed, it was unused by the web client,
  - `field_parent` is removed, it was unused by the web client,
  - `base_model` is removed, it was unused by the web client.
- `filters` is moved from the global dict returned by `load_views`
  (now `get_views`) to the dict returned by `fields_view_get` (now `get_view`)
  as it applies only to the `search` view type.
- Retro-compatible methods for the 3 methods
  `fields_view_get`, `_fields_view_get` and `load_views` are provided,
  with deprecation warnings in them.

- The web client could cache the model fields description
  (as it already caches the views),
  so it doesn't need to fetch them again if it asks for another view of a model
  for which he already has the fields description.
  If we do so, `get_views` could return only the list of models used by
  the views, without the fields description as of now,
  and the web client would then call `fields_get` independently only for
  the models for which it doesn't have yet the fields description.
  This would avoid the server to return the fields description
  and to call `fields_get`, which is costly, for each `get_views`,
  therefore gaining performances.
- Inject the views of the one2many and many2many fields all the way down,
  unlimited depth level, as explained above.
- Cache with `ormcache` the architecture of back-end views.
  This is already done for qweb views, it's not done for back-end views.
  Therefore the postprocessing of the views is performed for each `get_views`,
  which is costly, while the view architecture doesn't change for users
  belonging to the same groups, according to the groups implied by the view.

This pull request is co-authored by
Aaron Bohy (aab) for the web client part and
Denis Ledoux (dle) for the server part.

Part-of: odoo/odoo#87522
2022-04-29 09:57:44 +02:00
Kevin Baptiste 9b53cbe575 [FIX] hr: use correct name when creating employee from user wizard
When creating a user and employee from the wizard, the employee was
taking the default name from the context instead of the one chosen
in the wizard.

closes odoo/odoo#88368

Taskid: 2819821
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-04-11 10:01:47 +02:00
William Braeckman 717e03f51a [IMP] hr: create employees/users from eachother
The goal is to make it easier to link employees to users.
We can now directly create an employee from the 'invite' user form view
As well as create a new user from a form view using an action.

TaskId-2762247

closes odoo/odoo#85428

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-03-14 12:47:40 +00:00
anhe-odoo 6354cd0e5c [FIX] hr: Hide 'delete' and 'change password' actions on own profile
Expected Behaviour

When a user goes to his own profile, he has two ways to change his password :
1. through the 'Account security' tab
2. through the 'Actions' > 'Change password' menu in list/form view
Both option should let the user change its password, or one of the two should
not be present

Observed behaviour

While the first one works as expected, the second option gives an error as
the user doesn't have the admin rights

Reproducibility

This bug can be reproduced following these steps:
0. Make sure to have the "Employees" app installed
1. Connect as an employee (e.g. demo/demo on runbot)
2. Click on your name at the top right, go to 'My Profile'
3. Click 'Action' then 'Change password'

Problem Root Cause

There is an override of field_view_get for the res.users model in the hr
module which elevates the user with sudo so that the user may modify their
own user in some capacity. The problem is that by elevating the ACLs of the
user, fields_view_get will also return actions that are not normally
available to the user (e.g. deletion of user profile)

Related Issues/PR

- opw-2735671

closes odoo/odoo#86116

X-original-commit: 6487a9ea7d25d14a86a7476b4b512f3681da7405
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-03-09 17:05:07 +00:00
Noe Antoine a8b5a53e60 [REF][ADD] hr: split appointment module according to hr dependancy
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

closes odoo/odoo#82234

Related: odoo/enterprise#17934
Related: odoo/upgrade#2578
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-01-05 09:52:07 +00:00
William Braeckman 4902075e3d [IMP] hr: allow users to edit their settings in multi-company contexts
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

closes odoo/odoo#81612

X-original-commit: b5b105eabd90419a5856e8279e277743c5915fc9
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2021-12-17 16:58:10 +00:00
Jeremy Kersten de29bae3ee [FIX] hr: don't use .write() in a computed method
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

closes odoo/odoo#81555

X-original-commit: f85a67935c5dfa660e94f9bed8e8058c8df256cc
Signed-off-by: Jérémy Kersten <jke@odoo.com>
2021-12-17 08:29:41 +00:00
Sébastien Theys 4cd70f164e [IMP] mail, hr, hr_holidays, *: batch mail partner format
* = 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

closes odoo/odoo#73174

Related: odoo/enterprise#20186
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-08-12 15:22:59 +00:00
Krina Oza 962f13a2e0 [IMP] base,hr: imporve the language settings and access to it
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.

closes odoo/odoo#69292

Taskid: 2466771
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-06-07 09:50:58 +00:00
Raphael Collet 35a9f6c27a [FIX] core: SELF_READABLE_FIELDS and SELF_WRITEABLE_FIELDS on res.users
Avoid setting up those lists with method __init__() on the model, since
the model's class no longer has the expected parent classes.
2021-05-06 07:30:24 +00:00
Kevin Baptiste 3d5e912da7 [IMP] hr: add a model for work locations
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

closes odoo/odoo#63192

Related: odoo/enterprise#15235
Related: odoo/upgrade#2020
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-02-05 13:00:09 +00:00
Laurent Stukkens (LTU) 7a516973d3 [IMP] hr_contract: add employee type
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.

closes odoo/odoo#64931

Taskid: 2446000
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-01-28 12:20:16 +00:00
Yannick Tivisse 5703ec3cd8 [IMP] hr: Make employee lang editable on employee + my profile
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.

closes odoo/odoo#64949

Taskid: 2410407
Related: odoo/enterprise#15918
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-01-22 16:05:20 +00:00
Yannick Tivisse 5b886a747a [FIX] hr: Edit private address fields directly instead of M2O
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

closes odoo/odoo#62891

Taskid: 2412387
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-12-04 13:38:51 +00:00
Martin Trigaux e433bc57ff [FIX] *: rephrase, correct typos
Courtesy of Transifex's translators for reporting bad/unclear sentences.

closes odoo/odoo#61804

X-original-commit: f5d0f4a1ebf406583889e9e04912d40c0693343e
Related: odoo/enterprise#14769
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-11-16 16:47:28 +00:00
Martin TrigauxandXavier Morel 49838338e0 [FIX] *: sanitize action content reading
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.

closes odoo/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>
2020-11-10 16:04:29 +00:00
Yannick Tivisse 2511f5a889 [FIX] hr: Allow editing some missing fields on My Profile
Purpose
=======

Some fields weren't editable, even when the option is enabled on
the settings.

closes odoo/odoo#57842

X-original-commit: 57d595e87642fa6f7bec62cbb88a39c35cc72589
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-09-16 14:06:59 +00:00
Raphael Collet 69869ab681 [IMP] core: introduce subqueries in search
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.

closes odoo/odoo#52403

Related: odoo/enterprise#10945
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-08-18 13:02:41 +00:00
Martin Trigaux 6156f98288 [FIX] *: adapt action content retrieval
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.*
2020-08-17 09:09:02 +00:00
Yannick Tivisse 03a11b5a0e [REV] hr: revert f33644df65bcd4133689855018850c1b1deac7a6
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.

closes odoo/odoo#51435

X-original-commit: 0318f0acc5e98950c274c90a86a94d4588d2966d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-05-18 11:58:10 +00:00
Swapnesh Shah 665c2d536f [FIX] hr: use correct company for new employee
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.

closes odoo/odoo#51014

X-original-commit: 9206cc4db2a8dc5a7fbc281c1574f09bfba76544
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-05-11 10:13:29 +00:00
jvm-odoo 3da7db8cb6 [FIX] hr: fix employee creation from user form
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

closes odoo/odoo#46375

X-original-commit: e0c29f1a4cd8d95654963b024fd0b0e1b0578776
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-02-26 16:31:34 +00:00
Victor Feyens 9215e73fa2 [IMP] * : replace with_context(force_company=c) by with_company(c) 2019-11-18 12:25:05 +00:00
Swapnesh Shah 6f128fa959 [FIX] hr: Display archived employee on user form
closes odoo/odoo#38143

Signed-off-by: Romain Libert (rli) <rli@odoo.com>
2019-10-07 19:53:55 +00:00
jbm-odoo 73498572c3 [IMP] hr: Employee Profile set readonly attribute on readonly field
closes odoo/odoo#36698

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-09-11 14:00:39 +00:00
Lucas Lefèvre 55a4910b2e [FIX] hr: Redirect to company employee profile
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.
2019-09-10 11:46:01 +00:00
Yannick Tivisse e631dbc182 [IMP] hr: Improve general employee form UX (back2basics)
TaskID: 2054559

closes odoo/odoo#35802

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-08-19 11:10:03 +00:00
RomainLibert 1ca4c49ca1 [IMP] hr: synchonize image_1920 depending on self edit setting
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

closes odoo/odoo#35542

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-08-13 12:50:21 +00:00
RomainLibert 98385da449 [FIX] hr: add name to create
To create an employee you have to give it a name

closes odoo/odoo#35556

Signed-off-by: Romain Libert (rli) <rli@odoo.com>
2019-08-08 10:01:05 +00:00
Lucas Lefèvre 86dfe52eab [FIX] hr: Allow user to see fields in profile
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.

closes odoo/odoo#35486

Signed-off-by: Romain Libert (rli) <rli@odoo.com>
2019-08-07 12:40:41 +00:00
Lucas Lefèvre 9419d171a8 [FIX] hr: Allow to access employee profile
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.
2019-08-07 12:37:52 +00:00
Sébastien Theys 1e9772889b [IMP] *: use image.mixin when appropriate
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
2019-08-02 16:47:58 +00:00
Kevin Baptiste e9d9898276 [IMP] hr: Review the UX for 'My Profile' view
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

closes odoo/odoo#34180

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-07-18 10:27:50 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
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'`
2019-07-17 14:13:12 +02:00
Lucas Lefèvre f6fdde96bd [IMP] hr_*: Improve employee presence state
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

closes odoo/odoo#34933

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-07-17 09:11:18 +00:00
Yannick Tivisse 2eb374ea24 [FIX] hr: Correct implementation for 3be372c
This breaks the profile edition for non admin users
2019-06-28 08:48:49 +02:00
Christophe Simonis 25e3f27062 [MERGE] forward port branch saas-12.3 up to 48a9f5a633 2019-06-17 13:20:35 +02:00