Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] base: float_time #32834

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
3 participants
@nim-odoo
Copy link
Contributor

commented Apr 19, 2019

  • Record a timesheet entry of '00:14'
    => it is correctly saved as 0.23333...
  • Select the entry, and print 'Timesheet Entries'

The tmesheet appears as '00:13'.

This is because minutes is equal to 13.99999999999998, which is
truncated to 13 at formatting.

A simple call to round is enough to prevent this.

opw-1969149

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@nim-odoo nim-odoo self-assigned this Apr 19, 2019

@nim-odoo nim-odoo added the OE label Apr 19, 2019

@nim-odoo nim-odoo requested a review from nle-odoo Apr 23, 2019

@nle-odoo
Copy link
Contributor

left a comment

Alright.

And this is what is done in the equivalent JS widget (with Math.round around the minutes):

function formatFloatTime(value) {
var pattern = '%02d:%02d';
if (value < 0) {
value = Math.abs(value);
pattern = '-' + pattern;
}
var hour = Math.floor(value);
var min = Math.round((value % 1) * 60);
if (min === 60){
min = 0;
hour = hour + 1;
}
return _.str.sprintf(pattern, hour, min);
}

so now both have the sale calculation

but I think we also need the case of 60 minutes after rounding

[FIX] base: float_time
- Record a timesheet entry of '00:14'
  => it is correctly saved as 0.23333...
- Select the entry, and print 'Timesheet Entries'

The tmesheet appears as '00:13'.

This is because `minutes` is equal to `13.99999999999998`, which is
truncated to `13` at formatting.

A simple call to `round` is enough to prevent this. Moreover, we add a
check to convert 60 minutes into an hour. This is similar to:

https://github.com/odoo/odoo/blob/a73206c0b1b1519aef4e7f11d83b6a2fc31eca47/addons/web/static/src/js/fields/field_utils.js#L205-L218

opw-1969149

@nim-odoo nim-odoo force-pushed the odoo-dev:11.0-opw-1969149-float_time-nim branch from 4e99af9 to 6ce6a3c Apr 23, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Apr 23, 2019

@nim-odoo

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

robodoo r+

robodoo pushed a commit that referenced this pull request Apr 24, 2019

[FIX] base: float_time
- Record a timesheet entry of '00:14'
  => it is correctly saved as 0.23333...
- Select the entry, and print 'Timesheet Entries'

The tmesheet appears as '00:13'.

This is because `minutes` is equal to `13.99999999999998`, which is
truncated to `13` at formatting.

A simple call to `round` is enough to prevent this. Moreover, we add a
check to convert 60 minutes into an hour. This is similar to:

https://github.com/odoo/odoo/blob/a73206c0b1b1519aef4e7f11d83b6a2fc31eca47/addons/web/static/src/js/fields/field_utils.js#L205-L218

opw-1969149

closes #32834

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>

robodoo pushed a commit that referenced this pull request Apr 24, 2019

[FIX] base: float_time
- Record a timesheet entry of '00:14'
  => it is correctly saved as 0.23333...
- Select the entry, and print 'Timesheet Entries'

The tmesheet appears as '00:13'.

This is because `minutes` is equal to `13.99999999999998`, which is
truncated to `13` at formatting.

A simple call to `round` is enough to prevent this. Moreover, we add a
check to convert 60 minutes into an hour. This is similar to:

https://github.com/odoo/odoo/blob/a73206c0b1b1519aef4e7f11d83b6a2fc31eca47/addons/web/static/src/js/fields/field_utils.js#L205-L218

opw-1969149

closes #32834

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>

@robodoo robodoo added merged 🎉 and removed merging 👷 labels Apr 24, 2019

@robodoo

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2019

Merged, thanks!

@robodoo robodoo closed this Apr 24, 2019

@nim-odoo nim-odoo deleted the odoo-dev:11.0-opw-1969149-float_time-nim branch Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.