Commit Graph
46 Commits
Author SHA1 Message Date
Laurent Stukkens (LTU) 76489303c8 [IMP] hr_contract: ease contract management through contract history
Before this commit:

    It was complicated to manage the contracts as they were all displayed in
    one view.
    When the contract was a time credit one (which is by definition a temporary
    situation) the data used was based on the time credit and not on the full time
    equivalent. This usually forced the HR to create fake new contracts without
    time credit for the appraisals.

After this commit:

    A new report will ease the followup of contracts with the time running.
    It comes with a new view that highlight the reference information which
    allow to easily manage credit time. Simulation is also made on FTE data which
    eases HR work.
    This commit also fixes a bug in the simulation with the meal voucher (only one
    was taken into account in the summary right panel.
    The wage on signature is now populated when the document is signed.

Closes odoo/odoo#58120
Related PR: odoo/enterprise#13384, odoo/upgrade#1802

task-2326407

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-11-03 15:08:45 +00:00
Victor Feyens 532c083cbb [IMP] *: remove global field definition in ir rules xml
It is a computed field, there is no need to manually set its value.
2020-03-20 16:15:40 +01:00
Yannick Tivisse d77f5eb820 [IMP] hr_contract: Move payroll structure type from hr_payroll to hr_contract
Purpose
=======

Even if you don't manage your payroll using Odoo, it could interesting to
categorize your contract (CP200, ...), in case you manage several kind
of workers or employees in your company.

TaskID: 2148537
2020-03-16 08:45:50 +00:00
Yannick Tivisse a5b6f31cf2 [IMP] base: Contextualize the multi company
Purpose
=======

Allow the user to select the allowed companies for which he wants to see records
on top of selecting his current company.

It is confusing for users to see the records from the company he is connected to
and the records of the children companies.

Instead of using the hierarchy of companies to access records across companies,
the user can now select (from his set of allowed companies) the companies for
which he wants to access records.

/!\ This means that the user will interact with records from company A when in
company B.
Example: a SO has been created and confirmed in A. When in B, I create the
invoice from it.

Specifications
==============

1/ Deprecate the parent/children hierarchy on the res.company model. The fields are
kept on the res.company model to ensure the retro-compatibility, but won't be used
accross the standard code anymore. The only functional usage for this mechanism
was to allow to see records from several companies by creating a virtual parent
company, which will be possible with the new mechanism.

2/ By default, a user will only see the records of the company he is connected
to (or records without a company). (It is still editable by the user if needed).
For that, put this information in the user context, to allow having different
configurations on different browser tabs. Instead of having domains like
['|',
('company_id', '=', False),
('company_id', 'child_of', user.company_id.id)]
you'll have something like
['|',
('company_id', '=', False),
('company_id', 'in', company_ids)]
Note that the 'company_ids' is a value that is passed in the evaluation
context on the record rule, as we already have user, or time.
company_ids is a list of the ids of all the enabled companies in the
user's context.

3/ Out of the generic improvements brought by this task, this will illustrate
issues that could exist since several versions. For example, it should not be
possible to create a scrap order for the company A with a package of the company
B, or it should not be possible to create an invoice on the company A with
payment terms from the company B. Before the version 12.0, it was easy to
encounter this kind of issues as the admin was the SUPERUSER_ID. A positive side
effect of the fact that the SUPERUSER_ID has become an inactive user was to
make it more difficult to introduce mismatch on the records, but haven't solved
the issue, as it was still possible to do it with parent companies
configuration. Some of these issues have been fixed in this commit, but all the
business flows should be re-tested to check if an ir.rule should be introduced
(eg: a multi company rule for stock.quand.package), if the company of a record
is correctly transfered to another record created from the first record (eg:
From a SO, create an invoice and a payment, the company of the sales order
should be transfered on the invoice and the payment, even if the company of the
sales order is A and I'm logged into the company B with the company A enabled.

4/ Currently, if I click on a button on a notification email (example 'View
Task'), I face a traceback if I'm not logged into the company of the record.
Now, if you click on a button and if you have access to the record, the correct
company will be automatically set.

5/ If I display a kanban view with several records from several companies (and
an image), all the images should be displayed.

6/ Currently if you copy paste an url, this will crash if you're not in the
correct company. This won't be fixed because it's quite impossible to do it in
a clean way. This task brings a workaround. Copy/Paste -> Traceback -> Log into
the correct company, re-copy/paste -> Ok.

7/ 2 property methods have been added on the environment to retrieve the company
on which the user is logged in and the companies the user enabled, on a specific
tab.
That way, when creating a record, instead of doing
default=lambda self: self.env.user.company_id
do
default=lambda self: self.env.company_id
On the other hand, to retrieve the enabled companies, do
companies = self.env.company_ids

8/ Modify the Company Switcher widget to allow to log into another company
WITHOUT writing on the res.users (and thus bringing cache invalidation issues
and so on). Also allow to enable several companies and see records from several
companies, and independantly of the other browser's tabs.

9/ When focusing on a tab, save the current company configuration on the local
storage. That way, when doing 'CTRL+T' or a middle click, the context is
propagated to the new tab.

10/ Improve the error message in case of multi company access errors. Now, when
the user is in debug mode, display the related names of the records and the name
of the user who brings the issue.

11/ Remove the context erasing when writing on a res.users
This is probably coming from the migration to new API of the base module.
The context was not propagated at this moment, which was a common mistake at
that time. When migrating the module, probably by using the 'black box' method,
as the context was not propagated, it was erased on the new version. This is
now an issue because the context (i.e. the enabled companies) was erased when
writing on a res.users, leading to tracebacks.
See: https://github.com/odoo/odoo/commit/7eab8e26d3d46c53f4be924d6a34e80a66e74960#diff-4c2e738ee8f64f11806c889ea097b5e7R624

12/ Fix the crash manager on redirect warnings. The issue is the following
- Create an invoice on a company without a configured CoA.
- Set a partner
- On the onchange_partner_id, a redirect warning is raised to propose you
to configure a CoA
- Click on 'Go to the configuration panel'
- A generic warning says something like 'Do you want to discard your changes?'
- Click on yes, the page refreshes, but not on the redirect action.
Now, set correctly the action on the hash, and reload instead. The breadcrumb is
lost for example, but you reach the correct action at least.

13/ Introduce a res.group to enable/disable the multi company per tab
feature.

14/ To help the users to know which tab is in which company, add the
possibility to have a favicon per company. When creating a company,
the classical 'O' icon is colored by default in a random color.

15/ Remove the company switcher on the frontend. This was mainly there
to allow a user to swicth to the company linked to the website.
This behavior is now transparent to the user. If the website A is
activated, then the company set on the context is the company of the
website.

16/ Deprecated the _company_default_get method on the res.company
model. Remove the method _get_company on the res.users model.

17/ Add 'allowed_company_ids' and 'current_company_id' on the pyeval
context. You can now use those variables on domains in the views to
access directly to the activated company.ies on the current tab.

TaskID: 1960971

closes odoo/odoo#32341

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-05-13 08:57:49 +00:00
Lucas Lefèvre 29633756b0 [FIX] hr_contract: Allow contract managers to manage employee
Contract managers should be able to create/manager employees.
This make sense when a contract manager hires someone.
He first creates the employee, then his contract.

This also allows contract managers to access private addresses
by transitivity.
This is also intended to allow a contract manager to set
a driver (private  partner) on the employee's company car
or to access `km_home_work` for transport reimbursment
(l10n_be_hr_payroll).
2019-03-19 09:35:31 +01:00
Lucas Lefèvre 955427bb49 [FIX] hr_contract: group_hr_contract_manager implies group_user
A user with only the contract access rights should be able to create
a contract.
2019-03-19 09:35:31 +01:00
Yannick Tivisse b631280999 [REF] hr_payroll: Remove parent_id hierarchy + Add structures categorization
1/ Remove the parent-children relation on salary structures

Currently it is difficult to see what rules are applied on salary structures.

Most of the structures are inheriting 3 rules (Basic, Gross, Net) from the
'Base for new structures', and those rules are not shown. Same issue if a
structure has another one as parent (as in the French localization).

This bring more annoying issues:

- Since the saas-12.1, we can already set different accounts for different
  companies on the salary rules for which we want to post journal entries.
  But for the parent rules, like the 'NET' amount, it's impossible to post
  the journal entries on different account for different salary structures.
  (eg: for CP200 employees and CP200 workers). As the rules are following
  a M2M relation on the structure, we have to remove the parent_id and to
  recreate all the rules in the final structure.
- If we are not at ease with the M2M relation (which is the case for most
  of the end users), we will simply modify the rule on the parent structure.
  This was already done on the French localization on which we modified the
  code, sequence and the name. This could have some desastrous consequences
  as this will break the order on which the rules are computed for other
  structures for the sequence, or break other integration with the payroll
  as we also modify the code, for example the salary configurator.

As this parent-children relation on structure could cause several issues
difficult to spot and as this is quite difficult to correctly visualize the
structure composition, it is better to remove it and define all the rules
inside the structure itself. This improves also the code readability as we
are not trying to recursively retrieve the rules and find a proper sequence
inside them.

2/ Make the rules on the salary structure a o2m instead of a m2m

The issues described just above indicates that it would be better to remove
the M2M relation between salary structures and salary rules, and make it
a O2M relation instead. That way, no more confusion and misconfiguration of
the rules fields (code, sequence, accounts, ...).

3/ Remove the parent-children relation on rules

A salary rule can have a parent salary rule. This mechanism, which is
not obvious at all for an end user allows to specify a parent rules.
If the condition is met for the parent rule (eg: the employee has at least
1 child), all the children rules could be applied (eg: Deduction of 90 euros
if the number of children is between 1 and 1).

Visually it doesn't make a lot of sense, as it displays one line with an
amount of 0 for the parent, and one line with the real amount for each
applied child. On the other hand, no child rule is linked to the structure
and an end user has to click on the parent rule, to see the children and
understand that something mystic and hidden is existing.

This is equivalent to define as many classic rules as we have children, or
even better, define 1 rule that will compute the real amount directly,
as the number of children can be accessed from the localdict when computing
the salary line.

This commit also removed the relation.

4/ Clean some brols in the code (technical)

The 3 first points of the spec allow us to clean a little the code readability
and complexity.

5/ Adapt all the localizations for these changes

All the localizations are impacted by those changes. What is done in this commit
is mainly:

- l10n_be_hr_payroll: Make 3 separated files for the 3 existing structures (the
  fourth one, belgian worker, is not correct and is removed). For each
  structure, define explicitely the rules (in the correct order by sequence).
  This multiplies the total number of rules as some of them were shared (like
  the withholding tax rule for example), but all the code that is supposed to be
  modified each year/quarter/whenever the government decides to modify the law
  has been moved into a python file, and is available the computation context.
  This will also allow us to update the computation rules without having to
  update the module.
- l10n_fr_hr_payroll: There were 3 rules following this scheme:
                              Base for new structure
                                        |
                                 Basic structure
                                        |
                              ----------------------
                              |                    |
                           Cadre                Non-Cadre
  All the rules parent rules have been duplicated into the 2 remaining
  structures, cadre and non-cadre. There were a lot of parent-children relations
  between the rules that have been adapted to the new model.
- l10n_in_hr_payroll: There was a lot of rules in data, and a structure in demo
  data, which was using 4 or 5 of these rules. As the rules doesn't seem to make
  a lot of sense altogether, everything was moved in demo data.

6/ Introduce a new Salary Structure Type model

Currently we have a model hr.contract.type with a M2O on the contracts. This has
never been used in 9 years and is removed in this commit. On the other hand, we
would like to define a new model hr.payroll.structure.type (eg: CP200 Employee),
which will line all the salary structures the Belgian localization could bring
(Classic salary, double holidays, 13th month, ...). This field is defined on the
structure, and is displayed on the contract (as the same place than the contract
type we just removed).

On this model we could also define some fields like:
- The default pay period: Selection field, default = monthly. This is applied on
  the contract when selecting the structure.
- The Working Schedule, m2o. This is applied on the contract when selecting the
  structure

For example, on the 'commission paritaire' for teachers, we could set the
default pay period to 'Every 15 days' and the working schedule to '19 hours /
week'. Every contract under this structure would take those values.

Migration
=========

For a migration point of view:
- All the rules that had a parent_rule_id should be set to
  appears_on_payslip=False. The column parent_rule_id can be dropped afterward.
- All the rules that are coming from a parent structure or higher should be
  duplicated and the field 'struct_id' should be set on the current structure.
  The column parent_id can be dropped afterward.
- All the rules that were defined on the structure should have the field
  'struct_id' defined on them.
- The rules that are not linked to a structure should be unlinked.
- The column type_id on the contract could be dropped, no need to keep the
  values too.
- A default structure type is defined in data ('Employee'). This could be set to
  all the existing structure for the newly created 'type_id' field.

TaskID: 1942832
2019-03-19 09:24:23 +01:00
jbm-odoo ec07e72845 [IMP] base,*: Reorganize access rights groups
Purpose
=======

Access group terminology is missleading. Yous have to be manager to administrate
an application. This task consists to rename groups to be understandable for everyone.

Groups should be reorganised on the users form to be more explicit.

Specification
=============

1/ Rename 'Manager' to 'Administrator' in users groups.
2/ Define a hierarchy on access groups by using the category_id in the manifests
   A category 'Operations/Project' will create a category Project with a parent
   category 'Operations', and something smart is already developed (in modules/db.py)
   to avoid duplicating categories.
3/ Add a group in expenses to be able to approve expenses reports for my team.
4/ Add a group in timesheets to be able to approve timesheets for my team.
5/ Remove partially the useless crap in ir_module_category_data.xml
6/ Sort access rights groups on users form according to its parent category

closes odoo/odoo#29362

Signed-off-by: "Yannick Tivisse (yti)" <yti@odoo.com>
2019-03-05 09:08:12 +00:00
Yannick Tivisse 1684ec555d [IMP] hr_payroll: Manage multi company on payslips/contracts
Purpose
=======

Currently the payroll doens't manage the multi company

Specification
=============

1/ Add ir.rules on hr.contract and hr.payslip to prevent users
   to access a record in another company.
2/ Add ir.rules on hr.payroll.structure to prevent users to access
   a record for another country.
3/ Remove company_id fields on models that doesn't require it, as
   hr.salary.rule.category.
4/ Make the accounting fields on the salary rules company dependent.
5/ Specify the country on the salary structures on the
   l10n_**_hr_payroll modules.
6/ Add demo data and modify the salary package tour.
7/ Make the car_atn and company_car_total_depreciated_costs fields
   compute_sudo=True, as one car can be assigned on several contract,
   for different companies

Closes #26866
Closes #25231
Closes #24683
Closes #23814
2019-01-21 12:33:03 +01:00
Raphael Collet 2f7c03d9ca [IMP] base: add regular user admin as uid 2
User 1 simply becomes a technical user (inactive, no password).
2018-08-23 21:38:57 +02:00
Yannick Tivisse 9edc477b31 [IMP] hr_contract: Add a access right group on contracts
Some private information are on the contracts. Add a special group to display the
contracts, independant of the other HR access rights.
2018-05-04 09:47:00 +02:00
Yannick Tivisse e4c7c36c3a [FIX] hr_contract: Allow a employee user to read contracts 2016-09-20 15:42:29 +02:00
Martin Trigaux 11812b0b9e [FIX] all: remove external ids fakely from base
Several modules defines records with the external ID `base.foo_bar` while it is
created inside this module (typically menus and groups).
While there is no technical reasons to do so but this may introduce issues:

- these records will not be deleted during uninstall
- if a language is loaded before the installation of the module, it won't be
  translated

The uninstallation will only remove the records with an external id linked to
this module (these would only be removed when removing base).

Installing a language before the module will drop the translations not linked
to an existing external id (as it can not be resolved).

This commit correct all the external ids tagged as from base or other incorrect
modules.
2016-09-02 16:14:26 +02:00
Adrien Peiffer (ACSONE) 2ae37d7c9a [FIX] hr_contract: access on resource.calendar.attendance for HR officer
Add ACL on resource.calendar.attendance for HR Officer
according access right on resource.calendar

Otherwise, this isn't possible for HR officers to
manage Work Details (`resource.calendar.attendance`),
while they can manage Resource Calendar (`resource.calendar`)

Closes #9330
2015-11-03 17:04:22 +01:00
Fabien Pinckaers f27318c8af [IMP] Security Rule: removed duplicates due to inheritancies of groups
bzr revid: fp@tinyerp.com-20111212181113-mhnnbps3ip8ls6pp
2011-12-12 19:11:13 +01:00
Quentin (OpenERP) 8d29e89f44 [IMP] hr_contract: changed passport into char field and removed useless object
bzr revid: qdp-launchpad@openerp.com-20110711170401-q71lycboq23izgnv
2011-07-11 19:04:01 +02:00
psi (Open ERP) dc38bb2f62 [IMP] remove hr.contract.wage.type.period.user from security file and comment all appearance of the object from view file
bzr revid: psi@tinyerp.co.in-20110322130811-ps38kxglfwqqkx59
2011-03-22 18:38:11 +05:30
mtr 6292725450 [IMP] hr_contract:added access rights for hr.passport object
bzr revid: mtr@mtr-20110309062231-ea2huggnqk8qgchg
2011-03-09 11:52:31 +05:30
mtr 6e6b21a875 [IMP] hr_payroll,hr_contract:commented 'hr.contract.wage.type' and improved strings of menuitem in payroll.
bzr revid: mtr@mtr-20110307112817-f3c7o3fro4oxzejn
2011-03-07 16:58:17 +05:30
François Degrave b05d9cfe25 [FIX] HR sign in/sign out
bzr revid: fde@openerp.com-20101229123900-mxl4umxn1tqjjpar
2010-12-29 13:39:00 +01:00
François Degrave c19999edf8 [IMP+FIX] HR access rights, product margin
bzr revid: fde@openerp.com-20101229081804-ci2v2t9fhtmc1d3d
2010-12-29 09:18:04 +01:00
Vir (Open ERP) fc7ac05985 [REM] Removed not used security files
bzr revid: vir@tinyerp.com-20101013073425-03z20ylsxwq1or3y
2010-10-13 13:04:25 +05:30
DBR (OpenERP) d270bee66a [MOD/IMP] hr_timesheet_sheet : Usability Improvements in Timesheet Sheet Analysis Report
bzr revid: dbr@tinyerp.com-20101008070438-zc0g5fxb6kko2jmq
2010-10-08 12:34:38 +05:30
AMP (OpenERP) 92c78d14e6 [MOD/IMP] hr_* : hr,hr_attendance,hr_contract,hr_expence,hr_timesheet,hr_timesheet_invoice,hr_timesheet_sheet Usability improvement in access rights
bzr revid: amp@tinyerp.com-20101007094729-1sdtsxube9ti5lw2
2010-10-07 15:17:29 +05:30
DBR (OpenERP) 389a623545 [MOD/IMP] hr_* : Usability Improvement in Accessrights
bzr revid: dbr@tinyerp.com-20101007071157-z52414z1sz9h85qh
2010-10-07 12:41:57 +05:30
DBR (OpenERP) 34a533beba [MOD/IMP] hr_contract : Usability Improvement in Accessrights
bzr revid: dbr@tinyerp.com-20101006123108-zdrz31iewg7xfpvq
2010-10-06 18:01:08 +05:30
AMP (OpenERP) b4a3da2cc0 [MOD]hr_*: usability improvement
bzr revid: amp@tinyerp.com-20100918073924-3020grhwot6v837w
2010-09-18 13:09:24 +05:30
AMP (OpenERP) 3362c2ea82 [MOD]hr_*: usability improvement in access rights
bzr revid: amp@tinyerp.com-20100911131911-7k4g0r1b4kta30cc
2010-09-11 18:49:11 +05:30
AMP (OpenERP) 1d15f71146 [MOD] project_timesheet,hr_* : usability improvement in access rights
bzr revid: amp@tinyerp.com-20100901132905-hslnywxf4zxogxdo
2010-09-01 18:59:05 +05:30
AMP(Open ERP) aff16ab9a5 [MOD/IMP] hr_* : Improvement in access rights
bzr revid: vir@tinyerp.com-20100813133645-w8nex9k1he2zjq9h
2010-08-13 19:06:45 +05:30
DBR (OpenERP) 5f4d7ff09b [MOD/IMP]hr_* modules access right changes in configuration
bzr revid: dbr@tinyerp.com-20100804133252-vh4vbkhmvsev0pnw
2010-08-04 19:02:52 +05:30
Vir (Open ERP) 4a9ece3520 [MOD] hr_contract,hr_payroll : Modification in access rights
bzr revid: vir@tinyerp.com-20100804061834-jijidg5kujy8ckex
2010-08-04 11:48:34 +05:30
DBR (OpenERP) a446dfb18e [MOD] hr_* :Improvement in hr_* modules groups and accessright
bzr revid: dbr@tinyerp.com-20100803131117-jkvf2a7pe955en2u
2010-08-03 18:41:17 +05:30
Mustufa Rangwala c179005fc7 [IMP] Clean hr_* module (Still need to done)
bzr revid: mra@mra-laptop-20100703102152-4ulrrzbkorpd7xei
2010-07-03 15:51:52 +05:30
Fabien Pinckaers 65b70827c4 fix_and_better_access_rights
bzr revid: fp@tinyerp.com-20100612220005-4a33xqgs8bvvoa7x
2010-06-13 00:00:05 +02:00
uco (OpenERP) 264b7e4322 [ADD] hr_contract: Added security rules for hr_contract.
bzr revid: uco@tinyerp.co.in-20100308133244-h1jt52bb9juj47n1
2010-03-08 19:02:44 +05:30
Mantavya Gajjar c72753bfa1 [FIX]:fix a bug related to the twise Marital status
complete move to hr module instead of hr_contract

lp bug: https://launchpad.net/bugs/520992 fixed

bzr revid: mga@tinyerp.com-20100216070246-jq8d9zf6aogz1lt8
2010-02-16 12:32:46 +05:30
Christophe Simonis 123a99c39a fix access rules
bzr revid: christophe@tinyerp.com-20081021153441-af1qtobtazu7rs28
2008-10-21 17:34:41 +02:00
Christophe Simonis cebb03c476 fix and complete access rules
bzr revid: christophe@tinyerp.com-20081017170345-4gw81edzvd2yjtyw
2008-10-17 19:03:45 +02:00
Christophe Simonis 1a138e1454 fix and complete access rules
bzr revid: christophe@tinyerp.com-20081017162038-kzsgroivk73t0vyx
2008-10-17 18:20:38 +02:00
Christophe Simonis d3ce446ec0 fix and complete access rules
bzr revid: christophe@tinyerp.com-20081017084109-i1r4zigf7wp3o6i5
2008-10-17 10:41:09 +02:00
Stephane Wirtel 606165c849 rename the tag <terp/> by <openerp/>
bzr revid: stephane@tinyerp.com-20080910175600-tutctqg606c9eil4
2008-09-10 19:56:00 +02:00
Christophe Simonis d245f4f7fb fix errors preventing installation
bzr revid: christophe@tinyerp.com-20080910122034-vcq41c249oz4zqwu
2008-09-10 14:20:34 +02:00
Fabien Pinckaers 51f8c2b263 Better Security Rules
bzr revid: fp@tinyerp.com-20080903224650-u1oadqv9x75atmyl
2008-09-04 00:46:50 +02:00
Fabien Pinckaers f9ec54047f Improved Security
bzr revid: fp@tinyerp.com-20080903182533-bi4u27xqnm2mmhhr
2008-09-03 20:25:33 +02:00
Fabien Pinckaers b4d6690794 Improved Security
bzr revid: fp@tinyerp.com-20080903180400-df7l6wxg1zpirmmi
2008-09-03 20:04:00 +02:00