Commit Graph
1173 Commits
Author SHA1 Message Date
Audric Onockx (auon) 2933d5eb5b [FIX] resource : compute the correct default dates when planning a shift
Steps :
- Install Planning
- Users > Mitchell Admin > Preferences > Timezone :
	Europe/Brussels
- Settings > Employees > Company Working Hours > Timezone :
	Japan
- Planning > Gantt View > Week > Mitchell Admin x Friday > Click "+" button

Issue :
- Start date is set by default to Thursday 05:00
	whereas it is expected to be set on Friday 00:00

Cause :
- When we want to plan a shift on a day,
	we look into the 00:00 to 23:59 range for this day in calendar's tz
	to get the closest work time inside of it.
- Yet, this doesn't take the "resource user" into account.

Fix :
- Set these limits for the day in resource's tz.

opw-2678221

closes odoo/odoo#82555

X-original-commit: 1b248ebd58e0a57b070ebf7d67c6da78351a720a
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-01-12 16:43:24 +00:00
Prakash Prajapati 16246f8374 [FIX] resource: fix the maximum recursion depth traceback
Maximum recursion depth traceback occurs when the resource is created from planning.
This has been fixed.

Reproducing steps:
         - Planning
         - Schedule by Resource
         - Create new Resource

The issue occurs from this commit -https://github.com/odoo/odoo/commit/18952cdc76070f2a70789f2fa25e4fa0d546d470

closes odoo/odoo#81840

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-12-23 13:14:22 +00:00
Yannick TivisseandVictor Feyens 18952cdc76 [IMP] *: Convert single create method into multi
Taskid: 2703085
Part-of: odoo/odoo#80824
Co-authored-by: Victor Feyens <vfe@odoo.com>
2021-12-14 19:13:18 +00:00
Thibault Libioulle 74624f43ee [REF] resource,hr{,_contract}: obtain calendar validity per resource
This commit adds methods to easily obtain calendar validity per resource
for a given search period and get the work intervals per resource,
taking into account the validity of their calendars.

In hr, the create and departure date of an employee are taken into
account to compute the calendars validity.

In hr_contract, it looks for every contract of human resources with
employee of type student or employee existing in the search period and
consider the specific calendar of the contract as valid during the
contract-lifetime.

PR: #77362

task-2646630
2021-11-30 12:20:47 +01:00
Thibault Libioulle be23e7436d [IMP] resource: speedup tests
This commit replaces the setUp method by a classmethod in order to speed
up the tests.

PR: #77362

task-2646630
2021-11-30 12:20:31 +01:00
Thibault Libioulle 6d41b7ec7e [IMP] resource: add the false key to work intervals batch
The False key is always added in attendance and leave intervals batch
but is not added in the work_intervals batch.

To give a more smooth API, this commit aligns work_intervals behavior
with the two other methods behavior, regarding the added False key.

Furthermore, we avoid to deal with a resource_list of two empty
recordsets, in the case where the resources parameter is None or empty
recordset.

PR: #77362

task-2646630
2021-11-30 12:20:31 +01:00
Bonis ModiandKartik Chavda f4c054e473 [IMP] project, hr_timesheet, *: improve generic ux
Purpose of this commit to improve generic UX for the project app.

So, In this commit done following changes:

- add 'subtask_effective_hours' and 'total_hours_spent' fields in the page of
subtask in task form view.
- change invisible attrs to column_invisible attrs for block_by page in task
form view.
- add 'task in progress' subtype for project.task and move 'stage changed'
subtype above 'task blocked'.
- remove the 'is_close' field and all its references from project.task.type.
- unarchive all of its tasks when the user unarchives the task stage.
- sort projects on 'is_favorite'.
- internal users following the project automatically follow its updates and
their notification preferences propagated accordingly.
- duplicating a task will duplicate all of its subtasks.
- move parent task field in extra info page of task form view.
- change the label of 'edit' to 'view' in the burger menu of project kanban view.
- user can delete task without sale_order validation error.
- add constraints for 'seller_ids' field.
- add remaining_hours_so field in task tree view.
- add unusual_days in task calendar view.
- add 'no content helper' in action of burndown chart.

task-2536044

closes odoo/odoo#74018

Related: odoo/enterprise#19880
Related: odoo/upgrade#2801
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
Co-authored-by: Kartik Chavda <kcv@odoo.com>
2021-11-23 12:04:00 +00:00
Philippe Wauthy da642c06e3 [IMP] resource: allow to use _adjust_to_calendar with or without leaves
Allow to use _adjust_to_calendar with or without leaves.
This PR adds a keyword argument to the _adjust_to_calendar, _get_closest_work_time and _work_intervals_batch to include or not the employee being on leave when searching for the start and end of the shift.

