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] beesdoo_shift: forbid illegal hour #292

Open
wants to merge 1 commit into
base: 12.0
Choose a base branch
from

Conversation

tfrancoi
Copy link
Contributor

It was possible to encode shift that start at negative hour
or hour bigger then 24. Of course this lead to some
error at the moment we generate the planning for a given date

  • Add a constraint on start_time and end_time
  • Fix onchange on duration: duration was not computed properly
    when the start or end time was 00:00

It was possible to encode shift that start at negative hour
or hour bigger then 24. Of course this lead to some
error at the moment we generate the planning for a given date

- Add a constraint on start_time and end_time
- Fix onchange on duration: duration was not computed properly
when the start or end time was 00:00
@codecov-commenter
Copy link

Codecov Report

Merging #292 (6a36584) into 12.0 (fa7306c) will decrease coverage by 0.00%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             12.0     #292      +/-   ##
==========================================
- Coverage   68.53%   68.53%   -0.01%     
==========================================
  Files         107      107              
  Lines        3366     3369       +3     
  Branches      589      590       +1     
==========================================
+ Hits         2307     2309       +2     
  Misses        951      951              
- Partials      108      109       +1     
Impacted Files Coverage Δ
beesdoo_shift/models/planning.py 82.05% <40.00%> (-0.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa7306c...6a36584. Read the comment docs.

@api.onchange("start_time", "end_time")
def _get_duration(self):
if self.start_time and self.end_time:
self.duration = self.end_time - self.start_time
self.duration = (self.end_time or 0.0) - (self.start_time or 0.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather return False when start_time or end_time instead of these weird values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.duration = (self.end_time or 0.0) - (self.start_time or 0.0)
if self.start_time and self.end_time:
self.duration = self.end_time - self.start_time
else:
self.duration = False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants