0
をodoo、私はこの関数を作成しました:メールの添付ファイルは、私が問題odoo 8に添付ファイル付きのメールを作成する必要があり8のpython
dict: {'email_to':'[email protected]', 'email_from': '[email protected]', 'body_html': 'Reporte de desabastecimientos correspondiente al dia 2016-05-05', 'attachments_ids': [(6, 0, [806])], 'subject': 'Report'}
:
def send_desabastecimientos_report(self, cr, uid, ids, context=None):
if not context:
context = {}
# execution_date
day = datetime.datetime.now()
day = day. strftime('%Y-%m-%d')
#get attachment id
attachment_id=self.pool.get('ir.attachment').search(cr, uid, [('id',=, 806)] context=context)
email_vals = {}
# body message
mesaage = "Reporte de desabastecimientos correspondiente al dia %s" % day
# dict to send email
email_vals.update({'subject':"Report",'email_to':'[email protected]', 'email_from': '[email protected]', 'body_html':mesaage.encode('utf-8'), 'attachments_ids': [(6, 0, attachment_id)] })
# create and send email
if email_vals:
email_id=self.pool.get('mail.mail').create(cr, uid, email_vals, context=context)
if email_id:
self.pool.get('mail.mail').send(cr, uid, email_id, context=context)
return True
は、私はこの辞書を送信する取得debugerを設定します
「mail.mail」レコードを作成した後、私はこのコンソールメッセージ取得:
2016-05-05 14:58:36,505 7444 WARNING mexyfeb18 openerp.models: mail.mail.create() with unknown fields: attachments_ids
をそして最後に、SE電子メールを得ました添付ファイルなしのNT。
この手順は、設定 - >電子メールからメールを送信し、実際にファイルを添付することができ、mail_mailオブジェクトにattachment_idsフィールドが存在する場合にうまく機能します。
誰かに提案がありますか?
ありがとうございます!