task-2632775

closes odoo/odoo#79127

Related: odoo/enterprise#21944
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2021-11-12 16:34:58 +00:00
Philippe Wauthy 88d0c49604 [FIX] resource: timezone end before assigning search_range
The end datetime is not timezoned in _adjust_to_calendar before defining the search_range and using the _get_closest_work_time method.
Since _get_closest_work_time will timezone the timestamp received to start searching, the search interval needs to refer to the same end timestamp to avoid erratic behaviors.

Task-2628876

closes odoo/odoo#79049

X-original-commit: cbf0cb6e210959b3ceea554ec68957416a125141
Related: odoo/enterprise#21915
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2021-10-27 21:06:48 +00:00
William Braeckman faefaf7c39 [IMP] resource: improve _attendance_intervals_batch perf
Improves on _attendance_intervals_batch to profit more from batching.
Resources are grouped by timezone since we know they will all have the
same result except for when there are resource assigned attendances.
Those have to be handled separately but are incoroporated in the same
routine.

TaskId-2674527

closes odoo/odoo#78741

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-10-26 13:22:27 +00:00
William Braeckman 4fbff6a9d4 [FIX] resource: fix timezone being overwritten
If no timezone is given to _attendance_intervals_batch, the timezone was
overwritten by the first resource's timezone.

TaskId-2674527

Part-of: odoo/odoo#78741
2021-10-26 13:22:27 +00:00
Philippe Wauthy fd69a22410 [IMP] resource: assign a search_range for calendar_end
Assign a search_range for calendar_end in the _adjust_to_calendar method in all conditions.
The search_range was only assigned a value if the start and end are on the same date before.

The _adjust_to_calendar method receives a start and end from midnight to midnight in the resource timezone.
Start and end datetimes can be set on a different day via the Gantt view set in month or year for example.
This commit ensures that a search_range is always assigned to find the calendar_end and not only when start and end are on the same day.
This allows to find the end of a shift searched over two days if the employee is only working one day.

Task-2628876

closes odoo/odoo#78746

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-10-26 07:47:47 +00:00
Philippe Wauthy 3708c7982e [FIX] planning: fix sorting of records in Gantt view
Steps to reproduce:
Open the gantt view and add a few shifts for different resources

Observed behavior:
https://nimb.ws/1t38Jl resources are not sorted by alphabetical order

Expected behavior:
https://nimb.ws/NqIAG3 resources should be sorted by alphabetical order

task-2633936

closes odoo/odoo#76621

X-original-commit: 9c4ed2bcadc417a2927877902c4c275e5d9d16d5
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-09-16 07:18:15 +00:00
Martin Trigaux ef8ad324b0 [I18N] *: export 15.0 source terms
closes odoo/odoo#76542

X-original-commit: 63e6807437295519a0f4705fb88644d6d557ca3a
Related: odoo/enterprise#20882
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-09-16 07:17:40 +00:00
254d6a71e8 [IMP] hr_holidays: Improve Accruals, dashboards and general UX (Back2basics)
Purpose
=======

Time Off : New Dashboard, Accruals feature, Public holidays, New time off type configuration view.

- Review of Dashboard
- Accrual feature : Currently, when you create an allocation, it's possible to create an
  Accrual, but there is no appraisal Plan. An Appraisal plan is use to define steps of accruals
  for each employee.
  In Belgium, we use accrual Allocation for European Leaves, or compensatory hours, it's a
  simple use case.  But in USA, it's possible to change the calculation mode each year.
  Also, in USA, it's possible to deal your accrual plan when you arrive on the company. It's a
  HR Officer task to create the right Accrual allocation for each new employee.
- Public Holidays :
  Improvement of global time off feature located on Working hours calendar. Now, Time off
  application have to manage Public Holidays.
- Review of Time Off type configuration

COM PR: https://github.com/odoo/odoo/pull/72511
ENT PR: https://github.com/odoo/enterprise/pull/19157
UPG PR: https://github.com/odoo/upgrade/pull/2791
TaskID:2475413

closes odoo/odoo#72511

