我想将域放在Sales Person()上,只显示所选销售团队的销售人员。
为此,我在section_id(销售团队)上创建了on_change(),并从该方法返回domain。虽然当我进入开发人员模式时,域显示在销售人员(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)]}}我是不是遗漏了什么?
提前谢谢。
发布于 2014-02-04 17:52:09
我想你在这里犯了个小错误。
这样使用域:{'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)]}}发布于 2014-02-04 21:11:27
试试这个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}}发布于 2016-06-08 13:29:23
这里的答案对我不起作用,但user1576199的评论起到了作用。
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客户端期望的域值。因此使用字符串( ('id',in,member_ids) )
https://stackoverflow.com/questions/21548421
复制相似问题