-
-
Notifications
You must be signed in to change notification settings - Fork 670
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
10.0 public holidays next year #291
Conversation
Hey @jcdrubay, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
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 think it would be useful to let the user select which hr.public.holiday
to replicate, defaulting to the most recent one for each country as it is now; and also let the user choose the year (defaulting to the next).
For example if 2016 was a special year with an additional public holiday for the 150th anniversary of the Italian unification, I'd want to replicate the 2015 Italian holidays to 2017.
<field name="model">public.holidays.next.year.wizard</field> | ||
<field name="arch" type="xml"> | ||
<form string="Create Next Year Public Holidays"> | ||
<footer> |
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 little description here that briefly explains what the wizard does. The empty wizard looks, well, empty
def create_next_year_public_holidays(self): | ||
|
||
ph_env = self.env['hr.holidays.public'] | ||
pholidays = ph_env.search([]) |
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.
why not directly pholidays = self.env['hr.holidays.public'].search([])
, as you never use ph_env
again?
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.
Mainly because of an habit.
But in next commit, it will make it easier to use later if necessary. In the next commit, it will also simplify a bit to avoid code on 2 lines for this:
ph_env = self.env['hr.holidays.public']
pholidays = self.template_ids or ph_env.search([])
Also, I think it will mean less changes if we need to re-use it later on.
If required, I can change, let me know.
last_ph_dict = {} | ||
for ph in pholidays: | ||
|
||
curr_country = ph.country_id and ph.country_id.id or NO_COUNTRY |
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.
idiomatic python: curr_country = ph.country_id.id if ph.country_id else NO_COUNTRY
But you could even put directly the country recordset as the dict keys and skip the check altoghether. This is possible because recordset implements the hash method.
last_ph_country = last_ph_dict.get(ph.country_id, False)
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.
Nice trick! :)
|
||
NO_COUNTRY = 'NO_COUNTRY' | ||
last_ph_dict = {} | ||
for ph in pholidays: |
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.
Maybe a warning/error if no holidays defined?
for last_ph_line in last_ph.line_ids: | ||
|
||
ph_line_date = fields.Date.from_string(last_ph_line.date) | ||
new_date = ph_line_date.replace(ph_line_date.year + 1) |
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.
Very rare to have a public holiday in that day, but if the date is February 29 of a leap year, you'll get ValueError: day is out of range for month
when doing this
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.
Source: http://www.qppstudio.net/monthlyholidays/bank-holidays-february-2016.htm
Handling this rare case will mean quite a lot of complexity because previous or next day might also be a public holiday.
I suggest to block the user with a UserError: "You cannot use a the template of a year that includes public holidays on 29th of February (2016, 2020...), please select a template from another year.". Since I take into account your first comment, the users will be able to select the public holidays from 2015 instead for 2017; I guess it is good enough.
…-hr into 10.0-public-holidays-next-year
…for a specific year, and display a UserError for templates including February 29th.
Thanks @LeartS for your great feedback. I tried to take them into account in the best way. I am a bit scared so about the template and year field on the wizard as they create a lot of complexity for the users. I tried to make it clear on the wizard page with some documentation... Please let me know if you have any additional suggestion. |
<form string="Create Next Year Public Holidays"> | ||
<sheet> | ||
<div> | ||
Use this wizard to create pulic holidays based on the |
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.
s/pulic/public
<group string="Optional"> | ||
<div colspan="2"> | ||
The below optional fields are here only to handle | ||
special situtaions like "2016 was a special year with |
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.
- s/situtaions/situations
- (The 150th anniversary of Italian unification was actually in 2011, I used 2016 in my example just to make it more current 😁 )
- I would put this group under the first one instead of next to it, it looks clumsy:
Or we could even maybe put the two groups in two notebook pages so that the Optional section is "hidden" unless one explicitly clicks on it; while the "Defaults" explanation is immediately displayed. This could make the wizard look simpler and not overload the user with options/fields, what do you think?
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 like your notebook idea 👍
@jcdrubay Thanks for the contribution, good module... |
Yeah! 3 approvals reached 🎉 Thank you everyone 👍 |
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
…_account2 [BSSFL-410] Update product account
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
* [ADD] public holidays: add a wizard to create public holidays for the following year * [REF] odoolint improvements * [REF] adjustments for flake8 and pylint test * Move public holidays menu under Leaves menu. (OCA#290) * [ADJ] hr_public_holidays: take into account the need of several sub-menus * [ADD] Allow the creation of public holidays from a specific template for a specific year, and display a UserError for templates including February 29th. * [REF] removing useless comments * [ADJ] hr_public_holidays: Improving wizard display * [REF] Removing tab characters
Allow the creation of public holidays for next year through a wizard.
Minor odoolint fixes
Note: Recent merged PR#290 has been taken into account.