Skip to content

Commit

Permalink
[FIX] sale_timesheet: fall back on user employee to find SO line
Browse files Browse the repository at this point in the history
Versions:
---------
- 16.3e+

Steps:
------
1. Create an Sales Order with two lines that will create a task;
2. confirm and go to the new project's settings;
3. in Invoicing tab, link an employee to an SO item;
4. link yourself to the other item;
5. go to timesheets;
6. add a new line;
7. select the project and the task created for the other employee.

Issue:
------
The SO item changes to the one linked to the other employee instead of
the one linked to you in the project's settings.

Cause:
------
The new `account.analytic.line` record doesn't have an `employee_id`,
which `_compute_so_line` needs to accurately determine the sale line.
In saas-16.2, the new record retrieved the `employee_id` from the view,
which defaulted to the current user's, but these dissapeared at some
point between saas-16.2 and saas-16.3

Solution:
---------
Modify the `_timesheet_determine_sale_line` method can be modified to
compare `map_entry.employee_id` on `self.employee_id` or
`self.env.user.employee_id` instead of only `self.employee_id`.
This approach is already used in
caace8a to fix a similar bug.

opw-3641939

closes odoo#148493

X-original-commit: 0802f35
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Levi Siuzdak <sile@odoo.com>
  • Loading branch information
lvsz committed Jan 10, 2024
1 parent 2583c80 commit 51a493c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/sale_timesheet/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _timesheet_determine_sale_line(self):
else: # then pricing_type = 'employee_rate'
map_entry = self.project_id.sale_line_employee_ids.filtered(
lambda map_entry:
map_entry.employee_id == self.employee_id
map_entry.employee_id == (self.employee_id or self.env.user.employee_id)
and map_entry.sale_line_id.order_partner_id.commercial_partner_id == self.task_id.partner_id.commercial_partner_id
)
if map_entry:
Expand Down

0 comments on commit 51a493c

Please sign in to comment.