Skip to content

Commit

Permalink
ADD account check when account provided from ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaume Florez committed Apr 18, 2018
1 parent 057c27c commit 19d2ed0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions poweremail_send_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ def _get_accounts(self, cr, uid, context=None):

if template.enforce_from_account:
return [(template.enforce_from_account.id, '%s (%s)' % (template.enforce_from_account.name, template.enforce_from_account.email_id))]
elif (context.get('from', False) and
isinstance(context.get('from'), int)):
# If account provided from context, check availability
account = accounts_obj.browse(cr, uid, context.get('from'), context)
if ((account.user.id == uid or (
account.company == 'yes' and
account.user.id in company_users
)) and account.state == 'approved'):
return [(
account.id, "{} ({})".format(account.name, account.email_id)
)]
else:
# Check for user's accounts available
search_params = [
Expand Down

0 comments on commit 19d2ed0

Please sign in to comment.