Commit Graph
82 Commits
Author SHA1 Message Date
Christophe Simonis 7717f082c0 [MERGE] forward port branch saas-11.3 up to af35aea6b0 2018-08-09 19:33:32 +02:00
Christophe Simonis 33e7479865 [MERGE] forward port branch saas-11.2 up to d7e2c767ce 2018-08-07 13:59:40 +02:00
Christophe Simonis d7e2c767ce [MERGE] forward port branch 11.0 up to 3513e599a7 2018-08-07 13:58:20 +02:00
Richard Mathot c5d95f1b37 [FIX] resource: don't lose minutes anymore
In resource.calendar.attendance, we store the start and end hour of an
interval as floats.

eg: 17 hours 9 minutes is stored as 17.15

When converting this float to a datetime object, the method
float_to_time always rounds down the value, which may be wrong if, due
to float imprecisions, 0.15 hours is converted to 8.999... minutes (and
was then rounded to 8).

We do fix this behaviour by rounding to the closest integer.

Thanks to @jem-odoo for his help troubleshooting this issue.

opw-1872166
2018-08-07 07:36:49 +02:00
Christophe Simonis c302a90b6e [FIX] resource: oversights of previous forward-port 2018-06-28 21:50:23 +02:00
Christophe Simonis c8bb02141d [MERGE] forward port branch saas-11.3 up to 3cdcbce93c 2018-06-28 19:01:52 +02:00
Christophe Simonis 40836194c2 [MERGE] forward port branch saas-11.2 up to 12ddec3a76 2018-06-27 13:41:00 +02:00
Christophe Simonis 68326b15f9 [MERGE] forward port branch 11.0 up to c5ed372970 2018-06-21 12:18:40 +02:00
Nicolas Martinelli f90434b96c [FIX] resource: 24h shift
Create a resource working 24 hours / day.
If we record it as:
- From 00:00 ; To 24:00 => crash
- From 00:00 ; To 23:59 => 1 minute lost

The `float_time` widget doesn't allow to be more accurate than 1 minute,
therefore it is not possible to record an end time of 23:59:59.999999.
We allow a value of 24:00 which is automatically interpreted as
23:59:59.999999. Only 1 microsecond is lost for such use case, which
should be acceptable for our level of accuracy.

opw-1856943
2018-06-21 09:20:33 +02:00
Raphael Collet d3e2cf5585 [FIX] resource: methods plan_* can return naive datetimes
Make those methods return a datetime in the same (naive or aware) timezone as
their argument.
2018-06-19 16:44:56 +02:00
RomainLibert b6642f1b70 [IMP] hr_holidays: add support for taking leaves differently
We would like to be able to take leaves using different units, currently
we only support taking leaves by hours because we use datetimes.

We need to support three units:
 * days
 * half days
 * hours

These units will be defined on the leave type.

