0

ベース15244031に影響を与えずにopenerpオーバーライドonchange動作 からのフォローアップの質問

次のコードは実行されますが、関連するフィールドのいずれかに値がある場合、サーバー エラー 500 が発生します。

ログを見ると、JSON シリアライゼーションの問題と書かれています。

TypeError: browse_record(product.mycount, 1) is not JSON serializable

解決策を提案してください。

class purchase_order_line_custom(osv.osv):
_name = 'purchase.order.line'
_inherit = 'purchase.order.line'

def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id, date_order=False, fiscal_position_id=False, date_planned=False, name=False, price_unit=False, context=None):
values = super(purchase_order_line_custom, self).onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id, date_order, fiscal_position_id, date_planned,name, price_unit, context=context)
  if product_id:
    product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
    values['value'].update({
                            'qualified_name':product.qualified_name,
                            'product_type' : product.product_type or None,
                            'product_subtype' : product.product_subtype,
                            'count_id':product.count_id or None 
    })
  return values   

  _columns={
      'product_type': fields.related('product_id','product_type',type='selection', string='Product Type', selection=[('X','X'),('Y','Y'),('Z','Z')]),
      'product_subtype': fields.related('product_id','product_subtype',type='char', size=64, string='Sub-Type'),
      'qualified_name': fields.related('product_id','qualified_name',type='char', size=64, string='Qualified Name'),
      'count_id': fields.related('product_id','count_id',type='many2one',relation='product.mycount',string='Count')
      }

purchase_order_line_custom() 
4

1 に答える 1

2

の行'count_id':product.count_id or Noneで、count_id は product.order.line の count_id フィールドにオブジェクトを渡そうとしています。id を取得するには、product.count_id.id を渡す必要があります。

于 2013-03-07T13:20:28.113 に答える