Related: odoo/enterprise#19157
Related: odoo/upgrade#2791
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: William Braeckman <wbr@odoo.com>
Co-authored-by: Xavier BOL (xbo) <xbo@odoo.com>
Co-authored-by: Laurent Stukkens (LTU) <ltu@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2021-09-02 12:57:03 +00:00
jdoutreloux a8e6b57fef [IMP] resource,web : modifies the timezone_mismatch widget
This modifies the widget to allow a title option.

Task-2352428
Closes #67021

Related: odoo/upgrade#2223
Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-08-31 19:54:19 +00:00
Kevin Baptiste fe161c2105 [IMP] resource: improve resources views
Improve the UX of the different resource.resource views.

closes odoo/odoo#73822

Taskid: 2566432
Related: odoo/enterprise#19695
Related: odoo/upgrade#2649
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-08-24 10:55:22 +00:00
Xavier-Do 288595f558 [FIX] *: add explicit license to all manifest
The license is missing in most enterprise manifest so
the decision was taken to make it explicit in all cases.
When not defined, a warning will be triggered starting from
14.0 when falling back on the default LGPL-3.

closes odoo/odoo#74245

Related: odoo/design-themes#48
Related: odoo/enterprise#19862
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2021-07-26 13:09:57 +00:00
Martin Trigaux 6758868731 [I18N] *: export saas-14.4 source terms
Without demo data

closes odoo/odoo#73560

X-original-commit: 802e46541117573e028b711ea33dad9df9075a39
Related: odoo/enterprise#19602
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-07-12 10:57:37 +00:00
Adrien Widart 13266efa6b [FIX] resource: allow a working time of 24 hours
It is not possible to define a working time that lasts a whole day. This
can lead to calculation errors.

To reproduce the error:
(Need mrp,hr_payroll)
1. In Settings, enable:
    - Work Orders
2. Create a Work Center WC
    - Working Hours: <Create and Edit>
        - 2 shifts:
            - Monday, From 0 To 24
            - Tuesday, From 0 To 24
3. Create a routing R:
    - Add an operation:
        - Work Center: WC
        - Default Duration: 1440 (i.e., 24h)
4. Create a Bills of Materials BM
    - Routing: R
5. Create a MO:
    - Bill of Material: BM
    - Plan From: Next Monday
6. Save, Mark as ToDo, Plan

Error: Since the operation should last 24 hours, the end time should be
the same. However, the Planned Date field is incorrect: the end time is
one minute too late. This error is even more noticeable when increasing
the quantity to be produced.

On step 2, when setting the 'Work to' field to 24, it automatically
becomes 23:59. The first consequence is directly observable on working
time form: we should have a total of 48 hours/week but the current total
is 47.98 hours/week. Another consequence is the end of the planned date
(as described above).

OPW-2462094

closes odoo/odoo#72210

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-06-16 07:09:22 +00:00
Julien MougenotandSimon Genin 03641610c2 [REF] *: convert all modules to new asset system
Conversion of all modules to the new manifest assets declaration.

Part of task: 2352566

Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Simon Genin <ges@odoo.com>
2021-03-31 13:57:18 +02:00
Yannick Tivisse cf7e386032 [FIX] resource: Correctly pass domain if set
closes odoo/odoo#68536

X-original-commit: 62a01fa6ff2f1f078b333f5d8bb16d73d0921bdb
Related: odoo/enterprise#17371
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-03-30 11:24:21 +00:00
Martin Trigaux 3f13751e9b [I18N] *: export saas-14.1 source terms
Without demo data

closes odoo/odoo#63238

X-original-commit: 4e6683973b1d1ecc67f1312a8ef98b1272e2d5a5
Related: odoo/enterprise#15268
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-12-11 12:30:42 +00:00
Yannick Tivisse 0078a21876 [IMP] resource: Remove deprecated methods 2020-12-08 10:22:36 +00:00
Yannick Tivisse 0b07defece [IMP] resource: Index calendar/resources on calendar leaves
Improves performances, notably on the method  https://github.com/odoo/odoo/blame/14.0/addons/resource/models/resource.py#L487

closes odoo/odoo#62821

X-original-commit: fc962de2b60adaa1ffa3bf70bfadc5c3d17867b3
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-12-03 13:00:41 +00:00
fw-bot 53f877bf38 [FW][MERGE] l10n_be_hr_payroll: Clean tests + Handle threshold for training time off + ATN for 0€ payslips
closes odoo/odoo#62697

Taskid: 2393750
Forward-port-of: #15020
Related: odoo/enterprise#15077
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-12-02 08:48:09 +00:00
Victor Feyens f09afc4241 [REM] resource: remove duplicate constraint
The constraint is already enforced at the SQL level,
there is no need to add a duplicate python constraint to
verify the same thing.

Task Id: 2328664
COM PR: https://github.com/odoo/odoo/pull/55525
ENT PR: https://github.com/odoo/enterprise/pull/12250
2020-11-20 10:04:27 +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
Yannick Tivisse c5550eed5a [FIX] resource: Fix erroneous date/datetime comparison
closes odoo/odoo#60975

X-original-commit: febd3251aa970f6711f303d539eeeabebf16e818
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-10-29 11:42:31 +00:00
Yannick Tivisse f3c1a8fbd9 [FIX] resource: _get_resources_day_total is ensure_one
closes odoo/odoo#60974

Valueerror: Expected singleton: resource.calendar()
X-original-commit: af94ac4b4a25048adfd82f1de7fe2dc09755fd56
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-10-29 11:41:15 +00:00
fw-bot 2be103239f [MERGE] l10n_be_hr_payroll: Validate the CP200 different payslips
Purpose
=======

In Belgium, the job market is divided into "sectors": chemicals, metals, banks,
department stores, pharmacies ... This breakdown is made on the basis of the
activities of the company. In order to be able to ensure the functioning of the
sectors, each sector has its own consultation body, called the "joint commission".

A joint committee is a consultation body in which representatives of employers
and unions set, after negotiation, the minimum wage conditions as well as the
working conditions in legal texts, called “collective labor agreements”. These
are applicable to all employees in a specific sector.

These are agreements that employers and workers in a given sector must make and
respect. These agreements may be different from one sector to another. Each sector
has its label and number.

The CP 200 is the auxiliary joint committee of employees (CPAE). About a quarter
of private sector companies and employees in Belgium are found in CP 200. This
makes it the largest and most diverse CP in the country!

TaskID: 2352568

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

Most of the different use cases that we can face in belgian payroll for CP200
have been tested and validated by a fiscal expert.  Briefly, it covers the following
use cases:

- Unpaid time off
- Legal time off
- Credit time
    - Classical
    - With paid time off
    - With unpaid time off
    - With sick time off
    - Starting in the middle of a month
    - Full time (O hours / week)
- Half-days in working hours
    - Classical
    - With full-day time off
    - With half-day time off
- Low salaries
- Back-to-work - Sick time off
    - Relapse
    - Guaranteed salary
    - Long sick off (+1 month)
- Student contracts
- Posted Employess
    - Without ONSS
    - Wihtout withholding taxes
- Public Holiday
    - Classical (during the working hours)
    - Compensation (during the week end)
    - After the end of the contract
    - Note: Variable compensation is not handled yet, but it's planned
- Brief Holiday (In french: "Petit Chômage")
    - 1 day
    - 1 week
    - Note: Variable compensation is not handled yet, but it's planned
    - 1 day for unpredictable reason
- End of contract in the middle of the month
- Half-days time off
- New design of the payslip to improve readability

The detailed list of the fixes/improvements is the following:

- 1/ hr_work_entry_contract: Define 1 leave work entry per presence

    Purpose:
    Some sick time off have to be defined into different work entry types, according
    to the type of sick leaves.

    Example: after 30 calendar days of sick leaves, the employee is not paid by the
    same organism and therefore, the time off should be reported into different work
    entry types.

    Specification:
    Instead of creating a big work entry per time off, create as many work entries
    as there should have been presence work entries.

- 2/ hr_work_entries: Prevent users deleting work entries

    Prefer to archive them instead.

- 3/ hr_work_entry: Display work entry type on calendar views

- 4/ web: Add styling classes for report

    Purpose:
    Those classes are useful for the payslip printed pdf reports, but some
    of them are useless for any kind of report, and thus the classes have
    been defined in the web addons.
    Task-2341886

- 5/ resources: Take company attendances/global leaves on creation

    Purpose:
    When creating a new calendar (38 hours/week) on a Belgian company,
    the new calendar is prefilled on a 40 hours/week basis, even if the
    company calendar is correctly defined.

    Specification:
    Copy the global time off + the attendances on the company calendar
    on company modification

- 6/ hr_holidays: Allow to refuse overlapping time offs

    Purpose:
    It's normally not possible to create 2 time off that overlaps on the
    same period.

    But, if for a given reason it happens on a production database, it should
    be possible to refuse those time off. Otherwise, the user is stuck with
    this wrong configuration.

- 7/ hr_holidays: Prevent creating time off of 0 hours

    Purpose:
    It makes no sense + it could cause conflicts when generating the work
    entries

