我想将域名放在Sales Person()上,只显示所选销售团队的销售人员。
为此我在section_id(销售团队)上创建了on_change(),我从该方法返回域名。虽然当我进入开发者模式时,域名显示在销售人员(user_id)上,但在那里没有显示任何值。
这是代码:
def onchange_section_id(self, cr, uid, ids, section_id, context=None):
crm_case_section_obj = self.pool.get('crm.case.section')
member_ids = []
if section_id:
member_ids = [member_id.id for member_id in crm_case_section_obj.browse(cr, uid, section_id, context=context).member_ids]
return {'domain': {'user_id': [('user_id', 'in', member_ids)]}}
我错过了什么吗?
提前完成。
答案 0 :(得分:0)
我认为你在这里犯了一点错误。
以这种方式使用域:{'domain': {'user_id': [('id', 'in', member_ids)]}}
def onchange_section_id(self, cr, uid, ids, section_id, context=None):
crm_case_section_obj = self.pool.get('crm.case.section')
member_ids = []
if section_id:
member_ids = [member_id.id for member_id in crm_case_section_obj.browse(cr, uid, section_id, context=context).member_ids]
return {'domain': {'user_id': [('id', 'in', member_ids)]}}
答案 1 :(得分:0)
试试这个pooja,希望这会解决你的最新问题
def onchange_section_id(self, cr, uid, ids, section_id, context=None):
crm_case_section_obj = self.pool.get('crm.case.section')
member_ids = []
if section_id:
member_ids = [member_id.id for member_id in crm_case_section_obj.browse(cr, uid, section_id, context=context).member_ids]
return {'domain': {'user_id': [('id', 'in', member_ids)]}, 'value': {'user_id': False}}
答案 2 :(得分:0)
这里的答案对我不起作用,但是Mdymade的评论确实如此。
def onchange_section_id(self, cr, uid, ids, section_id, context=None):
crm_case_section_obj = self.pool.get('crm.case.section')
member_ids = []
if section_id:
member_ids = [member_id.id for member_id in crm_case_section_obj.browse(cr, uid, section_id, context=context).member_ids]
return {'domain': {'user_id': str([('id', 'in', member_ids)]) }}
这里的技巧是将实际域作为字符串传递,因为Web客户端期望域的值。所以使用 str( [('id',in,member_ids)] )