-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
[11.0][MIG] hr_public_holidays > hr_holidays_public #465
Conversation
Hey everybody! something on Odoo changed that makes a test fail. Previously was all green some months ago in the commit of @feketemihai . My changes didn't affect the tests but the PR is red. I can't find what's the cause or what's wrong, so please, can someone help to fix this? |
[BSSFL-556] Propagate lot from sale line to 3 delivery steps
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.
Thank you for this PR! Please check my comments for the code review.
I personally would prefer a pure porting of this module from https://github.com/OCA/hr/tree/10.0/hr_public_holidays to V11, without adding so much other stuff. The module version =< 10 was meant to be a technical module, useful for being extended for further customization. But with the latest PRs this module is becoming something else.
The calculation of the hours should be delegated to a specific module hr_holidays_hour, which migration to V11 is proposed here: #450.
Odoo V12 will have the code for the leave management almost completely rewritten, supporting also the hours calculation, so do we really want to spend so much effort to rewrite the hours management in this module, with the risk to restart all over in V12 (will be released next October 😮 )?
Anyway I will not block this PR if you have different needs, just think about it.
from datetime import date | ||
|
||
from odoo import api, fields, models, _ | ||
from odoo.exceptions import Warning as UserError |
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.
Just use:
from odoo.exceptions import UserError
import logging | ||
|
||
from odoo import api, models, fields, _ | ||
from odoo.exceptions import Warning as UserError |
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.
from odoo.exceptions import UserError
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.exceptions import ValidationError | ||
from odoo.exceptions import Warning as UserError |
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.
from odoo.exceptions import UserError, ValidationError
<field name="model">hr.holidays.public</field> | ||
<field name="arch" type="xml"> | ||
<tree string="Public Holidays"> | ||
<field name="year"/> |
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.
Could you replace <field name="year"/>
with <field name="display_name"/>
here?
|
||
<notebook> | ||
<page name="defaults" string="Defaults"> | ||
<div> |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
show_full_days = fields.Boolean( | ||
string="Show Full Days", | ||
related="holiday_status_id.compute_full_days") | ||
number_of_hours_temp = fields.Float( |
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.
Shouldn't this module inherit from hr_holidays_hour
? The module hr_holidays_hour
already defines those fields for managing the hours. There would be an overall simplification of code by inheriting from hr_holidays_hour
, for example you could take advantage of methods for the conversion to hours, the onchanges and the views.
Migration of hr_holidays_hour
to V11 is proposed here: #450.
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.
Ok, I will wait then until that module is merged.
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.
@astirpe I have been reviewing the module hr_holidays_hour
and the dependency should be just the contrary: to add public holidays, we don't need to make the computation by hours first, but to adjust current Odoo core methods for obtaining the days in float. The hour one should go on top of this. I'm reviewing right now this one and proceed to merge for unlocking this, but I'm available to review any adjustment you need to make over this one for correctly pasting both together. I hope you understand.
9d3b5bf
to
4b61577
Compare
…Management modules
[MIG] hr_public_holidays
[MIG] hr_public_holidays/hr_holidays_compute_days: port to 10.0
* [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
* hr_public_holidays: use group 'hr_holidays.group_hr_holidays_manager' * hr_public_holidays: Update README.rst
Add correct calculation of holidays in hr_public_holidays, instead of hr_holidays_compute_days. Remove dependancy of contracts. Add unlink at onchnage of public holiday lines. Update code. Fix flake. Update code, add calculation in hours, update views. Update flake. Update calendar creation with no attendances, otherwise default values were set. Remove config of show days/hours. Update flake. Update readme. Rename module. Updated holiday reports. Update klake and pylint. Update flaket. Update hr_holidays_views.xml Add readonly to show_full_days. Update code according with comments. Increase coverage. update flake8.
4b61577
to
ff3a6c4
Compare
After been thinking about this a lot, this is the best option I have found:
I'm implementing this tomorrow. What do you think? |
@pedrobaeza I would prefer to keep |
OK, no problem, as stated, you can do it repeating some of the code. Just take a look for not screwing up inheritance for allowing the installation of the 3 of them. |
@mreficent I'm doing the other changes, but thanks for the lint fixup. |
Hours part will be in module hr_holidays_hour.
* Squash commits into a single one. * Update tests with old onchange methods. * Fix variable name in tests.. * Update tests. * Update flake8. * Update security rules so that employee can read his schedule and contract, and hr manager to have the same rigths as defined in hr_contract. * Improve onchange employee, add tests for onchange. * Fix flake, whitespaces.
[MIG] hr_public_holidays/hr_holidays_compute_days: port to 10.0
the name collision between _compute_number_of_days defined in this addon and the method for the field number_of_days computation in the base addon hr_holidays caused the latter to not be called => the field number_of_days would be 0 for holidays allocation, and have the wrong sign for holidays request (because it was forced in the the reimplemented version. This patch: * adds tests for the expected value of number_of_days * adds a test for the behavior of the method for holidays allocation * renames the method _compute_number_of_days to _recompute_number_of_days
* To not depend on hr_contract. Working times are set also in employee, and v11 rely on this data, not in contract working time. This simplifies also the code. * To not include all the checks while selecting start or end leave date. At the end, it's the same for you: what counts is the number of leave days. As the compute algorithm already handles overlapping leaves, rest days and public holidays, there's no problem with this. * It handles fraction of days!! New algorithm put the part of the working day that you are leaving. There's a new option at leave type level for keeping the behavior of including full days. This option is checked by default also for keeping backwards compatibility. This code has been made similar to v11. * It includes UI helps for being better to select dates in the form view, allowing to select only dates instead of date + time. * The number of days is not manually modifiable by leave users, but to leave managers. If this behavior is not desirable, you can manually add other groups to the view, as this won't be overwritten with module update.
97e9593
to
bec5b57
Compare
I have finished the adaptation, reducing the code to the minimal and decoupling all modules from each other. I think it has been a good job 😃 For handling module renaming in OpenUpgrade, there's OCA/OpenUpgrade#1509 |
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.
Review of module hr_holidays_public only
<form string="Public Holidays"> | ||
<group> | ||
<field name="year"/> | ||
<field name="country_id"/> |
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.
We already have a module that extends this one. Would be nice if you write this block this way (to ease the extensions):
<group>
<group name="name">
<field name="year"/>
<field name="country_id"/>
</group>
<group name="extra">
</group>
</group>
|
||
<odoo> | ||
|
||
<record id="holidays_public_next_year_wizard_view" model="ir.ui.view"> |
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.
Could you indent the records more to the right, making this xml consistent with the other views?
'state_id', | ||
'Related States' | ||
) | ||
calendar_leave_id = fields.Many2one( |
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 this field was added?
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.
No idea...
) | ||
else: | ||
obj = self | ||
return super(HrHolidays, obj,)._get_number_of_days( |
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.
Could you remove the trailing comma after obj
?
Hehe, you have just reviewed the untouched part. Checking the comments... |
bec5b57
to
e40d5a2
Compare
Reduce to the minimum the footprint of this module, adding only public holidays as leaves in a transparent way by other modules.
This has been totally reworked for decoupling parts, not depending now on hr_holidays_public, and making transparent its use for compatibility with other modules.
e40d5a2
to
f9f51f9
Compare
Changes done |
Thanks! We are not using Module |
I think we are going to move forward, and if any problem, we can fill new PRs. This is done for not interfering with your module, so I don't think you will find troubles. |
Superseeds #401.
cc @Tecnativa