- 8/ resource: Add method to retrieve the longest work day

    Purpose:
    Add a method on the calendar to retrieve the maximum number of hours
    an employee is supposed to work.

    Example:
    Monday: 8-12, 13-17
    Tuesday: 8-12, 13-17
    Wednesday: 8-12
    Thurday: Off
    Friday: Off

    The method will return 8

- 9/ hr_holidays: Adapt query counter due to changes on hr_payroll

    See: https://github.com/odoo/enterprise/pull/13848/

- 10/ hr_payroll: Update translations

    Lots of new terms have been added on the printed reports, etc...

- 11/ l10n_be_hr_payroll: Consider out of contract public holiday

    Purpose:
    If there is a public holiday less than 30 days after the end of the
    contract, the employee should be paid for that day too

- 12/ l10n_be_hr_payroll_posted_employee: Add an easy way to create a public time off

    Purpose:
    Public time off should be created via the calendar (at least for belgian companies using payroll).

    The reason behind this is that there should be a resource.calendar.leaves available even if the
    employee ends its contract. If it's created using a hr.leave, there won't be any
    resource.calendar.leave as the employee is not supposed to work anymore at that time.

    When an employee leaves the company, it's possible that he's paid for public time off if it
    occurs less than 30 days after the end of his contract.

- 13/ l10n_be_hr_payroll: Rename bank holiday into Public holiday

    Purpose:
    A bank holiday is a specific holiday name, not the generic one.

- 14/ hr_work_entry_contract: Add menuitem to access calendars

    It shouldn't be required to enter debug mode to access this information.

- 15/ l10n_be_hr_payroll_posted_employee: Add support for posted employees

    Purpose:
    https://www.socialsecurity.be/citizen/fr/travailleur-salarie-occupe-en-belgique-detache-a-l-etranger

- 16/ l10n_be_hr_payroll: Implement guaranteed wage/relapse for sick leaves

    Purpose:

    Guaranteed salary for employees:
    The employee who is incapacitated for work as a result of a work accident, an accident on
    the way to work or an occupational disease retains, at the employer's expense, the right to
    his remuneration for the first 30 days of incapacity for work. The daily allowances relating
    to this period are paid to the employer by the body responsible for industrial accidents or
    by the Fund for Occupational Diseases.

    Successive disabilities - relapse:
    It is possible that a worker will be unable to work during different successive periods.

    When two incapacities follow one another without interruption (for example, accident followed by
    illness; successive illnesses of a different nature), there is only one period of incapacity and
    the guaranteed remuneration is not due again. time.

    On the other hand, we talk about relapse when a new disability occurs after the worker has returned
    to work normally.

    In this case, the guaranteed remuneration is not due again when the new incapacity for work occurs
    within the first 14 days following the end of a period of incapacity for work giving rise to the
    payment of the guaranteed remuneration.

    However, there is still a right to the guaranteed salary for the part remaining to run, if the first
    period of incapacity has not exhausted the entire right to the guaranteed salary during the first
    period of incapacity. A new guaranteed wage is also due again when the worker establishes by a
    medical certificate that this new incapacity for work is due to another illness or to another
    accident.

- 17/ hr_work_entry_contract: Define 1 leave work entry per presence

    Purpose:
    Some sick time off have to be defined into different work entry types, according
    to the type of sick leaves.

    Example: after 30 calendar days of sick leaves, the employee is not paid by the
    same organism and therefore, the time off should be reported into different work
    entry types.

    Specification:
    Instead of creating a big work entry per time off, create as many work entries
    as there should have been presence work entries.

- 18/ test_l10n_be_hr_payroll: Add test for full time credit time

- 19/ test_l10n_be_hr_payroll: Add test for out of contract credit time

- 20/ test_l10n_be_hr_payroll: Avoid undeterministic bug on generated tests

- 21/ hr_payroll: Don't display out of contract line on pdf

- 22/ test_l10n_be_hr_payroll: Fix undeterministic test crashes

- 23/ payroll : Improve the printed payslip report

    Improves the design of the payslip report
    Generates the report in the employee's language (add a message if the lang is not official)
    Adds some data to Laurie Poiret
    Task-2341886

- 24/ test_l10n_be_hr_payroll_account: Add test for unjustified reasons

- 25/ test_l10n_be_hr_payroll_account: Add tests for small unemployment

- 26/ test_l10n_be_hr_payroll_account: Add tests for half days time off

- 27/ test_l10n_be_hr_payroll_account: Fix false positive

- 28/ hr_holidays: Prevent creating time off of 0 hours

    Purpose:
    It makes no sense + it could cause conflicts when generating the work
    entries

- 29/ test_l10n_be_hr_payroll_account: Add test for end of contract

- 30/ test_l10n_be_hr_payroll_account: Add tests for public holidays

- 31/ hr_payroll: Display amount if hourly wage

- 32/ hr_work_entry_contract: Allow creating record on gantt view

- 33/ l10n_be_hr_payroll: Add new structure for student employees

    Purpose:
    Also bring some fixes on fields display + hours/days counts
    TaskID: 2347843

- 34/ test_l10n_be_hr_payroll_account: Add test for low salaries

    Ensure the correct computation of the employment bonus.

- 35/ l10n_be_hr_payroll: Make separate lines for half/full worked days

    Purpose:
    Worked days should be separated between the complete full days and the
    half days.

    Example:
    I work on Monday, Tuesday, Wednesday (half day)

    The calculation is OK, but the number of days is, in principle, 14 in the month of
    September 2020 (9 full and 5 in half-days). This number of days should be the subject
    of 2 separate lines:

    9 days - 68.4 hours - € 1,100.77
    5 days (in the form of half-days) - 19 hours - 224.33 €.

    In this case, we cannot use the hourly formula since the monthly salary must always be
    the same, without having an identical number of working days.

    The worker benefits from 14 meal vouchers. The number of days must however correspond
    to the number of meal vouchers so that the worker can check.

- 36/ test_l10n_be_hr_payroll: Test credit time with sick leaves

- 37/ test_l10n_be_hr_payroll_account: Test credit time with unpaid leaves

- 38/ l10n_be_hr_payroll: Don't consider time off as credit times

    Purpose:
    When generating the work entries, we compare the standard attendances
    (i.e. the full time contract) and the credit time attendances to
    deduct the intervals on which the employee is on credit time.

    But if the employee is on a time off during a period, those intervals
    will be removed from the supposed attendances, and then those periods
    are considered as credit time.

- 39/ l10n_be_hr_payroll: Fix credit time amount on payslip computation

    Purpose:
    The time credit days must not include a corresponding amount.

    In fact, no remuneration is linked to the taking of time credits. The necessary modifications
    are:
    Code LEAVE300 -> no amount

- 40/ hr_payroll: Export standard calendar if needed on payslip export

- 41/ l10n_be_hr_payroll: Fix worked days lines amount computation

    Purpose:
    The amount was computed as a simple ratio based on the number of days.

    To be correct and compliant with the law, we should consider the hourly
    equivalent wage, and compute the amount based on the worked hours.

- 42/ l10n_be_hr_payroll: Fix unpaid worked days amount computation

    Purpose:
    Don't use the normal wage which is an integer btw.

    Compute the worked days amount using the classic hourly computation formula

- 43/ l10n_be_hr_payroll: Fix unpaid leaves retenues formula

    Purpose:
    Unpaid leave must be deducted from the usual gross monthly salary
    up to the number of working hours concerned.

    The formula is in principle the following:
    gross monthly salary * 3/12/38 -> “usual” hourly salary.

    So, in the case of 2 days of unpaid leave, corresponding to 15.2 hours,
    the formula is as follows: 2650 * 3/13/38 * 15.2 = 244.61 €.

    The gross for the days actually worked is € 2,650 - € 244.61, or € 2,405.39

- 44/ hr_payroll: Generate python test from arbitrary payslip

    When the payroll is incorrect, the feedback that we receive is
    generally: "this doesn't work".

    This commit add a route in the controller of hr_payroll, to export
    in a python file, all data useful to reproduce the exact employee
    situation about the incorrect payslip.

    Before testing and fixing the incorrect payslip, we need to anonymize all
    sensitive data about the employee. This commit converts all sensitive
    data into demo data.

    This commit add a button in payslip form view to use the new route to
    export all data about the incorrect payroll.

    This button is only displayed when we are in debug mode and the current
    user is a payroll manager.
    task-2337786

closes odoo/odoo#60136

X-original-commit: 60eaecb749ad68429e4d8ba00ff0200c3360cdcb
Related: odoo/enterprise#14147
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-10-15 19:54:53 +00:00
Martin Trigaux e79531c136 [I18N] *: export 14.0 source terms
Including demo data this time

closes odoo/odoo#58862

X-original-commit: 575abde110acb3d12b25f177a863374becef0894
Related: odoo/enterprise#13705
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-29 17:52:02 +00:00
Victor Feyens 594ccdcbf4 [FIX] *: typos and english incoherences
Mainly transifex issues but also some errors found through 'grep' checks.

Fix typos and obscure english strings in xml contents, fields strings/helps, some docstrings, ...
ensuring correct translations base (and fallback when translations isn't available).

closes odoo/odoo#57276

X-original-commit: 4214f05d454bca2b60fda3a288d529c098e84f77
Related: odoo/enterprise#13053
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-09-08 18:12:26 +00:00
alt-odooandPierreCourt e8f81ae39c [FIX] resource: attendance intervals should be expressed in resource timezone
closes odoo/odoo#57053

X-original-commit: efec3e57c2eeda188e0dd2cc7c7413987d58513e
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
Co-authored-by: PierreCourt <pco@odoo.com>
2020-09-03 15:20:09 +00:00
Martin Trigaux 90d85eb9c5 [I18N] export saas-13.5 source terms
Without demo data

closes odoo/odoo#56869

X-original-commit: 33f251b6489455cd7221f2c62dee0400a69784b8
Related: odoo/enterprise#12836
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-01 11:18:00 +00:00
Arnaud Joset 0cb64fd99c [IMP] resource: improve clarity of two weeks explanations
Before this commit, when two week calendar were used, the tooltip was wrongfully assuming which week were odd and even.
Even with correct information, it was not easy to fill and could easily lead to wrong information on the payroll.

closes odoo/odoo#56055

Taskid: 2308804
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-28 12:26:07 +00:00
Yannick Tivisse 3eec4d6a69 [FW][MERGE] resource,calendar,hr_holidays: Improve the performances
TL;DR
=====

Improve performances with nearly a factor of 2. Use case, call action_validate on hr.leave for 100 employees
- 1987 requests -> 844 requests
- 1300 ms -> 700 ms

Purpose
=======

The first purpose of this commit is to add a test ensuring the number of request while creating
a company leave for 100 employees, if 15 of them already have a leave during that period.

It includes, the mass leave generation, and the conflicts resolutions. (Cancelling/Splitting the
already existing one and adapting the dates accordingly).

The second one is to reduce the number of request for this test.

In term of requests, currently we have:
- 5154 requests without bypassing the mail tracking + the activities management
- 1987 requests when bypassing the mail post-process (this is the current value, the bypassing was
  already done several month ago)
- 844 requests with all the optimization done in resource/calendar/hr_holidays

In terms of execution time, we have a reduction from +- 1300 ms to call the method action_validate
to +- 700 ms

As the performances issues severity increases with the number of leaves to create and the real time access
to the database, on the production base, we reduced the execution time to generate more than 500 hr.leaves
from several minutes to 21 seconds. A fix to avoid deadlock was already made at
https://github.com/odoo/enterprise/pull/10740/files

Some contortions were made to avoid changing a signature method in a stable release and thus
introducing for each method a second one, with the "batched" implementation, to keep a retro-compatibility
for the existing custom code.

But surely this could be cleaned in the master version. The old one will be deprecated while waiting to be
removed in a few versions.

closes odoo/odoo#56534

Taskid: 2256705
X-original-commit: 8c96a887d3f05680c923dcd44f9c70c0e5e0bd32
Related: odoo/enterprise#12670
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-25 15:44:07 +00:00
Kevin Baptiste 71f719a61e [IMP] resource: move unavailable intervals on resource.calendar
The method `_get_unavailable_intervals` was only available on
`resource.resource`. It's now moved to the `resource.calendar`.

closes odoo/odoo#51311

Taskid: 2253893
Related: odoo/enterprise#10616
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-07-02 06:48:45 +00:00
Xavier Morel 6835aeb0de [REM] core, *: deprecate <act_window> and <report>
Convert deprecated tags through the codebase.
2020-07-28 13:03:13 +00:00
Kevin Baptiste c8d496382f [IMP] resource: hide start/end date on resource attendance
This commit sets the fields date_from and date_to as optional hidden on
the resource.calendar.attendace.

closes odoo/odoo#51527

Taskid: 2241686
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-29 11:53:57 +00:00
Lucas Lefèvre 103feca347 [FIX] resource: Find intervals in the resource timezone
With a user with timezone "Europe/Brussels", add a
slot on the gantt view where the preceding day is a working day.
The default starting time will be the previous day.
Reason: the default starting time is midnight, adjusted to
the closest attendance interval in the employee's calendar.
However, midnight in "Europe/Brussels" is actually 10pm UTC
the previous day.
The method adjusting the datetime to the closest attendance only
checks within the corresponding day.

Two ways to fix this:
1) the business code calling `_adjust_to_calendar` should
   timezone the datetimes itself. To avoid similar bugs in the future,
   the method should be modified to only accept timezoned datetimes.

