Skip to content
Snippets Groups Projects
Commit f9f27779 authored by roen-odoo's avatar roen-odoo
Browse files

[FIX] sale_timesheet: Fallback on user employee when creating timesheet


Current behavior:
  If you set a specific sale_order_item for an employee on a project, and
  create a timesheet line from the "My Timesheets" menu,
  the sale_order_item will not be the one you selected for this employee.
  This happens because when you create a timesheet line from the "My
  Timesheets" menu, the employee is not set on the timesheet line.
  To fix this we fallback on the user's employee when creating a timesheet
  line from the "My Timesheets" menu.

Steps to reproduce:
  - Make sure you'r logged in as Mitchel Admin
  - Create a service product that create project and tasks
  - Create a sale order with this product
  - Go to the project and set a sale order item for Mitchel Admin in the
    invoicing tab
  - Go to the "My Timesheets" menu and click "Add Line"
  - Select the project you created
  - The sale order item will not be autofilled with the one set on the
    invoicing tab of the project.

opw-3463849

closes odoo/odoo#133532

X-original-commit: ba0d428a
Signed-off-by: default avatarXavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: default avatarRobin Engels (roen) <roen@odoo.com>
parent e69c6eae
No related branches found
No related tags found
No related merge requests found
......@@ -160,7 +160,7 @@ class AccountAnalyticLine(models.Model):
def _get_employee_mapping_entry(self):
self.ensure_one()
return self.env['project.sale.line.employee.map'].search([('project_id', '=', self.project_id.id), ('employee_id', '=', self.employee_id.id)])
return self.env['project.sale.line.employee.map'].search([('project_id', '=', self.project_id.id), ('employee_id', '=', self.employee_id.id or self.env.user.employee_id.id)])
def _hourly_cost(self):
if self.project_id.pricing_type == 'employee_rate':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment