Skip to content
Snippets Groups Projects
Commit e65c8826 authored by Lucas Perais (lpe)'s avatar Lucas Perais (lpe)
Browse files

[FIX] sale_timesheet: timesheet cost with company on analytic account

FIXUP da2140b7

The above commmit was half-right in the business logic, but overlooked that if a user is not
in the company of the project, it will crash.
This use case worked before that commit

While agreeing that a little more clear access right is needed
like for example be able to get the project_time_mode_id on the companies
that are in user.company_ids,
the aim of this present commit is to avoid regression

OPW 1878204
closes #26539
parent 7b87212e
Branches
Tags
No related merge requests found
......@@ -38,10 +38,10 @@ class AccountAnalyticLine(models.Model):
return {}
unit_amount = values.get('unit_amount', 0.0) or self.unit_amount
user_id = values.get('user_id') or self.user_id.id or self._default_user()
project = values.get('project_id') and self.env['project.project'].browse([values['project_id']]) or self.project_id
emp = self.env['hr.employee'].search([('user_id', '=', user_id)], limit=1)
account = values.get('account_id') and self.env['account.analytic.account'].browse([values['account_id']]) or self.account_id or emp.account_id
cost = emp and emp.timesheet_cost or 0.0
uom = project.company_id.project_time_mode_id
uom = account.company_id.sudo().project_time_mode_id
# Nominal employee cost = 1 * company project UoM (project_time_mode_id)
return {
'amount': -unit_amount * cost,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment