From 899ae6d3da474529a861eba004788fdd072b2e8f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 20 Apr 2018 15:01:37 +0200 Subject: [PATCH] [FIX] account: print invoice - Create a user A with group `group_sale_salesman` but no Accounting & Finance group set - Create and validate a SO, create the invoice - With another user B, pay the invoice - Print the "Invoices" with A An access error occurs. The error is due to user A not having the rights to see the payments. We set a group on the corresponding report to avoid a user without proper rights to print it. opw-1837845 --- addons/account/models/account_invoice.py | 5 ++++- addons/account/views/account_report.xml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 6bee36dfed5..83407aec4bc 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -548,7 +548,10 @@ class AccountInvoice(models.Model): """ self.ensure_one() self.sent = True - return self.env.ref('account.account_invoices').report_action(self) + if self.user_has_groups('account.group_account_invoice'): + return self.env.ref('account.account_invoices').report_action(self) + else: + return self.env.ref('account.account_invoices_without_payment').report_action(self) @api.multi def action_invoice_sent(self): diff --git a/addons/account/views/account_report.xml b/addons/account/views/account_report.xml index 2ba116e884a..8918d2763e7 100644 --- a/addons/account/views/account_report.xml +++ b/addons/account/views/account_report.xml @@ -11,6 +11,7 @@ file="account.report_invoice_with_payments" attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')" print_report_name="(object._get_printed_report_name())" + groups="account.group_account_invoice" />