[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
This commit is contained in:
Nicolas Martinelli
2018-04-23 13:35:05 +02:00
committed by Nicolas Martinelli
parent 61c32429a6
commit 899ae6d3da
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -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):
+1
View File
@@ -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"
/>
<report