From a53ca4f949a7b5f2c44678eeedb6db912bc21ada Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 12 Aug 2019 13:27:25 +0000 Subject: [PATCH] [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) --- addons/sale_timesheet/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/account_invoice.py b/addons/sale_timesheet/models/account_invoice.py index 12a18f5524b..dbae7d52522 100644 --- a/addons/sale_timesheet/models/account_invoice.py +++ b/addons/sale_timesheet/models/account_invoice.py @@ -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, })