
Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn
由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解
本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!
开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号
如果您登录系统碰到问题,请在微信公众号留言:
odoo res.currency
-
currency = 'HKD' currency_ids = models.execute_kw(db, uid, password, 'res.currency', 'search', [[['name', '=', str(currency)]]])
新建的数据库中货币的active都是False,都是不能在界面看到的,现在想通过查询出当前货币HKD的id,设置它的active为True,这样就能在视图中查看.
问题:这个查询有时可以查询出结果,有时又没有查询出结果,什么原因啊
-
不用那么麻烦啊,你直接在高级筛选里面搜索active=False,然后就可以在界面修改他的active值了。
-
@joshua
除了高级筛选可以修改外,代码修改可以做到吗?我现在测试的是,想代码修改active=True
,没成功. -
你可以设置默认值,那么新建的时候就会是
True
了。active = fields.Boolean(default=True)
-
@1234567
context 里面传: active_test: False
context 里面的 active_test 是判断要不要过滤掉inactive 字段的一个条件
def _where_calc(self, cr, user, domain, active_test=True, context=None): """Computes the WHERE clause needed to implement an OpenERP domain. :param domain: the domain to compute :type domain: list :param active_test: whether the default filtering of records with ``active`` field set to ``False`` should be applied. :return: the query expressing the given domain as provided in domain :rtype: osv.query.Query """ if not context: context = {} domain = domain[:] # if the object has a field named 'active', filter out all inactive # records unless they were explicitely asked for if 'active' in self._fields and active_test and context.get('active_test', True): if domain: # the item[0] trick below works for domain items and '&'/'|'/'!' # operators too if not any(item[0] == 'active' for item in domain): domain.insert(0, ('active', '=', 1)) else: domain = [('active', '=', 1)]
-
@joshua
我只是在视图中需要显示currency这个模型的数据,但是我没有创建这个模型,还是你说的这种改法吗? -
我只是在视图中需要显示currency这个模型的数据,我不继承这个模型的,还是不太懂您说的这个方法怎么使用?
-
@1234567 在对应视图的action 的context 里面补 active_test: '0'
-
@siyuan
那你这样是不是把res.currency模型中的所有数据都显示出来了,如果我只需要显示我用到的,不需要显示全部的呢? -
@1234567 根据业务逻辑,自己加domain
-
@siyuan
哦,谢谢了,我想想怎么实现.