首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果从onchange字段返回的域没有选择值

如果从onchange字段返回的域没有选择值
EN

Stack Overflow用户
提问于 2014-02-04 17:26:16
回答 3查看 2.1K关注 0票数 0

我想将域放在Sales Person()上,只显示所选销售团队的销售人员。

为此,我在section_id(销售团队)上创建了on_change(),并从该方法返回domain。虽然当我进入开发人员模式时,域显示在销售人员(User_id)上,但那里没有显示任何值。

下面是代码:

代码语言:javascript
复制
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)]}}

我是不是遗漏了什么?

提前谢谢。

EN

回答 3

Stack Overflow用户

发布于 2014-02-04 17:52:09

我想你在这里犯了个小错误。

这样使用域:{'domain': {'user_id': [('id', 'in', member_ids)]}}

代码语言:javascript
复制
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)]}}
票数 0
EN

Stack Overflow用户

发布于 2014-02-04 21:11:27

试试这个pooja,希望它能解决你最新的问题

代码语言:javascript
复制
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}}
票数 0
EN

Stack Overflow用户

发布于 2016-06-08 13:29:23

这里的答案对我不起作用,但user1576199的评论起到了作用。

代码语言:javascript
复制
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) )

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21548421

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档