raise TypeError(repr(o) + " is not JSON serializable

左心房为你撑大大i 提交于 2019-12-08 12:50:11

问题


Can help me? i want to domain many2one field where id not show in other transaction

@api.multi
@api.onchange('batch_id')
def _onchange_batch_id(self):
    if self:
        tempt=[]
        for record in self:
            tempt.extend([record.batch_id])

        culling = self.env['estate.nursery.cullinglinebatch'].search([('batch_id', '!=', list(tempt))])

        return {
             'domain': {'batch_id': [('batch_id','not in',culling),('qty_abnormal','>',0)]}

        }

回答1:


In ODOO8/9 search method always return object not the Id of object.

culling = self.env['estate.nursery.cullinglinebatch'].search([('batch_id', '!=', list(tempt))])

Here culling is the object of model 'estate.nursery.cullinglinebatch'

Your domain should be look like

 'domain': {'batch_id': [('batch_id','not in',culling.ids),('qty_abnormal','>',0)]}

here i have uses culling.ids instead of culling.

I hope this will help you.



来源:https://stackoverflow.com/questions/36733192/raise-typeerrorrepro-is-not-json-serializable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!