2) Change `_adjust_to_calendar` to convert datetimes it was given
   to the resource's timezone and consider the dates in those converted
   datetimes.

Option 2 is chosen because it seems to take care of the problem at a lower
level which allows the business code to not think about those timezone details.
While this is technically an API change (in a stable release), the method was
introduced recently by b058ca1 as a fix for an already broken method.

closes odoo/odoo#53582

X-original-commit: c6cecac60360a1d8b0c62ee155a818a3a28505e1
Related: odoo/enterprise#11399
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-24 12:35:11 +00:00
Martin Trigaux ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02:00
Lucas Lefèvre 5d50509be8 [FIX] resource: Fail fast if no calendar
The methods `get_work_hours_count` and `_attendance_intervals`
raise a traceback if `self` does not contain a single calendar record.

This commit adds an explicit check for this requirement.

Related PR odoo/enterprise#10593

closes odoo/odoo#51326

X-original-commit: e5d93be382b03c7a9c925b4a2e6be6875843195d
Related: odoo/enterprise#10619
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-05-15 10:47:38 +00:00
Swapnesh Shah 2eecd98679 [IMP] resource: add possibility to archive resource calendar
Before this commit, It was not possible to Hide Working Time or Deleting Working Time if Resource is linked to it.

Now we add, Active field to Hide Working timw without removing it.

closes odoo/odoo#50963

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-05-09 05:24:38 +00:00
Lucas Lefèvre b674e4401d [FIX] resource: Adjust time span to calendar
The method `_get_work_interval` has several problems:

1) The name is not self explanatory in any way

2) It should be defined on the `resource.mixin`

3) It simply does not work (as described in its docstring).
   Here is a simplified example (only concerned about hours):
   Currently, given two attendances: 8-12 and 13-17,
   with parameters start=9 and end=18 it returns (9, 17)
   while it should return (8, 17).

   This leads to strange behaviors in the planning app:
   Given employee A with calendar 8-17 and employee B 8-16.
   Create a planning slot and assign employee A: the start and end times
   are set to 8-17.
   Then assign employee B, the start and end times are correcly set to 8-16.
   Now reassign employee A: the start and end times are not set to 8-17.

Task 2229296

closes odoo/odoo#50804

X-original-commit: 7dfab89bc0025cf6424f00b6992fef1f42463ffe
Related: odoo/enterprise#10426
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: lul-odoo <LucasLefevre@users.noreply.github.com>
2020-05-07 08:22:22 +00:00
Swapnesh Shah 6054f60d51 [FIX] resource: display hours with float_time widget
closes odoo/odoo#50750

X-original-commit: 1bb0f50bf6a04c93b144d889fe1faecfca949c92
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-05-06 11:59:12 +00:00
Jorge Pinna Puissant ed5ab19065 [FIX] resource: week_type for new periods
In a calendar with 2 weeks mode (odd and even), before this commit, all
new created periods (placed in one of the two sections) don't have the
week_type field set. This generates a confusion, because a period that
should be applied only in odd weeks, for instance, it was applied also
in the even weeks.

Now, the new periods will have the week_type field set with the
week_type of the section where is it. Also, an error message is raised
if a period is not in one of the two sections.

opw-2239966

closes odoo/odoo#50478

X-original-commit: 33a62118818952872321591e85403b657380128a
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2020-04-30 13:53:17 +00:00
Yannick Tivisse f9fc55b9fe [FIX] resource: Improve calendar duplicate
Purpose
=======

When duplicating a calendar, duplicate their global time off too.

closes odoo/odoo#49255

Taskid: 2230549
X-original-commit: b1417a8f094331246120ce5f0a5d25db6c6eb8a7
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-04-08 16:02:09 +00:00
Raphael Collet 51c4e6e2fc [FIX] *: invalid parameter 'tracking' on non-mail-thread models 2020-04-07 09:25:08 +00:00
Victor Feyens a3ded9043d [IMP] *: declare ir.rule in noupdate
ir.rule are default values but can be customized based on the
company's policy and needs.
This is typically a record that is in noupdate as should be
customization-friendly.
2020-03-20 16:21:25 +01:00