本文介绍了引发TypeError(repr(o)+“不是JSON可序列化的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能帮帮我吗?我想对在其他交易中不显示ID的域many2one进行域设置

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)]}

        }

推荐答案

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

此处culling是模型'estate.nursery.cullinglinebatch'

您的域应类似于

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

这里我使用的是 culling.ids 而不是 culling .

here i have uses culling.ids instead of culling.

我希望这会对您有所帮助.

I hope this will help you.

这篇关于引发TypeError(repr(o)+“不是JSON可序列化的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 09:40