[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
This commit is contained in:
Jeremy Kersten
2016-09-19 11:27:31 +02:00
parent f98aa664df
commit 06032f8883
+5 -5
View File
@@ -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)