-
-
Notifications
You must be signed in to change notification settings - Fork 881
[19.0][ADD] project_profitability_threshold_alert: Notify project followers and project manager about costs exceeding based on a set threshold #1660
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
base: 19.0
Are you sure you want to change the base?
Conversation
… and project manager about budget exceeding based on a set threshold
050db67 to
be238cd
Compare
be238cd to
5a29fe3
Compare
project_profitability_threshold_alert/models/project_project.py
Outdated
Show resolved
Hide resolved
project_profitability_threshold_alert/models/project_project.py
Outdated
Show resolved
Hide resolved
project_profitability_threshold_alert/models/project_project.py
Outdated
Show resolved
Hide resolved
| def _cron_find_costs_threshold_exceeded(self): | ||
| projects = self.env["project.project"].search([("active", "=", True)]) | ||
| for project in projects: | ||
| project._compute_is_cost_exceeded() |
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.
Is this really necessary ? The compute is triggered by its depends.
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 need to execute _get_profitability_items() to get updated data related to project costs and revenues
| projects = self.env["project.project"].search([("active", "=", True)]) | ||
| for project in projects: | ||
| project._compute_is_cost_exceeded() | ||
| if project.is_cost_exceeded and not project.is_notfication_sent: |
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.
Those fields should be included in search criteria (add a dedicated method for the domain like _get_costs_threshold_notification_domain())
| email_layout_xmlid=None, | ||
| ) | ||
|
|
||
| @api.depends("costs_threshold", "company_id.project_costs_threshold") |
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.
So, no need of company_id.project_cost_threshold
project_profitability_threshold_alert/models/project_project.py
Outdated
Show resolved
Hide resolved
project_profitability_threshold_alert/models/project_project.py
Outdated
Show resolved
Hide resolved
| internal_user_followers += manager | ||
| return internal_user_followers | ||
|
|
||
| @api.onchange("costs_threshold") |
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.
Set is_notification_sent as computed / store=True depending on costs_threshold to avoid onchanges.
project_profitability_threshold_alert/models/res_config_settings.py
Outdated
Show resolved
Hide resolved
- Rename module to be more generic - Add costs vs revenues threshold
5a29fe3 to
1653c40
Compare
Notify followers and project manager about costs exceeding based on a set threshold