Content-Length: 414646 | pFad | https://github.com/odoo/odoo/pull/167999

DA [FIX] sale_timesheet: get profitability items from all linked projects by lvsz · Pull Request #167999 · odoo/odoo · GitHub
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

[FIX] sale_timesheet: get profitability items from all linked projects #167999

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

lvsz
Copy link
Contributor

@lvsz lvsz commented Jun 4, 2024

Versions

  • 16.0+

Steps

  1. Enable analytic accounting;
  2. have a sales order with a timesheeted service product;
  3. have two projects with different AALs;
  4. link both projecs to the same SOL;
  5. create timesheets in both projects;
  6. open the profitability view of a project.

Issue

The profitability shows shows the total revenue of the SO, but only the cost of that specific project.

Cause

The _get_profitability_items override only checks the AAL associated with that project.

Solution

Call _get_profitability_items on all projects linked the the project's sales order.

opw-3631672

@robodoo
Copy link
Contributor

robodoo commented Jun 4, 2024

Pull request status dashboard.

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jun 4, 2024
@lvsz lvsz force-pushed the 15.0-opw-3631672-update_sol_project_on_task_change-sile branch from e073f46 to 2c9d8a3 Compare June 5, 2024 11:49
Copy link
Contributor

@nle-odoo nle-odoo left a comment

Choose a reason for hiding this comment

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

seems good to me but I'm not too knowledgeable about how these flow functionally work

@@ -128,12 +128,18 @@ class SaleOrderLine(models.Model):

project_id = fields.Many2one(
'project.project', 'Generated Project',
compute='_compute_project_id', store=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

from this:

@api.depends('order_line.product_id.service_tracking')
def _compute_visible_project(self):
""" Users should be able to select a project_id on the SO if at least one SO line has a product with its service tracking
configured as 'task_in_project' """

it seems like the user should be able to select a project, so the field should probably at least be readonly=False

Copy link
Contributor Author

@lvsz lvsz Jun 6, 2024

Choose a reason for hiding this comment

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

They're able to select it on the SO, but this compute method only affect the order's lines, where project_id is assumed to be generated or provided by the SO rather than user-selected.

Copy link
Contributor

Choose a reason for hiding this comment

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

That field is only used to say the SOL generated that project, we don't really use it for the data displayed in the right side panel in project update, IMO. 🤔

And so that field is not used to say that SOL is linked to that project as you said in your commit message. 🙂

@lvsz lvsz force-pushed the 15.0-opw-3631672-update_sol_project_on_task_change-sile branch 2 times, most recently from e3e3284 to 187b0a6 Compare June 6, 2024 07:27
@lvsz lvsz changed the title [FIX] sale_project: update sol project on task project change sale_{project,timesheet}: update sol project based on task Jun 6, 2024
@lvsz lvsz force-pushed the 15.0-opw-3631672-update_sol_project_on_task_change-sile branch from 187b0a6 to e84d2fc Compare June 6, 2024 07:29
@lvsz lvsz changed the title sale_{project,timesheet}: update sol project based on task sale_{project,timesheet}: update SOL project based on task Jun 6, 2024
@lvsz lvsz changed the title sale_{project,timesheet}: update SOL project based on task [FIX] sale_{project,timesheet}: update SOL project based on task Jun 6, 2024
@lvsz lvsz force-pushed the 15.0-opw-3631672-update_sol_project_on_task_change-sile branch 3 times, most recently from 52abddb to a654dde Compare June 6, 2024 11:36
@lvsz lvsz marked this pull request as ready for review June 6, 2024 20:41
@C3POdoo C3POdoo requested a review from a team June 6, 2024 20:43
Copy link
Contributor

@xavierbol xavierbol left a comment

Choose a reason for hiding this comment

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

Thanks for the work, however, it does not seem you fix the bug explained in the video, the product used in the video does not create any project and task.

The steps to reproduce the issues described in your commit message are not the same than the ones showed in the video.

IMO, the bug is not in 15.0 and 16.0 but since 17.0.

@@ -128,12 +128,18 @@ class SaleOrderLine(models.Model):

project_id = fields.Many2one(
'project.project', 'Generated Project',
compute='_compute_project_id', store=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

That field is only used to say the SOL generated that project, we don't really use it for the data displayed in the right side panel in project update, IMO. 🤔

And so that field is not used to say that SOL is linked to that project as you said in your commit message. 🙂

@lvsz
Copy link
Contributor Author

lvsz commented Jun 24, 2024

The steps to reproduce the issues described in your commit message are not the same than the ones showed in the video.

You're right, I think I forgot to enable analytic accounting, which is why I wasn't able to reproduce it as in the video.

IMO, the bug is not in 15.0 and 16.0 but since 17.0.

I'm not sure what you mean; as far as I can tell, the behavior in 17.0 is exactly the same as in 16.0.

@lvsz lvsz marked this pull request as draft June 24, 2024 09:08
@lvsz lvsz force-pushed the 15.0-opw-3631672-update_sol_project_on_task_change-sile branch from a654dde to 2b53425 Compare January 6, 2025 17:10
@lvsz lvsz changed the base branch from 15.0 to 16.0 January 6, 2025 17:10
@lvsz lvsz changed the title [FIX] sale_{project,timesheet}: update SOL project based on task [FIX] sale_timesheet: get profitability items from all linked projects Jan 6, 2025
Versions
--------
- 16.0+

Steps
-----
1. Enable analytic accounting;
2. have a sales order with a timesheeted service product;
3. have two projects with different AALs;
4. link both projecs to the same SOL;
5. create timesheets in both projects;
6. open the profitability view of a project.

Issue
-----
The profitability shows shows the total revenue of the SO, but only the
cost of that specific project.

Cause
-----
The `_get_profitability_items` override only checks the AAL associated
with that project.

Solution
--------
Call `_get_profitability_items` on all projects linked the the project's
sales order.

opw-3631672
@lvsz lvsz force-pushed the 15.0-opw-3631672-update_sol_project_on_task_change-sile branch from 2b53425 to c8dce26 Compare January 7, 2025 11:51
@lvsz lvsz marked this pull request as ready for review January 7, 2025 14:58
@C3POdoo C3POdoo requested a review from a team January 7, 2025 14:59
@lvsz
Copy link
Contributor Author

lvsz commented Jan 7, 2025

Hi @xavierbol

Updated the PR in a way that it would fix the flow shown in the client video.

@lvsz lvsz requested a review from xavierbol January 16, 2025 11:42
@xavierbol
Copy link
Contributor

The _get_profitability_items override only checks the AAL associated with that project.

Why don't we want to just take into account the timesheets linked to the project? 🤯

To me, the issue explained on the ticket is because we take into account the whole revenue instead of just taking the revenues related to the work done in the project itself.

However, after investigating a bit, I don't think it is possible to fix that issue. 🧐

I will discuss about that with Alexandra (my product owner)

@lvsz
Copy link
Contributor Author

lvsz commented Jan 16, 2025

However, after investigating a bit, I don't think it is possible to fix that issue. 🧐

Indeed, revenue is based on sale order lines, but one line can be linked to multiple projects/analytic accounts, so taking that approach would be way more complex, requiring some form of heuristic to divide the line's revenue between multiple timesheet entries.

@xavierbol
Copy link
Contributor

Yep, that's why I think we should not cover that case since it is too complex. 🙁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/odoo/odoo/pull/167999

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy