[IMP] hr_holidays: cap carryover day selection based on month - #5239
[IMP] hr_holidays: cap carryover day selection based on month#5239amgom-odoo wants to merge 1 commit into
Conversation
|
This PR targets the un-managed branch odoo-dev/odoo:master-hr-onboarding-amgom, it needs to be retargeted before it can be merged. |
Introduce a new widget to cap the carryover day selection based on the selected month Task: 6459855
cd44b77 to
d8c84d2
Compare
lebm-odoo
left a comment
There was a problem hiding this comment.
Hellooo, nice widget. Some little points otherwise it's already good 😄
| const monthMaxDays = { | ||
| "1": 31, "2": 29, "3": 31, "4": 30, "5": 31, "6": 30, | ||
| "7": 31, "8": 31, "9": 30, "10": 31, "11": 30, "12": 31 | ||
| }; |
There was a problem hiding this comment.
Maybe you can try to make it prettier, something should exists to get the last day of a given month without hardcoding it 👀 (using luxon or standard js Date 🤷♂️)
| supportedOptions: [ | ||
| ...(selectionField.supportedOptions || []), | ||
| { name: "month_field", type: "string" } | ||
| ], | ||
|
|
||
| extractProps: (fieldInfo, dynamicInfo) => { | ||
| const props = selectionField.extractProps(fieldInfo, dynamicInfo); | ||
|
|
||
| if (fieldInfo.options && fieldInfo.options.month_field) { | ||
| props.monthField = fieldInfo.options.month_field; | ||
| } | ||
|
|
||
| return props; | ||
| } |
There was a problem hiding this comment.
It's good, you can use attrs too. options are more used to set multiples values that will be evaluated. and attrs will be just string. so in your case, an attr is more adapted here I think 👀
And don't forget to add fieldDependencies, so that you'll not be forced to add the field in the view in invisible to be able to retreive it in the js record. 😄
| export class CarryoverDaySelection extends SelectionField { | ||
| props = useProps(); | ||
|
|
||
| get options() { |
There was a problem hiding this comment.
it's a good practice to add
/**
* @override
* /
get options(){As it comes from SelectionField
Introduce a new widget to cap the carryover day selection based on the selected month
Task: 6459855