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

[14.0][ADD] project_forecast_line_priority #14

Closed
wants to merge 1 commit into from

Conversation

ntsirintanis
Copy link

No description provided.

@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch 4 times, most recently from 433d8e2 to b2438cc Compare February 6, 2024 09:29
@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch 2 times, most recently from a2f6eb4 to e481c98 Compare February 7, 2024 13:31
@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch from e481c98 to da08e38 Compare February 8, 2024 10:55
@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_deadline branch from 08df2f4 to 9f4bde8 Compare February 8, 2024 10:57
@gjotten gjotten changed the title [ADD] project_forecast_line_priority [14.0][ADD] project_forecast_line_priority Feb 8, 2024
if this.date_deadline:
continue
# if priority is not set, do nothing
if int(priority) < 0:
Copy link

Choose a reason for hiding this comment

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

less then, or less then equal <= as a task with priority zero has basically no priority, and zero is the default?

Copy link
Author

Choose a reason for hiding this comment

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

Actually priority 0 means no priority, but the module should also set forecast_date_planned_end in this case too

Copy link
Member

Choose a reason for hiding this comment

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

@NL66278 functionally what @ntsirintanis says here is correct, the module can set a planned end date for priority 0 as well so we should do only nothing if even that is not the case.

Copy link
Author

Choose a reason for hiding this comment

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

Actually there is a corner case that priority field can be false. This happens when a portal user is creating the task; the priority field accepts falsy values on that case, i.e., its default value is False.

Copy link

@NL66278 NL66278 left a comment

Choose a reason for hiding this comment

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

See comments

@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch from 6626b20 to da02886 Compare February 9, 2024 11:01
@ntsirintanis ntsirintanis requested a review from NL66278 February 9, 2024 11:04
@ntsirintanis ntsirintanis requested a review from NL66278 February 14, 2024 10:13
return super(ProjectTask, self - to_write_forecast_date).write(vals)

def _update_forecast_lines(self):
"""Override cron method and inject forecast date recomputation"""
Copy link
Member

Choose a reason for hiding this comment

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

Can we simplify this code by just:

  • Searching for all tasks that have no deadline, but do have a priority set
  • Retriggering a write of the priority field for those records
  • Which will trigger the recomputation

That way, the recomputation logic is in one place only, and the code becomes more maintainable.

Copy link
Author

Choose a reason for hiding this comment

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

The recordset that this method runs on is set here:

https://github.com/OCA/project/blob/14.0/project_forecast_line/models/project_task.py#L218

and the cron that summons it is here:

https://github.com/OCA/project/blob/14.0/project_forecast_line/models/forecast_line.py#L397

So I thought to just use this project.task recordset, which is already fetched by the cron. Which is simpler than performing another search.

Either way, we can keep it that way, or I can inject another method here

https://github.com/OCA/project/blob/14.0/project_forecast_line/models/forecast_line.py#L397

that does what you suggested.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, reusing that same recordset makes sense, but maybe then still, the recomputation can be triggered by dummy-writing to one of the @api.depends fields, instead of explicitly reiterating the computation logic here, which would save some duplicate code.

@NL66278 What do you think?

@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_deadline branch from 6817b01 to 5517f64 Compare February 26, 2024 09:18
@thomaspaulb
Copy link
Member

@NL66278 Could you check the two remaining open comments

@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_deadline branch from 5517f64 to dff7328 Compare March 12, 2024 16:17
@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch from 2b37667 to 8b140e3 Compare March 15, 2024 08:13
@ntsirintanis ntsirintanis changed the base branch from 14.0-project_forecast_line_deadline to 14.0 March 15, 2024 09:14
@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch 2 times, most recently from 73d5778 to 3e1b2ec Compare March 15, 2024 12:16
@@ -0,0 +1,19 @@
# Copyright 2024 Therp BV
Copy link

Choose a reason for hiding this comment

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

What happened to the <https://therp.nl>. part? Here and elsewhere?

# is creating a task on portal
priority = "0"
selection = self.company_id["forecast_line_priority_%s_selection" % priority]
if selection == "none":
Copy link

Choose a reason for hiding this comment

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

These two lines can be left out, as you return False when selection is not "date" or "delta" anyway.

selection = self.company_id["forecast_line_priority_%s_selection" % priority]
if selection == "none":
return False
elif selection == "delta":
Copy link

Choose a reason for hiding this comment

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

Simple if is enough here, also on the selection == "date" line.

@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch 2 times, most recently from a2d10fb to ba93d37 Compare April 9, 2024 07:27
@ntsirintanis ntsirintanis force-pushed the 14.0-project_forecast_line_priority branch from ba93d37 to 97d85cb Compare April 9, 2024 07:35
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.

4 participants