From 06032f88836de4b23a6003a05271b2f8baf08050 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Sun, 18 Sep 2016 16:19:51 +0200 Subject: [PATCH] [FIX] purchase: don't check subtype if not in the context of purchase order. Before this commit, we check everytime the subtype. In some case (eg: portal user on the forum) don't have access to subtype of type internal. This commit fixes opw-688403 This commit closes #13510 --- addons/purchase/purchase.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index d663b69bb32..9869590052f 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1065,9 +1065,9 @@ class MailComposeMessage(models.TransientModel): @api.multi def send_mail(self, auto_commit=False): - compose_internal = self.filtered('subtype_id.internal') - if self._context.get('default_model') == 'purchase.order' and self._context.get('default_res_id') and not compose_internal: - order = self.env['purchase.order'].browse([self._context['default_res_id']]) - if order.state == 'draft': - order.state = 'sent' + if self._context.get('default_model') == 'purchase.order' and self._context.get('default_res_id'): + if not self.filtered('subtype_id.internal'): + order = self.env['purchase.order'].browse([self._context['default_res_id']]) + if order.state == 'draft': + order.state = 'sent' return super(MailComposeMessage, self.with_context(mail_post_autofollow=True)).send_mail(auto_commit=auto_commit)