问题
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