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] hr_timesheet: analytic account linked to the wrong plan when creating timesheets #162213

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

Conversation

deneuvillem
Copy link
Contributor

@deneuvillem deneuvillem commented Apr 17, 2024

Steps to reproduce:

  1. Create a new analytic plan and set it as the default analytic plan in Project settings (it must be different from the 'Projects' plan)
  2. Create again a new analytic plan and set its parent to the one you have created in step 1.
  3. Create a new analytic account linked to the plan you have just created in step 2.
  4. Create a new project and a new task
  5. Link the analytic account you have created in step 3. to the task
  6. Create a new timesheet linked to the task
  7. In Accounting > Analytic Items, the analytic account of the timesheet will not be reported in the plan you created in step 2.

Fix:

The 'Projects' plan (the default one) represents the 'account_id' field of analytic.account.line, other plans have names with the following format: 'x_plan{plan.id}_id' (they are fields created on the fly).
When creating a timesheet we were always setting its account.analytic.account to the 'account_id' field by default and ignoring the other plans.
The fix we propose is to look at the top-level plan of the account.analytic.account of the timesheet being created or modified, and link it to the plan it belongs to.
Note that we keep the 'account_id' ('Projects' plan) updated even if the account does not belong to this plan because this field is used in other parts of the code.

Linked PR: #139225

task-3820916


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Apr 17, 2024

Pull request status dashboard.

@deneuvillem deneuvillem force-pushed the 17.0-fix_analytic_account_link_wrong_plan_timesheet-mane branch from 68c9097 to aa0d113 Compare April 17, 2024 12:41
@C3POdoo C3POdoo added the RD research & development, internal work label Apr 17, 2024
@deneuvillem deneuvillem force-pushed the 17.0-fix_analytic_account_link_wrong_plan_timesheet-mane branch 2 times, most recently from aaf54f7 to 1bfa5c2 Compare April 18, 2024 07:56
…eating timesheets

Steps to reproduce:
-------------------
1. Create a new analytic plan and set it as the default analytic plan in Project settings (it must be different from the 'Projects' plan)
2. Create again a new analytic plan and set its parent to the one you have created in step 1.
3. Create a new analytic account linked to the plan you have just created in step 2.
4. Create a new project and a new task
5. Link the analytic account you have created in step 3. to the task
6. Create a new timesheet linked to the task
7. In Accounting > Analytic Items, the analytic account of the timesheet will not be reported in the plan you created in step 2.

Fix:
-------------------
The 'Projects' plan (the default one) represents the 'account_id' field of analytic.account.line, other plans have names with the following format: 'x_plan{plan.id}_id' (they are fields created on the fly).
When creating a timesheet we were always setting its account.analytic.account to the 'account_id' field by default and ignoring the other plans.
The fix we propose is to look at the top-level plan of the account.analytic.account of the timesheet being created or modified, and link it to the plan it belongs to.
Note that we keep the 'account_id' ('Projects' plan) updated even if the account does not belong to this plan because this field is used in other parts of the code.

Linked PR: odoo#139225

task-3820916
@deneuvillem deneuvillem force-pushed the 17.0-fix_analytic_account_link_wrong_plan_timesheet-mane branch from 1bfa5c2 to b5f1c07 Compare May 22, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants