[FIX] sale_timesheet: Sales user not allowed to create invoice linked to timesheets

Steps to reproduce:
- Create a service product P with invoicing policy = Timesheets on tasks,
Service Tracking = Create a task in a new project and Re-Invoice Policy = No.
- Create a SO with P and confirm it
- Go to the task created for the SO and assign an employee on it.
- Valide the related analytic line in the timesheet module
- Create a user U with the following rights: Sales: 'User: all documents',
Project: 'Manager' and no right in Employee.
- Log as U and try to invoice the SO

Bug:

An access rights error was raised

opw:2044659

closes odoo/odoo#35656

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2019-08-12 13:50:43 +00:00
parent 392f6f2b2b
commit a53ca4f949
@@ -61,7 +61,7 @@ class AccountInvoiceLine(models.Model):
sale_line_delivery = invoice_line.sale_line_ids.filtered(lambda sol: sol.product_id.invoice_policy == 'delivery' and sol.product_id.service_type == 'timesheet')
if sale_line_delivery:
domain = self._timesheet_domain_get_invoiced_lines(sale_line_delivery)
timesheets = self.env['account.analytic.line'].search(domain)
timesheets = self.env['account.analytic.line'].search(domain).sudo()
timesheets.write({
'timesheet_invoice_id': invoice_line.invoice_id.id,
})