跳至内容
Odoo 菜单
  • 登录
  • 免费试用
  • 应用程序
    财务
    • 会计
    • 发票
    • 费用
    • 电子表格 (BI)
    • 文档
    • 电子签名
    销售
    • 客户关系管理
    • 销售
    • POS 销售点管理-零售
    • POS 销售点管理 - 餐厅
    • 订阅
    • 租赁
    网站
    • 网站设计
    • 电子商务
    • 博客
    • 论坛
    • 在线客服
    • 在线学习
    供应链
    • 库存
    • 制造
    • 产品生命周期
    • 采购
    • 维护保养
    • 品控
    人力资源
    • 员工
    • 招聘
    • 休假
    • 评价
    • 内部推荐
    • 车队
    营销
    • 社媒营销
    • 电邮营销
    • 短信营销
    • 近期活动
    • 营销自动化
    • 网上调查
    服务
    • 项目管理
    • 工时单
    • 现场服务
    • 服务台
    • 排期
    • 预约
    生产力
    • 讨论
    • 批核
    • IoT物联网
    • VoIP
    • 知识库
    • WhatsApp
    第三方应用软件 Odoo 定制 Odoo云端平台
  • 行业
    零售
    • 书店
    • 服装店
    • 家具店
    • 食品杂货店
    • 五金店
    • 玩具店
    餐饮与酒店服务
    • 酒吧及酒馆
    • 餐厅
    • 快餐
    • 民宿
    • 饮品分销商
    • 酒店
    房地产
    • 房地产代理
    • 建筑师事务所
    • 建造业
    • 地产管理
    • 园艺
    • 业主协会
    咨询
    • 会计师事务所
    • Odoo合作伙伴
    • 市场推广公司
    • 律师事务所
    • 人才招聘
    • 审核 & 认证
    制造
    • 纺织
    • 金属
    • 家具
    • 食品
    • 啤酒厂
    • 企业礼品
    保健与健身
    • 体育俱乐部
    • 眼镜店
    • 健身中心
    • 健康从业者
    • 药房
    • 发型屋
    商贸服务
    • 维修人员
    • IT 硬件及支持
    • 太阳能系统
    • 鞋匠
    • 清洁服务
    • 暖通空调服务
    其他
    • 非营利组织
    • 环境机构
    • 广告牌租赁
    • 摄影服务
    • 自行车租赁
    • 软件经销商
    浏览所有行业
  • 社区
    学习
    • 教学视频
    • 文档
    • 认证
    • 培训
    • 博客
    • 播客
    赋能教育
    • 教育计划
    • Scale Up! 商业游戏
    • 参观Odoo
    获取软件
    • 下载
    • 版本对比
    • 发布
    合作
    • Github
    • 论坛
    • 近期活动
    • 翻译
    • 成为合作伙伴
    • 合作伙伴服务
    • 注册您的会计事务所
    获取服务
    • 寻找合作伙伴
    • 查找会计服务
    • 预约顾问咨询
    • 安装及推行服务
    • 客户参考
    • 支持
    • 升级
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    获取演示
  • 定价
  • 技术支持

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • 客户关系管理
  • e-Commerce
  • 会计
  • 库存
  • PoS
  • 项目
  • MRP
All apps
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
帮助

field.function in tree view

订阅

此帖文有活动时,接收通知

此问题已终结
v6
2 回复
14414 查看
形象
Tajjajt

hi !

I have in my new module a functional field, whene i put it in my tree view i can't open my view.

here the action code :

    <record id="my_module_normal_action" model="ir.actions.act_window">
    <field name="name">My module</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">mymodule</field>
<field name="domain">[('my_field','=',True)]</field>
    <field name="view_type">form</field>
    <field name="view_id" ref="my_module_tree_view"/>
    <field name="search_view_id" ref="my_module_search_form_view"/>
</record>

my code xml :

<record id="my_module_tree_view" model="ir.ui.view">
            <field name="name">my.module.tree</field>
            <field name="model">mymodule</field>
            <field name="type">tree</field>
            <field eval="7" name="priority"/>
            <field name="arch" type="xml">
                <tree string="my module">
                   <field name="my_string"/>
            <field name="my_field"/>
                </tree>
            </field>
        </record>

in my python code :

  'my_field': fields.function(_get_concatenate_values, method=True, string='Reference', type='char'),

this is the function's code :

def _get_concatenate_values(self, cr, uid, ids, field_name, arg, context=None):
            records=self.browse(cr,uid,ids)
            result={}
            for r in records:
                if(r.field1 and r.field2):
                    result[r.id]= str(r.field1.name)+'.'+ str(r.field2.name)
                return result

"my_field"'s value is the concatenation of the two fields :field1 and field2

thanks for your reply.

0
形象
丢弃
Andreas Brueckl

What version of OpenERP are you using? Your field is called 'code' but you use 'my_string' and 'my_module' in the view?

Tajjajt
编写者

I use V6.0.2 , my feild's name is 'my_field', 'my_sring' is an other field in my module. so I rectify the python code : 'my_field': fields.function(_get_concatenate_values, method=True, string='Reference', type='char'),

形象
Lucio
最佳答案

In the definition of the action, you need to add:

<field name="view_mode">tree,form</field>

or

<field name="view_mode">form,tree</field>

depending in the order you want the views to be accessed.

(Or maybe just <field name="view_mode">tree</field> if you do not have a form view.)

I think the problem is in your domain statement in the definition of the action!

<field name="domain">[('my_field','=',True)]</field>

I think you are trying to say that it is not empty, but this restriction is satisfied only if the field has the boolean value True. Change it to:

 <field name="domain">[('my_field','&lt;&gt',False)]</field>

This means that is different to False that, I think, is more acccurate.

Hope it helps!

2
形象
丢弃
Tajjajt
编写者

It dosnt work !!

here a picture of my problem:

[URL=http://www.imagup.com/data/1176824638.html][IMG]http://data.imagup.com/12/1176824638.png[/IMG][/URL]

I have 3 rows but invisible, when I delete the line <field name="my_field"/> from the tree code it works and I have my liste

Tajjajt
编写者

link to the picture : http://www.imagup.com/data/1176824638.html

Lucio

Without the 'my_field' field it works just fine? What's the message error you are getting?

Tajjajt
编写者

yes without 'my_fiels' it works fine, i have no msg error, i can't see my data?

Tajjajt
编写者

any help !!

Lucio

I updated my answer, maybe that is the problem! I do not see any other possibility of change!

Andreas Brueckl

Please update your question with the code of "_get_concatenate_values"

Lucio

Did it work?

Tajjajt
编写者

no !! I have the same problem.

Tajjajt
编写者

I updated my question

形象
Tony Gu
最佳答案

You defined a domain in act_window based on the function field 'my_field', while you didn't define a "fnct_search" search method for that function field.

Update: Another option would be to add store=True to the function field.

0
形象
丢弃
Lucio

As far as I know, store=True will be used for the value of the field to be stored in the database. But, is this necessary to just show it in a tree view and filter the domain? I think it is not, but then again, I am not sure

Andreas Brueckl

For the domain filter only, the store flag is not required. Only if you want to use in the SearchView.

Lucio

Yes, in that case, I see what you are saying! Thanks!

Tajjajt
编写者

I added "store=True" to my function field but during the installation of the module I get this error :

=================
Traceback (most recent call last):
  File "netsvc.pyo", line 489, in dispatch
  File "service\web_services.pyo", line 599, in dispatch
  File "osv\osv.pyo", line 122, in wrapper
  File "osv\osv.pyo", line 176, in execute
  File "osv\osv.pyo", line 167, in execute_cr
  File "C:\Program Files\OpenERP 6.0\Server\addons\base\module\wizard\base_module_upgrade.py", line 98, in upgrade_module
  File "pooler.pyo", line 60, in restart_pool
Tajjajt
编写者
  File "pooler.pyo", line 39, in get_db_and_pool
  File "addons\__init__.pyo", line 883, in load_modules
  File "addons\__init__.pyo", line 719, in load_module_graph
  File "addons\__init__.pyo", line 414, in init_module_objects
  File "osv\orm.pyo", line 2651, in _auto_init
  File "osv\orm.pyo", line 378, in get_pg_type
TypeError: int argument required
=============
Tajjajt
编写者

can you help me plz ?!

joshuajan
def _get_concatenate_values(self, cr, uid, ids, field_name, arg, context=None):
    records=self.browse(cr,uid,ids)
    result={}
    for r in records:
        if(r.field1 and r.field2):
            result[r.id]= str(r.field1.name)+'.'+ str(r.field2.name)
        #return result
    return result

I think there is a problem of you return value.

Tajjajt
编写者

can anyone help me plz!

喜欢讨论吗?不要只阅读,加入进来!

立即创建账户,享受专属功能,与我们的精彩社区互动!

注册
相关帖文 回复 查看 活动
How to reset default values for a specific user? 已解决
v6
形象
形象
1
12月 17
14365
how to get url of current page 已解决
v6
形象
形象
形象
2
12月 23
23510
How to find all the customer invoices that were paid after the due date?
v6
形象
形象
1
3月 15
6927
Limiting access Controls to Allocation requests in Holidays
v6
形象
1
3月 15
4838
JasperReports won't evaluate null nor 0
v6
形象
0
3月 15
4537
社区
  • 教学视频
  • 文档
  • 论坛
开源
  • 下载
  • Github
  • Runbot
  • 翻译
服务
  • Odoo.sh 托管
  • 支持
  • 升级
  • 自定义开发服务
  • 教育
  • 查找会计服务
  • 寻找合作伙伴
  • 成为合作伙伴
关于我们
  • 我们的公司
  • 品牌资产
  • 联系我们
  • 招聘
  • 近期活动
  • 播客
  • 博客
  • 客户
  • 法律 • 隐私
  • 安全
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo致力于为企业管理提供高效智能的开源解决方案,是全球业内高速成长的软件服务商之一,逾七百五十万用户选择Odoo进行数字化升级。通过一系列全业务链覆盖、高度集成、简单易用的商业应用,助力企业实现信息化改革、降本增效并释放公司增长潜力。

Odoo独特的价值在于是一款非常容易使用又完全集成的应用。

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now