Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

leaves unit of measure

By
Davide Corio
on 3/7/13, 8:35 AM 1,870 views

it seems that leaves can be requested in days only. if, using date from/to fields on the leave request form, i select 4 hours, openerp counts always 1 day.

is it possible to change this behaviour? are you aware of 3rd party addons that modify this and allow to specify hours instead of days?

1

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/9/13, 7:31 PM

Hi,

perhaps :

menu settings/configuration/sales check box to True for "Allow using different units of measures" and apply

now, in menu sales/configuration you will have a new section "units of measure".

click on this section and you will have days and hours as "working time category".

days is the unit of reference, and hours lower than the unit of reference (warning, just configure one unit of reference by category, there was a bug with this in 6.0, but now ???)

then to compare unit of reference and other (smaller or biggert than unit of reference), use ratio value.

Update :

I'm looking hr holidays code, the problem comes from 2 functions onchange_date_from and onchange_date_to.

In the first if you add value only in date_from, value returned is 8 hours, with working time unit of measure this will correspond to one day (see the ratio days/hours).

if there is date_from and date_to, this will return :

diff_day = self._get_number_of_days(date_from, date_to)
        result['value']['number_of_days_temp'] = round(math.floor(diff_day))+1

here round will convert float to integer with 0 as result for 4 hours, that's why it is add + 1 after round function. This is strange because number_of days has type float ...

I think this is an error ....

Update 2 :

solution here could be, but to test result (not done), by adding 2 decimals to the result :

result['value']['number_of_days_temp'] = round(math.floor(diff_day), 2)

perhaps verify the rest of the code too and just add filter cases for 1/4 day, 1/2 day, 3/4 day.

Hoping that solves your problem.

Bye

unfortunately that setting isn't used by the hr application.

Davide Corio
on 3/10/13, 6:26 AM

Hi, I update my answer. This will explain why you already have 1 day for 4 enter's hours. Bye

Cyril Gaspard (GEM)
on 3/10/13, 7:39 AM

i actually think the reason is that in belgium it isn't possible to ask leaves in hours, then they round them to 1 day

Davide Corio
on 3/10/13, 7:39 AM

I proposed a solution for the 2 functions, but I not verify the rest of the code. Bye

Cyril Gaspard (GEM)
on 3/10/13, 7:48 AM

"i actually think the reason is that in belgium it isn't possible to ask leaves in hours, then they round them to 1 day",, I believe this is an international erp. Bye.

Cyril Gaspard (GEM)
on 3/10/13, 7:52 AM

perhaps to report as a bug ?

Cyril Gaspard (GEM)
on 3/10/13, 8:31 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/7/13, 8:35 AM
Seen: 1870 times
Last updated: 3/16/15, 8:10 AM