From bd7b36aa5a87ed7b7e995f8e20c82da3de7dcbca Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Mon, 17 Feb 2020 16:36:47 +0000 Subject: [PATCH] [FIX] account: allow salesman to send and print posted invoice Issue: as salesman you want to send and print the invoice of your customer but you don't have the access to write on the invoice and thus you don't have access to create a mail.message and set the flag invoice_sent to True Allow to post message on an invoice when you have read access closes odoo/odoo#45629 X-original-commit: d23d872f885f34bbbd747471e35e6914ac79b6cf Signed-off-by: Quentin De Paoli (qdp) --- addons/account/models/account_move.py | 1 + addons/account/wizard/account_invoice_send.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 4bb88b46948..c273bd35c72 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -34,6 +34,7 @@ class AccountMove(models.Model): _inherit = ['portal.mixin', 'mail.thread', 'mail.activity.mixin', 'sequence.mixin'] _description = "Journal Entries" _order = 'date desc, name desc, id desc' + _mail_post_access = 'read' @property def _sequence_monthly_regex(self): diff --git a/addons/account/wizard/account_invoice_send.py b/addons/account/wizard/account_invoice_send.py index a4e4a8802b9..7ef17afc7c1 100644 --- a/addons/account/wizard/account_invoice_send.py +++ b/addons/account/wizard/account_invoice_send.py @@ -86,7 +86,9 @@ class AccountInvoiceSend(models.TransientModel): if self.is_email: self.composer_id.send_mail() if self.env.context.get('mark_invoice_as_sent'): - self.mapped('invoice_ids').write({'invoice_sent': True}) + #Salesman send posted invoice, without the right to write + #but they should have the right to change this flag + self.mapped('invoice_ids').sudo().write({'invoice_sent': True}) def _print_document(self): """ to override for each type of models that will use this composer."""