首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在单击之前,是什么使打开更改函数?

在单击之前,是什么使打开更改函数?
EN

Stack Overflow用户
提问于 2015-07-21 11:45:04
回答 1查看 30关注 0票数 1

拜托,我和on_change和get_inputs一起工作。

这是我的代码:

PYTHON:

代码语言:javascript
复制
 def get_inputs(self, cr, uid,ids, convention_id, company_id, context=None):
 ret = []
 if convention_id == False:
 My_error_Msg = 'Please, select your CONVENTION'
 raise osv.except_osv(_("Error!"), _(My_error_Msg))
 return False
 else:
    obj = self.pool.get('seetek.convention.categorie.line')
    obj_ids = obj.search(cr, uid, [('convention_id', '=', convention_id)])
    res = obj.read(cr, uid, obj_ids, ['nom','nature','id'], context)
    for r in res :
        inputs = {  
                  'company_convention_categorie_id': r['id'],
                  'company_id': company_id,
                  'nom': r['nom'],
                  'nature': r['nature'],
                  'actif': True,
                   }
      ret.append(inputs)
 return ret
 def on_change_convention_id(self, cr, uid, ids, convention_id, company_id, context=None):
 res = {'value':{line_ids': self.get_inputs(cr, uid, ids, convention_id, company_id, context=context),
 }
 }
 return res

XML:

代码语言:javascript
复制
  <field name="convention_ids" on_change="on_change_convention_id(convention_ids,company_ids)" attrs="{'invisible': [('company_ids','=',False)]}"/>

我的问题是,在我单击convention_ids字段之前,get_inputs函数会给我所有的值??

拜托,谁能帮忙?!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-24 12:52:04

我已经找到了解决问题的办法。事实上,get_inputs函数是完美的,没有问题。导致问题出现的问题在on_change中。我已经将它更改为下面的代码,它工作得非常完美:

代码语言:javascript
复制
  def on_change_conventions_id(self, cr, uid, ids, convention_id, company_id, context=None):
    if company_id == False:
    My_error_Msg =  'Please, select your COMPANY'
    raise osv.except_osv(_("Error!"), _(My_error_Msg))
else:
    print company_id
    print convention_id
        res = {'value':{'seetek_line_ids': self.get_inputs(cr, uid, ids, convention_id, company_id, context=context),
                  }
            }
        return res

(非常感谢和问候:)

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

https://stackoverflow.com/questions/31538158

复制
相关文章

相似问题

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