title: Openerp 7 Access Denied Document type: Message, Operation: create
body: <p>With the admin user I can do everything, add, delete, modify, etc. As it should be.
  when i add new user with email configuration well done(can send and receive emails on openerp messaging module), but when i call my function send email from my custom module :</p>
  
  <pre><code>  &lt;button name="send_email" string="Notifier Participants" states="open" type="object" icon="gtk-jump-to"/&gt;
  </code></pre>
  
  <p>My function :</p>
  
  <pre><code>def send_email(self, cr, uid, ids, context=None):
      res_id=''
      objects_review = self.browse(cr, uid, ids, context=context)
      for object_review in objects_review:
          participant_names=''
  
          for user_id in object_review.user_ids:
              participant_names += '&lt;tr&gt;&lt;td&gt;'+user_id.name+'&lt;td&gt;&lt;/tr&gt;'
  
      email_template_obj = self.pool.get('email.template')
      template_ids = email_template_obj.search(cr, uid, [], context=context) 
      if template_ids:
          current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
          values = email_template_obj.generate_email(cr, uid, template_ids[0], ids, context=context)
          values['subject'] = object_review.name
          values['email_from'] = current_user.email
          values['email_to'] = object_review.participant_emails
          values['body_html'] = 'Bonjour, &lt;/br&gt;  Convocation à la revue
          :&lt;/br&gt; &lt;table&gt;&lt;tr&gt;&lt;td&gt;Revue :
          &lt;/td&gt;'+'&lt;td&gt;'+str(object_review.name)+'&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;
          &lt;td&gt;Référence&lt;/td&gt;&lt;td&gt;'+str(object_review.reference)+'&lt;/td&gt;
          &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Date de la Revue&lt;/td&gt;
          &lt;td&gt;'+str(object_review.date)+'&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
          Lieu de la Revue&lt;/td&gt;&lt;td&gt;'+str(object_review.lieu)+'
          &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Type de la Revue&lt;/td&gt;
          &lt;td&gt;'+str(object_review.type.name)+'&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;table&gt;
          &lt;th&gt;Participants&lt;/th&gt;'+participant_names+'&lt;/table&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Object :&lt;/td&gt;&lt;td&gt;'+str(object_review.objet)
          or ''+'&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'
          values['body'] = '&lt;table&gt;&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'
          values['res_id'] = False
          mail_mail_obj = self.pool.get('mail.mail')
          msg_id = mail_mail_obj.create(cr, uid, values, context=context)
          mail_mail_obj.send(cr, uid, [msg_id], context=context) 
          #email_template_obj.send_mail(cr, uid, template_ids[0], ids[0], force_send=True, context=context)
          return True
  </code></pre>
  
  <p>I got this error :</p>
  
  <blockquote>
    <p>{'body': u'<p>Hello,</p>\n\n        \n            ', 'attachments': [], 'attachment_ids': [], 'auto_delete': True, 'email_recipients': False, 'body_html': u'Bonjour,   Convocation \xe0 la revue : Revue :dfR\xe9f\xe9rence/001/2015Date de la Revue2015-09-16 14:57:32Lieu de la RevueFalseType de la RevueNoneParticipantsAdministratorObject :False', 'mail_server_id': False, 'email_to': u'admin@example.com', 'reply_to': False, 'email_cc': False, 'model': u'document.page.history', 'res_id': False, 'email_from': u'echange.nad@gmail.com', 'subject': u'df'}
    2015-09-16 14:59:57,552 5688 WARNING tist openerp.osv.orm: No such field(s) in model mail.mail: attachments, email_recipients.
    2015-09-16 14:59:57,564 5688 ERROR tist openerp.netsvc: Access Denied
    The requested operation cannot be completed due to security restrictions. Please contact your system administrator.</p>
  </blockquote>
  
  <p>(Document type: Message, Operation: create)
  Traceback (most recent call last):
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/netsvc.py", line 306, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/service/web_services.py", line 632, in dispatch
      res = fn(db, uid, *params)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/osv/osv.py", line 190, in execute_kw
      return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/osv/osv.py", line 132, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/osv/osv.py", line 199, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/addons/audittrail/audittrail.py", line 532, in execute_cr
      return fct_src(cr, uid, model, method, *args, **kw)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/osv/osv.py", line 187, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/addons/mgmtsystem_review/mgmtsystem_review.py", line 129, in send_email
      msg_id = mail_mail_obj.create(cr, uid, values, context=context)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/addons/fetchmail/fetchmail.py", line 305, in create
      res = super(mail_mail, self).create(cr, uid, values, context=context)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/addons/mail/mail_mail.py", line 93, in create
      return super(mail_mail, self).create(cr, uid, values, context=context)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/osv/orm.py", line 4489, in create
      record_id = self.pool.get(table).create(cr, user, tocreate[table], context=parent_context)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/addons/mail/mail_message.py", line 754, in create
      newid = super(mail_message, self).create(cr, uid, values, context)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/osv/orm.py", line 4615, in create
      self.check_access_rule(cr, user, [id_new], 'create', context=context)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/addons/portal/mail_message.py", line 63, in check_access_rule
      return super(mail_message, self).check_access_rule(cr, uid, ids=ids, operation=operation, context=context)
    File "/home/nadia/barid/server2/openerp15-9-15/openerp/addons/mail/mail_message.py", line 744, in check_access_rule
      (self._description, operation))
  except_osv: (u'Access Denied', u'The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: Message, Operation: create)')</p>
  
  <p>i used the function send_mail instead of send and i have same problem</p>
  
  <p>so i created a rule on model mail.message :</p>
  
  <pre><code>&lt;record id="mes_email_rule" model="ir.rule"&gt;
          &lt;field name="name"&gt;Email send&lt;/field&gt;
          &lt;field name="model_id" ref="mail.model_mail_message"/&gt;
          &lt;field name="domain_force"&gt;[(1,'=',1)]&lt;/field&gt;
          &lt;field name="groups" eval="[(4, ref('base.group_user'))]"/&gt;
          &lt;field eval="True" name="perm_unlink"/&gt;
          &lt;field eval="True" name="perm_write"/&gt;
          &lt;field eval="True" name="perm_read"/&gt;
          &lt;field eval="True" name="perm_create"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>but still have the same problem.</p>