[17.0][ADD] hr_timesheet_autofill_project_off
This module disables the project field being automatically filled when a new line is added to a timesheet.
Details about the feature that this module disables on https://github.com/odoo/odoo/commit/ad1b64ab02c5d31087f25c1c7fae64a2659a2249 and a relevant fix on https://github.com/odoo/odoo/commit/623ecff069f360fad7c9583d8008f97459ed6008
According to the description of the so-called improvement, if the last five timesheets belong to the same project then that project is considered a favorite project.
Why five is anybody's guess but the real problem with this is that it induces errors. Inevitably the user will fail to change the project when the automatic selection is incorrect, and book time to another project. If the mistake is not picked before billing then the risk is that the client will do so and then good luck explaining why you are charging them for work done for others.
While the feature might work well for those working on one project at a time, a good number of professional services' users billing on hourly rates juggle between many assignments concurrently so the project that is filled automatically will often be incorrect thus not saving them time while adding the risk explained above.
@miquelalzanillas @lbarry-apsl @BernatObrador @peluko00 @javierobcn @ppyczko @mpascuall
Would you kindly review this PR for me please? Same as my previous request. I of course would be very happy to review any of your PRs.
This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖
Hello @innovara one question: why not overriding default_get() method (https://github.com/odoo/odoo/blob/fb74d9f2d6cc001ac1b5968d8cd81096d721df05/addons/hr_timesheet/models/hr_timesheet.py#L29-L38) instead of invalidating for all _get_favorite_project_id()? Not tested, but you might obtain the same desired behavior, and others that could need use _get_favorite_project_id shouldn't be affected.
Maintainability, I’d say. As far as I can see, _get_favourite_project_id() is only used there. Overriding default_get() would require keeping track of changes to that method upstream, so you’d need to maintain the same code minus the call to _get_favourite_project_id(). With that in mind, I feel this is the better approach. However, if you have any other idea about how default_get() could be overridden without the burden of mirroring the method upstream, please do let me know.
Well, not tested as you'll guess, but my idea for default_get() override should be the following:
def default_get(self, field_list)
result = super().default_get(field_list)
if not self._context.get('default_project_id') and self._context.get('is_timesheet') and result.get("project_id", False):
# project_is filled, and filled by https://github.com/odoo/odoo/blob/22c333d0ed7eba1165f6462e668998d37fcabb73/addons/hr_timesheet/models/hr_timesheet.py#L35
# so, we reset its value
result["project_id"] = False
return result
I see. That would be preferable. I'm testing the proposed change and will update this PR if I don't encounter any issues.
@dalonsod I'm preparing to push a revised version of this PR based on your suggestion. I've been running it for a week without any issues.
I'd like to credit you as a contributor. Would the following be acceptable?
- [Solvos](https://www.solvos.es):
- David Alonso
Looks perfect, thanks!
@pedrobaeza could I kindly ask you to review this PR when you get a chance? I'm happy to make any adjustments if needed. If it looks good and it's merged, I'd like to prepare a port to 18.0 afterwards.
Merging due to the existing reviews and being a new module.
/ocabot merge nobump
This PR looks fantastic, let's merge it! Prepared branch 17.0-ocabot-merge-pr-755-by-pedrobaeza-bump-nobump, awaiting test results.
Congratulations, your PR was merged at 4d820fc3b59970f81d04d01f68115ad4e0aa7f59. Thanks a lot for contributing to OCA. ❤️
Thanks a lot