搜索函数返回null odoo 8

时间:2016-10-25 13:06:28

标签: search openerp odoo-8

无法使用变量

进行搜索
@api.multi
def send_email(self,invoice_id):
     invoice_data = self.env['account.invoice'].browse(invoice_id)
     email_template_obj = self.env['email.template']
     template_id = self.env.ref('multi_db.email_template_subscription_invoice', False)
     report_id = self.env.ref('account.account_invoices', False)
     print'invoice_id',str(invoice_data.id) #Here prints invoice_id

     attach_obj = self.pool.get('ir.attachment')

     attachment_id = self.env['ir.attachment'].search([('res_id','=',invoice_data.id),('res_model','=','account.invoice')])
     print'attachment_id1234',attachment_id
     if template_id:
        values = email_template_obj.generate_email(template_id.id,invoice_id)
        values['subject'] = 'Invoice for AMS registration'
        values['email_to'] = invoice_data.partner_id.email
        values['partner_to'] = invoice_data.partner_id
        # values['attachment_ids'] = [(6, 0, report_id.id)]
        values['attachment_ids'] = [(6, 0, [attachment_id.id])]
        # print'values',values
     mail_obj = self.env['mail.mail']
     msg_id = mail_obj.create(values)
     if msg_id:
         mail_obj.send([msg_id])
     return True

返回ir.attachment()

但是  如果我硬编码该值,它将返回id:

attachment_id = self.env['ir.attachment'].search([('res_id','=',60),('res_model','=','account.invoice')])

返回ir.attachment(53)

我如何使用变量而不是静态值?

0 个答案:

没有答案