Task #40995
Closes #21760
2018-06-06 17:04:07 +02:00
Raphael Collet a058bf18d3 [FIX] resource: field tz defaults to UTC if no timezone found 2018-06-01 18:27:52 +02:00
Raphael Collet 975c6c8639 [REF] resource calendar (#24717)
Refactor resource calendar and resource mixin:
 - add a required timezone field on models 'resource.calendar' and 'resource.resource';
 - resource calendar attendances are now computed in the timezone of the resource
   or the calendar;
 - improve API of 'resource.calendar' and 'resource.mixin';
 - avoid other modules from using the implementation methods of 'resource.calendar';
 - refactor implementation of 'resource.calendar' to make it more efficient.
2018-05-31 20:28:12 +02:00
Benjamin Stiens 6383120f3b [IMP] all: Improve error messages
Many error messages are misleading or too "vague"
This task aims to improve all error message.

Task #47042
PR #23321
2018-05-28 16:45:48 +02:00
Christophe Simonis 0f57bdba72 [MERGE] forward port branch saas-11.2 up to 42659dc70c 2018-03-09 16:25:58 +01:00
Christophe Simonis 36945a5853 [MERGE] forward port branch 11.0 up to c2e878e34c 2018-03-01 19:43:25 +01:00
Christophe Simonis e5987434c6 [MERGE] forward port branch saas-15 up to 9cfd4a5c07 2018-02-22 19:06:31 +01:00
Nicolas Martinelli 5ce76a0e70 [FIX] hr_payroll, resource: no attendances
Method `get_day_work_hours_count` can return 0 if no attendance is found
in the calendar. Therefore, we must make sure to not divide by zero,
otherwise, boom boom.

Closes #22900
opw-1815095
2018-02-22 16:32:43 +01:00
Duc Dao ad3cc1b231 [FIX] resource: Fix default empty timezone
Since the method `_get_leave_intervals` assumed that field `tz` is always filled in.
There is a case in default function, when `self._context` had key `tz` but its value was `False`,
which may causes null value of field `tz` and lead to mismatch interval between leave and payslip
2018-02-22 14:09:49 +01:00
RomainLibert 05bb9848a2 [IMP] resource: add time_type field on resource.calendar.leaves
We would like to have an overview of project forecast that include
leaves, for this we need to implement several kind of 'leaves' directly
in resource module.

These kind of 'leaves' can be defined via the hr.leave.type model (only
visible in base.group_no_one (choices currently are 'leave' and 'other')

    * Add field time_type on resource.calendar.leaves
    * Add a domain restriction that allows for filtering on this field
    * Add tests
2018-02-19 10:43:25 +01:00
RomainLibert 6d870463d0 [IMP] resource: Add possibility to pass in a domain
It will enable to retrieve data from the resource module based on a
domain that we pass to the model. It can be used in order to filter on
certain leave types only.

  * In resource_mixin and resource add a way to use a domain in order to
  filter the leaves
  * In resource_mixin add a method to get the work/leaves hours count
2018-02-19 10:43:25 +01:00
Christophe Simonis 806f42b065 [MERGE] forward port branch saas-11.2 up to 8b9e854be4 2018-02-15 13:46:23 +01:00
Christophe Simonis 3b959c313d [MERGE] forward port branch saas-11.1 up to a277b58507 2018-02-15 11:52:10 +01:00
Christophe Simonis a277b58507 [MERGE] forward port branch 11.0 up to 259686ba78 2018-02-15 10:58:08 +01:00
RomainLibert b4bda28f0d [FIX] resource: _get_leave_intervals
We were using start_datetime instead of end_datetime. Which resulted
into wring results if we passed in datetimes with different date parts.
2018-02-14 16:53:00 +01:00
qdp-odoo 4a3df5256a [FIX] *: fixed decorators on copy() 2018-02-09 10:32:23 +01:00
Martin Trigaux 20f2de8296 [FIX] resource: prevent adding wrong hours
e.g. negative hours, over 24h, start > end

Task id: 36965
opw-802816
Closes #20449
2018-02-06 19:58:42 +05:30
Kirti Choudhary 1ce899d118 [IMP] resource: Set company_id on a resource.calendar on company creation
Purpose
=======

Currently, when creating a company, the resource calendar is created if not specified.

This lead to duplicated data. In Manufacturing > Configuration > Working Time, two same working time demo data('Standard 40 Hours/Week')

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

Company should be correctly set in the calendar.
2018-02-05 09:40:41 +01:00
Christophe Simonis e00a447e2c [MERGE] forward port branch saas-11.1 up to 7e469eb77a 2018-02-01 18:20:28 +01:00
Christophe Simonis 7e469eb77a [MERGE] forward port branch 11.0 up to f5e7b86686 2018-02-01 18:15:21 +01:00
RomainLibert a5cbf2105c [FIX] resource: _interval_and not working with disjoint intervals
When we pass two disjoint intervals the behaviour of _interval_and is a
little strange, it returns an interval wich begins after it finishes.
In order to fix that we return None when the intervals are disjoint.
2018-01-30 17:38:30 +01:00
jem-odoo 8386773a5b [IMP] resource: define a conversion factor hour to day on working calendar
Using a working calendar, you might want to know
how much hour correspond a work day. This depends
of you working calendar. This might be usefull to
compute leave duration (half a day is not 8 hours,
but 4).

The hours_per_day field is not computed as the
average of working hour of all work day of calendar
to allow customization. By default, it is 8, as
the default attendances are the one from the
40h/week calendar.

A constant is also available to handle case where
resource calendar is not available.
2018-01-29 10:10:46 +01:00
Christophe Simonis 88a87240a6 [MERGE] forward port branch saas-11.1 up to 8613724bfc 2018-01-25 17:38:41 +01:00
Christophe Simonis cb50970f3f [MERGE] forward port branch 11.0 up to eefe879a37 2018-01-25 15:41:45 +01:00
RomainLibert 894229c268 [FIX] resource: Fix annoying bug with timezones
When encoding global leaves, we put the timezone of this particular
leave to False, which raises an exception when given directly to pytz.

Simple solution is to pass 'UTC' in case we receive False. This
behaviour might be improved in master later.
2018-01-24 14:01:27 +01:00
Raphael Collet 2304edd46c [IMP] *: avoid non-stored dependencies 2018-01-12 15:00:01 +01:00
Christophe Simonis 55b810dc70 [MERGE] forward port branch saas-11.1 up to 726b91b9fb 2018-01-03 14:05:48 +01:00
Christophe Simonis 362f0489d0 [MERGE] forward port branch 11.0 up to fe22a0f9ca 2018-01-03 12:28:52 +01:00
Martin Trigaux cab7e0d204 [FIX] *: add missing space in multilines messages
Courtesy of @Yenthe666
2018-01-03 11:09:09 +01:00
Barad Mahendra b1402c6ad5 [FIX] resource: Allow 'Access Rights' users to create companies
Purpose
=======

A 'Access Rights' (group_erp_manager) user can create a company
A 'Settings' (group_system) user can create a resource.calendar

With the resource module, if a resource.calendar is not set on the new company values, a default one is create.

As the 'Access Rights' user can create a company, but can't create a resource calendar, this should be done with sudo.
2017-12-21 15:09:50 +01:00
Christophe Simonis 29590a61cd [MERGE] forward port branch 11.0 up to 8fb25e185b 2017-11-28 16:57:58 +01:00
Christophe Simonis 5851a69aa3 [MERGE] forward port branch saas-16 up to 3f66814a0d 2017-11-28 15:12:31 +01:00
Christophe Simonis 3f66814a0d [MERGE] forward port branch saas-15 up to 09badbed98 2017-11-28 13:37:35 +01:00
Thibault Delavallée c129b91b6d [MOV] base: move res_* models into models/ 2017-11-27 11:15:00 +01:00
Simon Lejeune d7d9603f1b [FIX] resource: mixin: copy
When copying a record implementing the resource mixin, the linked
resource should be copied too and not shared across the records.

Fixes #20956
opw-781508
2017-11-20 09:19:07 +01:00
Christophe Simonis 10128fa7e8 [MERGE] forward port branch saas-16 up to dc2a6c6cd2 2017-10-20 19:27:04 +02:00
Christophe Simonis 25e65d2bcb [MERGE] forward port branch saas-15 up to 8096162bee 2017-10-18 16:57:35 +02:00
Nicolas Martinelli a13120c039 [FIX] resource: default TZ
If TZ is not set on a user, the creation of a `hr.leave` won't populate
the `tz` field of the associated `resource.calendar.leaves` record.
However, the method `_get_leave_intervals` assumes that field field is
always filled in.

Set the TZ to UTC as a fallback.

opw-777031
2017-10-17 16:38:45 +02:00
Christophe Simonis 017ee5eab3 [MERGE] forward port branch saas-17 up to 877e709871 2017-08-24 13:17:53 +02:00
Xavier Morel f315ea4b71 [FIX] resource: P3 rounding issue 2017-08-23 14:34:50 +02:00