[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) <qdp@openerp.com>
This commit is contained in:
Thibault Francois
2020-02-18 13:15:04 +00:00
parent a232f56312
commit bd7b36aa5a
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -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):
@@ -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."""