-
Notifications
You must be signed in to change notification settings - Fork 117
[FIX] hr_holidays: dynamic accrual days #4904
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
base: master-hr-onboarding-haabo
Are you sure you want to change the base?
[FIX] hr_holidays: dynamic accrual days #4904
Conversation
|
This PR targets the un-managed branch odoo-dev/odoo:master-hr-onboarding-haabo, it needs to be retargeted before it can be merged. |
3207f98 to
d7d62df
Compare
Mahmoudk3m
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work 🚀
Just a few comments.
| let date = new Date(2024, selectedMonth, 0); | ||
| let days = date.getDate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let date = new Date(2024, selectedMonth, 0); | |
| let days = date.getDate(); | |
| const date = new Date(2024, selectedMonth, 0); | |
| const days = date.getDate(); |
Use const instead of let where values don't change:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| const selectedMonth = this.props.record.data[this.props.selectedMonth]; | ||
| let date = new Date(2024, selectedMonth, 0); | ||
| let days = date.getDate(); | ||
| let newChoicesList = Array.from({length: days}, (_, i) => [(i + 1).toString(),(i + 1).toString()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let newChoicesList = Array.from({length: days}, (_, i) => [(i + 1).toString(),(i + 1).toString()]) | |
| let newChoicesList = Array.from({length: days}, (_, i) => [(i + 1).toString(), (i + 1).toString()]) |
missing space after comma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
| get options() { | ||
| const selectedMonth = this.props.record.data[this.props.selectedMonth]; | ||
| let date = new Date(2024, selectedMonth, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a comment to explain why I used 2024 specifically, because it might be a bit confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
|
|
||
| get options() { | ||
| const selectedMonth = this.props.record.data[this.props.selectedMonth]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If selectedMonth is undefined or invalid, this could fail silently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a condition to prompt the user and not give him any day options to select from
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user has selected "31" for the day and then changes the month to one with only 30 days, what happens? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The widget automatically adjusts I think it's because it's watching on the selectedMonth prop to recall the function on change
8724928 to
fdc2c51
Compare
d7d62df to
ac4b195
Compare
| if (isNaN(selectedMonth) || selectedMonth < 1 || selectedMonth > 12){ | ||
| alert("Please select a valid month."); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using alert is not really standard for Odoo. You could raise an error if you want to do that.
What I had meant was to just check if it exists before the condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Changed the {day} dropdown to adapt to the selected month. It was previously set to 31 for all months which allowed the user to select the 31st on a 28 or 30 day month for example.
task-5392293
ac4b195 to
fd32130
Compare
Changed the {day} dropdown to adapt to the selected month. It was previously set to 31 for all months which allowed the user to select the 31st on a 28 or 30 day month for example.
task-5392293