Skip to content
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

[18.0][MIG] hr_timesheet_task_required: Migration to 18.0 #730

Open
wants to merge 40 commits into
base: 18.0
Choose a base branch
from

Conversation

HeliconiaSolutions
Copy link

No description provided.

adrienpeiffer and others added 30 commits January 2, 2025 18:29
Currently translated at 100.0% (9 of 9 strings)

Translation: timesheet-14.0/timesheet-14.0-hr_timesheet_task_required
Translate-URL: https://translation.odoo-community.org/projects/timesheet-14-0/timesheet-14-0-hr_timesheet_task_required/nl_NL/
Currently translated at 66.6% (6 of 9 strings)

Translation: timesheet-14.0/timesheet-14.0-hr_timesheet_task_required
Translate-URL: https://translation.odoo-community.org/projects/timesheet-14-0/timesheet-14-0-hr_timesheet_task_required/fr/
Currently translated at 100.0% (12 of 12 strings)

Translation: timesheet-15.0/timesheet-15.0-hr_timesheet_task_required
Translate-URL: https://translation.odoo-community.org/projects/timesheet-15-0/timesheet-15-0-hr_timesheet_task_required/fr/
Currently translated at 100.0% (10 of 10 strings)

Translation: timesheet-16.0/timesheet-16.0-hr_timesheet_task_required
Translate-URL: https://translation.odoo-community.org/projects/timesheet-16-0/timesheet-16-0-hr_timesheet_task_required/it/
Currently translated at 100.0% (10 of 10 strings)

Translation: timesheet-16.0/timesheet-16.0-hr_timesheet_task_required
Translate-URL: https://translation.odoo-community.org/projects/timesheet-16-0/timesheet-16-0-hr_timesheet_task_required/es/
Copy link
Contributor

@CRogos CRogos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module works as expected.

  1. Commit history is not squashed for commits like oca-ci, ...
  2. There should be 2 commits.
    2.1. [IMP] hr_timesheet_task_required: pre-commit auto fixes
    This commit should contain the yellow maked changes.
    image
    2.2. [MIG] hr_timesheet_task_required: Migration to 18.0
    All the other changes should be in this commit.
  3. The UI has some issues, see comment at the xml file

Comment on lines +11 to +20
<field name="arch" type="xml">
<xpath expr="//block[@name='project_time']" position="inside">
<setting
id="is_timesheet_task_required_setting"
help="Require task selection on each timesheet entry by default"
>
<field name="is_timesheet_task_required" />
</setting>
</xpath>
</field>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Settings UI is not correct:
image

in version 17 it looked like this:
image

Comment on lines 13 to 15
<field name="task_id" position="before">
<field name="is_task_required" invisible="1" />
</field>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be removed because of:

Missing fields used in domains and other attributes are added to the view as invisible automatically. If you encounter fields in views with invisible="True", they can probably be removed.

Comment on lines 26 to 28
<field name="task_id" position="before">
<field name="is_task_required" column_invisible="1" />
</field>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check if this can be removed as well.

<field name="allow_timesheets" position="after">
<field
name="is_timesheet_task_required"
invisible="allow_timesheets == False"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to
invisible="not allow_timesheets"

<setting
id="timesheet_task_settings"
help="Set tasks on timesheet as a mandatory field"
invisible="allow_timesheets == False"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

def _check_timesheet_task(self):
for line in self:
if line.is_task_required and not line.task_id:
raise ValidationError(_("You must specify a task for timesheet lines."))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be changed?

You can replace the call to translate a string ( _ ) with self.env._ for getting some performance improvement in some cases.

is_timesheet_task_required = fields.Boolean(
string="Require Tasks on Timesheets",
related="company_id.is_timesheet_task_required",
readonly=False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attribute is unnecessary?

_inherit = "account.analytic.line"

is_task_required = fields.Boolean(
string="Is Task Required", related="project_id.is_timesheet_task_required"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default string value and can be removed?

@HeliconiaSolutions HeliconiaSolutions force-pushed the 18.0-mig-hr_timesheet_task_required branch from 427cc3e to 14664ac Compare January 15, 2025 10:50
@HeliconiaSolutions
Copy link
Author

The module works as expected.

  1. Commit history is not squashed for commits like oca-ci, ...
  2. There should be 2 commits.
    2.1. [IMP] hr_timesheet_task_required: pre-commit auto fixes
    This commit should contain the yellow maked changes.
    image
    2.2. [MIG] hr_timesheet_task_required: Migration to 18.0
    All the other changes should be in this commit.
  3. The UI has some issues, see comment at the xml file

Hi @CRogos ,

Thank you for the review.

As mentioned, I have cross-checked the migration of the same module in a fresh environment using the steps below:

git checkout -b 18.0-mig-hr_timesheet_task_required origin/18.0
git format-patch --keep-subject --stdout origin/18.0..origin/17.0 -- hr_timesheet_task_required | git am -3 --keep
pre-commit run --all

During these steps, I did not encounter any changes related to the pre-commit hooks, so the migration commit is straightforward. As a result, this PR does not include any pre-commit fixes.

Please let me know if I am missing any steps or information. Your advice would be highly appreciated.

@HeliconiaSolutions
Copy link
Author

Hi @CRogos ,

I have taken care of the other suggested changes and updated the PR accordingly. Whenever you have a chance, please review them as well.

Thank you for your time and guidance!

@CRogos
Copy link
Contributor

CRogos commented Jan 16, 2025

Hi @CRogos ,

I have taken care of the other suggested changes and updated the PR accordingly. Whenever you have a chance, please review them as well.

Thank you for your time and guidance!

I had a quick look on other PR and you are right. I would have expected some of the index.html changes (like gray/grey) in this commit, but this isn't in the other PR as well.

The commits here marked should be squashed.
image

The rest LGTM, even though I am not sure how to trigger the Validation Error message?
I only get this message:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.