TypeError: product.product(3,) is not JSON serializable
TypeError: product.product(3,) is not JSON serializable
我现在对这段代码有很多问题。这是我的功能:
def _get_invoice_lines(self):
self.cr.execute("SELECT inv.number,l.price_subtotal_taxed,l.name,inv.maitre_ouvrage,m.type_paiement,m.ref,m.date
FROM product_product p,account_invoice inv, account_invoice_line l,account_move ml
where p.id = l.product_id
and inv.id= l.invoice_id
and ml.invoice_id=inv.id
and ml.type_paiement is not null
and inv.journal_id = 1
and ml.type_paiement = '%s'
and inv.date_invoice =DATE '%s'
and p.id = %d "%(self.datas['type_paiement'],self.datas['date_invoice'],self.datas['product_id'].id))
return self.cr.fetchall()
当我打印报告时出现此错误:
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 239, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: product.product(3,) is not JSON serializable
看来你l.product_id完全是product对象,你只需要id就可以了
你测试过l.product_id.id吗?
您可能会遇到与 inv.id= l.invoice_id 相同的错误。相同的解决方案!
我现在对这段代码有很多问题。这是我的功能:
def _get_invoice_lines(self):
self.cr.execute("SELECT inv.number,l.price_subtotal_taxed,l.name,inv.maitre_ouvrage,m.type_paiement,m.ref,m.date
FROM product_product p,account_invoice inv, account_invoice_line l,account_move ml
where p.id = l.product_id
and inv.id= l.invoice_id
and ml.invoice_id=inv.id
and ml.type_paiement is not null
and inv.journal_id = 1
and ml.type_paiement = '%s'
and inv.date_invoice =DATE '%s'
and p.id = %d "%(self.datas['type_paiement'],self.datas['date_invoice'],self.datas['product_id'].id))
return self.cr.fetchall()
当我打印报告时出现此错误:
File "/usr/lib/python2.7/dist-packages/simplejson/encoder.py", line 239, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: product.product(3,) is not JSON serializable
看来你l.product_id完全是product对象,你只需要id就可以了
你测试过l.product_id.id吗?
您可能会遇到与 inv.id= l.invoice_id 相同的错误。相同的解决方案!