Commit Graph
60 Commits
Author SHA1 Message Date
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
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 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
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
RomainLibert 9717026dcc [IMP] Resource: Expand testing on timezones
We need to check if resource module takes into account the timezone of
the employee taking a leave and the timezone of the user asking to see
when this employee has taken some leave.

Basically everything should be done in UTC internally and then converted
back to the user's timezone.
2018-02-14 14:43:38 +01:00
RomainLibert bb02b93c3a [IMP] resource: timezone support for global leaves
Purpose
=======

We should add some real timezone support for the global leaves
(resource.calendar.leaves without a resource assigned) currently it is
declared in UTC and never changed to the user or employee timezone.

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

In order to support this, we have to add some choices for the user
defining the global leave. He can specify how the timezone is
configured,
  - no value is specified, we keep the dates in UTC then convert those to
    user timezone
  - current user timezone specified, we set the timezone of the leave to
    the company timezone
  - a timezone is specified, we keep this specific timezone
2018-02-05 14:45:42 +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
Christophe Simonis 34b432d528 [MERGE] forward port branch saas-15 up to 4d79a1ff58 2017-06-26 19:19:39 +02:00
Nicolas Martinelli a74c5a42bc [IMP] resource: add test case
Test case known to be problematic in v10.
2017-06-16 13:25:38 +02:00
Christophe Simonis 2a008d5168 [MERGE] forward port branch saas-15 up to 2f6edfef49 2017-06-15 19:04:51 +02:00
Christophe Simonis 2f6edfef49 [FIX] resource: remove bad test introduced by previous forward-port 2017-06-15 19:00:54 +02:00
Christophe Simonis 1b50c829ef [MERGE] forward port branch saas-15 up to 9713dc2e1f 2017-06-15 18:44:16 +02:00
Christophe Simonis 9713dc2e1f [MERGE] forward port branch saas-14 up to 96595772e0 2017-06-15 18:39:59 +02:00
Thibault Delavallée 8b886bd316 [FIX] resource: fix timezone management when planning hours and days
Low-level methods have to convert datetime into a naive user timezone
in order to match the attendances and leaves. Returned values are already
in UTC ready for display. Therefore no postprocessing is necessary for
output.
2017-06-13 12:40:44 +02:00
Thibault Delavallée 6baa42ed57 [FIX] resource: return correct date when planning hours
Planning hours can be done forwards or backwards. In first case the
returned datetime should be the last one aka the date when the job is
finished. In second case it should be the first one, aka the date when
the job begins. Those are the dates user want to know and manipulate when
programming working hours.

Manual forward port of 577eb10c0b .
2017-06-13 12:30:14 +02:00
Thibault Delavallée 577eb10c0b [FIX] resource: return correct date when planning hours
Planning hours can be done forwards or backwards. In first case the
returned datetime should be the last one aka the date when the job is
finished. In second case it should be the first one, aka the date when
the job begins. Those are the dates user want to know and manipulate when
programming working hours.
2017-06-13 10:56:25 +02:00
xmo-odoo 2e6a589f41 [FIX] builtins removed from Python 3
* Reverse wrapper courtesy of @rco-odoo's original P3 branch
* thin compat module stripped down from werkzeug (to augment as needed)

issue 8530
2017-04-27 13:59:33 +02:00
Thibault Delavallée 9944209ef7 [IMP] resource: add resource mixin adding fields and an API for resource
Purpose is to replace existing inherits of resource.resource by an inherit
on the mixin itself. The mixin offers several methods to compute working
intervals, attendance, hours, ... This mixin will be improved in future
commits when new methods that will be required with future improvements
of various service apps.

This commit also adds tests for the mixin itself. A new model is defined
only for testing purpose to test the mixin.
2017-02-27 14:04:48 +01:00
Thibault Delavallée ff32384b8f [REF] resource: correctly take into account timezones and clean code
Currently timezones were not or incorrectly taken into account in resource
computation. Indeed complexity comes from attendances being expressed in
naive timezones valid for all users, whereas dates and leaves are computed
into UTC. Computation should always be done in user timezone so that there
are no overlapping days and all time intervals are correctly computed.

A new timezone field is added on leaves to know in which timezone they
were originally encoded. Indeed putting them in naive user timezone
require its original timezone, not the current user timezone, as those
can be different.

This commit also contains code cleaning in resource to be a bit more
pythonic, simplify method parameters and offer a more simple api to
other modules.

Eventually code field is removed on resource as it is not really necessary
for resources. It is explicitly added on workcenter model who use it.
2017-02-27 14:04:48 +01:00
Thibault Delavallée ac26fa3dd4 [REF] resource: include attendance and leave info in intervals
Calendar and resource scheduling work on time intervals. However in some
cases it is useful to have info about attendances and / or leaves linked
to those intervals. Internal interval tuples is thus extended to keep
records about resource.calendar.attendance and resource.calendar.leaves.
This will notably allow to remove some hacks in stock_calendar module.
Hooray.
2017-02-27 14:04:48 +01:00
Thibault Delavallée be01aaa99f [REF] resource: remove deprecated compatibility and rename methods
Old methods are still present since a long time and are deprecated since
saas-3. This compatibility layer adds unnecessary complexity to the module
API. Those methods should now be removed. Some renaming is also performed
to ease resource api understanding, notably to better differentiate
internal methods from other methods.

All addons are updated accordingly.
2017-02-27 14:04:48 +01:00
Thibault Delavallée 06f36ddbe9 [REF] resource: remove pseudo-default working hours computation
Companies now always have a default calendar configured. All methods in
resource module should therefore be able to use a real resource.calendar.
This commit removes the computation based on a pseudo 8-17 calendar
given as weird method parameters.

Project is updated in order to use the company calendar by default.
2017-02-27 14:04:48 +01:00
Thibault Delavallée 2b90398cb6 [REF] resource: strengthen link between companies and calendars
Purpose of this commit is to always have a default calendar for each
company and ensure it is correctly set on resources.

Some cleaning is also performed in resource models to remove unused
fields, improve labels and make views a bit more odoo-ish.

 * [REF] res_company: add a m2o to the default calendar to use in the
   company as well as a o2m linking all resource calendars used in the
   company. Some code has been added to correctly update existing
   companies when installing the module;
 * [REF] resource_calendar
  * [REM] manager field on resource.calendar: this field is never used
    and is not necessary anyway
  * [ADD] global_leave_ids: filter leaves on a calendar to see global
    company leaves
  * [IMP] better default company / calendar computation to ensure there
    is always a calendar attached to a resource
  * [IMP] improve resource and calendar views in order to look more like
    other odoo views
2017-01-18 10:26:53 +01:00
Thibault Delavallée 1c4ea80f78 [IMP] resource: clean tests code
This commit cleans resource test code by removing unnecessary stuff
and simplifying code. Purpose is to lessen number of lines and improve
readability of tests. Some duplicated tests have been removed.
2017-01-18 10:24:24 +01:00
qdp-odoo 4f29b77e3d [MERGE] foward port of 10.0 up to revision 84a650e33a 2016-12-30 17:21:25 +01:00
Thibault Delavallée 84a650e33a [FIX] resource: fix computation of limited attendances
Due to an error introduced when migrating the module at new API
at commit a4e57ea16c limited attendances
having date_from and / or date_to were not correctly taken into
account.

Tests have been added to avoid regression.
2016-12-30 16:38:02 +01:00
Raphael Collet ffdafd3f8a [REM] most uses of _model (useless in most cases) 2016-08-16 09:55:46 +02:00
Thibault Delavallée c8a313d51e [IMP] various: use odoo for imports instead of openerp and update class names 2016-08-10 15:48:07 +02:00
Ravi Gohil dc77ed4f90 [MIG] resource: Migrated unittest cases to new api
- Converted yml test cases to python unittest
- now, 'self.calendar' recordset from common.py will carry forward its context
  so no need to pass context explicitely to the methods calling using that recordset.
- removed commented code
- used odoo.fields.Datetime to covert dates instead of python datetime library
2016-07-13 12:53:34 +02:00
Xavier Morel 4a6adff30d [ADD] resource: work day helpers
Add methods to query work days (entire) for resources for systems
working daily insted of hourly.
2016-06-07 17:41:44 +02:00
Christophe Simonis d1a79ec704 [MERGE] forward port of branch saas-6 up to 9363372 2016-02-17 16:28:56 +01:00
Christophe Simonis 9363372efe [MERGE] forward port of branch 8.0 up to 0f46e6a 2016-02-17 16:20:23 +01:00
Adrien Peiffer (ACSONE) b21773456c [ADD] Add test with half hours to compute working hours. 2016-02-16 17:24:39 +01:00
Christophe Simonis 57168a9e90 [MERGE] forward port of branch saas-6 up to a669433 2015-09-23 14:34:26 +02:00
Christophe Simonis 3fd91d4244 [MERGE] forward port of branch 8.0 up to d05ee26 2015-09-22 15:43:12 +02:00
Christophe Simonis d05ee26a72 [MERGE] forward port of branch saas-3 up to 24bcdb7 2015-09-22 15:40:28 +02:00
Christophe Simonis 024177ebc4 [FIX] resource: get_working_intervals_of_day
Use patch from 8.0 (64e1c28e35) instead of
the one from 7.0 (bbd15cdca6).
2015-09-11 18:07:49 +02:00
Christophe Simonis 3bb0cb2a50 [MERGE] forward port of branch 8.0 up to 9c8b99a 2015-09-04 18:30:48 +02:00
Goffin Simon 64e1c28e35 [FIX] resource: get_working_intervals_of_day
To compute start and end date of a working interval this function replaced
hour in datetime object without taking into account the time zone. The start and end date
taking respectively from calendar_working_day.hour_from and calendar_working_day.hour_to are
in the time zone of the user and the datetime object are compared in UTC to avoid schedule's gap.
This is why the start and end must be converted in UTC after being replaced by these hours.
The tz_info must be removed from dates because it's forbidden to compare naive and aware dates.

opw:648349
2015-09-04 10:01:20 +02:00
Christophe Simonis 044c0625ad [MERGE] forward port of branch saas-6 up to 7faf72c 2015-08-31 19:57:20 +02:00
Christophe Simonis 7faf72c024 [MERGE] forward port of branch 8.0 up to 0c1e978 2015-08-31 19:25:37 +02:00
Antonio Espinosa e1d59f8f82 [FIX] resource: Schedule days backwards when days is negative number
Regarding _schedule_days, similar thing was done in
saas-6, @ fd5e7f2.
When the argument `days` was negative, the
returned intervals were wrong.

Regarding `get_working_intervals_of_day`,
calling this method without
`default_interval` and calendar
set crashed.

Closes #8208
2015-08-28 12:33:46 +02:00
Olivier Dony 0bd4545348 [LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate text
- Preserved explicit 3rd-party copyright notices
- Explicit boilerplate should not be necessary - copyright law applies
  automatically in all countries thanks to Berne Convention + WTO rules,
  and a reference to the applicable license is clear enough.
2015-06-02 03:16:04 +02:00
Christophe Simonis 18e22be138 [MERGE] forward port of branch 8.0 up to 0aab81c 2015-01-19 17:15:56 +01:00
Xavier Morel 65cd4a2a33 [FIX] remove deprecated checks/fast_suite test attributes from standard modules 2015-01-15 14:31:40 +01:00