跳至内容
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
关于此论坛区
帮助

How to "postion=replace" a Form or Tree View, Menuitem ?

订阅

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

此问题已终结
formmenuitemtreenew
2 回复
9736 查看
形象
Ruban Kannan

Hello everyone, 

I want to list all the product template colums (39 columns I see in pgadmin) in the Product template Form view. Adding position="replace" for fields does not work for me since I want to see all the colums.

I want to know how I can replace the existing menuitem,action and views with the new items I created. Also, how can I inject new menuitem,action and views. Below is my XML content. 

<record id="product_vape_form_view" model="ir.ui.view">
            <field name="name">product.vape.form.view</field>
            <field name="model">product.template</field>
            <field name="arch" type="xml">
                <form>
                    <group>
                        <field name="warranty" />
                        <field name="uos_id" />
                        <field name="list_price" />
                        <field name="weight" />
                        <field name="color" />
                        <field name="image" />
                        <field name="write_uid" />
                        <field name="mes_type" />
                        <field name="uom_id" />
                        <field name="description_purchase" />
                        <field name="create_date" />
                        <field name="uos_coeff" />
                        <field name="create_uid" />
                        <field name="rental" />
                        <field name="product_manager" />
                        <field name="message_last_post" />
                        <field name="company_id" />
                        <field name="state" />
                        <field name="uom_po_id" />
                    </group>
                    <group>
                        <field name="type" />
                        <field name="description" />
                        <field name="weight_net" />
                        <field name="volume" />
                        <field name="write_date" />
                        <field name="active" />
                        <field name="categ_id" />
                        <field name="sale_ok" />
                        <field name="image_medium" />
                        <field name="name" />
                        <field name="description_sale" />
                        <field name="image_small" />
                        <field name="loc_rack" />
                        <field name="track_incoming" />
                        <field name="sale_delay" />
                        <field name="track_all" />
                        <field name="track_outgoing" />
                        <field name="loc_row" />
                        <field name="loc_case" />
                    </group>
                </form>
            </field>
        </record>
        <record id="product_vape_tree_view" model="ir.ui.view">
            <field name="name">product.vape.tree.view</field>
            <field name="model">product.template</field>
            <field name="arch" type="xml">
                <tree >
                    <field name="name" />
                    <field name="create_date"/>
                    <field name="create_uid"/>
                </tree>
            </field>
        </record>
        <record id="action_product_vape_tree_view" model="ir.actions.act_window">
            <field name="name">All Products</field>
            <field name="res_model">product.template</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="product_vape_tree_view"/>
        </record>
        <menuitem id="vape.product" action="action_product_vape_tree_view" name="All Vape Products" parent="base.menu_product" />

0
形象
丢弃
形象
Ivan
最佳答案

Ruben, aside from <record> tag, there is also <delete> tag.  Both works if you specify the XML ID (id) and model of the said attribute.  So, having said that:

  • You can delete a record by adding <delete id="the_xml_id_of_record_to_delete" model="the_model_to_delete/> somewhere in your XML
  • You can update a record by adding <record id = "the_xml_id_of_record_to_change" model="the_model_to_change"> ... </record>, where ... is the new content (list of fields and their values) of the record.  It will update the fields listed in the content.
  • If the record is created by other module you can specify the "full" XML ID: module_name.the_xml_id_of_record_to_change
  • Note that generally it is not advisible to change or delete a view as the view may be inherited by other modules. It is better to inherit a view instead.
  • To tie in a view to an action, you can specify it with the following XML snippet:
  • <record model="ir.actions.act_window.view" id="tie_in_view_to_action">
                <field name="sequence" eval="1"/>
                <field name="view_mode">form</field>
                <field name="view_id" ref="your_view_xml_id"/>
                <field name="act_window_id" ref="product_template_action_tree"/>
            </record>
1
形象
丢弃
Ruban Kannan
编写者

Note that generally it is not advisible to change or delete a view as the view may be inherited by other modules. It is better to inherit a view instead. /// Thanks. I completely agree with the last point and I want to proceed this way. So, 1. How do I bulk replace fields in an inherited view? 2. How do I add a new menu item under an existing menu item and open the newly created View?

Ivan

Menu will call an action (in this case, a window action). Window action will call a view. So, basically you need to do the following: - Inherit the view that you need to inherit. I am not aware of any way to bulk replace field. You can replace the form, I guess, but this will be quite similar as deleting the old view and creating a new one. - Create a new action window to using the new views that you have specified - Create a new menu whose parent is an old menu (specified by XML ID) and calling the new action that you have created. Check the account/account_view.xml for example. If you really need a different view from the original view, you can create (instead of inheriting or replacing) a new view and let the old view be.

Ruban Kannan
编写者

Thx John. I want to display my new action under Sales/Products underneath Sales/Products/Products by Category. I wrote my new action as . vape is my module name, base.menu_product seems to be the id of Sales/Products. It didn't work

Ruban Kannan
编写者

See the last line of my XML for the action I wrote.

Ruban Kannan
编写者

Sorry about the confusion. This works now. I didn't include the new XML file in my data of openerp.py.

Ruban Kannan
编写者

Thx for this. So this works when I add a new line (field name="sequence" eval="1") or (field name="priority" eval="1") to the form view xml. But, since it changes the priority, it changes the default Form view. While this is okay for me, I just want to know how to associate the my custom form view only to the custom tree view I created. In other words, how to trigger the custom form view when a record in tree view is clicked.

Ivan

Ruben, please refer to the last 2 points in this answer on how to tie in a view to an action.

形象
Ruban Kannan
编写者 最佳答案

I was able to inject a new Menuitem with the following line

<menuitem id="vape.product" action="action_product_vape_tree_view" name="All Vape Products" parent="base.menu_product" />

I'm still wondering how to use my custom defined Form View in place of the default product template form view "product.product_template_only_form_view"

 

0
形象
丢弃
Ivan

Can't find product_template_only_form_view in my version of Odoo. Anyway, there are a couple of ways to achive that. First, the simplest one but no guarantee, is to set your custom view with a small priority. The view has a priority field in which a smaller priority (e.g. 1) will be picked first if there are more than one views defined for that model. Second, is to tie the action with the form view. In my version of Odoo, product.template is called by action with XML ID: product_template_action_tree. You can add the following record to tie in your view with this action: form

Ivan

Sorry the XML is not posted properly, I'll edit my previous answer.

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

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

注册
相关帖文 回复 查看 活动
Tree not showing "Add an item"
form tree
形象
形象
形象
形象
3
5月 20
8366
One model, two forms and trees, how to set this up?
developement form tree
形象
形象
形象
3
4月 24
2721
Make a boolean field editable in a tree view with the possibility of open a form view when clicking on a row ?? 已解决
editable form tree
形象
形象
2
11月 18
14138
How to use two specific views (tree and form view) when using ir.actions.act_window 已解决
form tree ir.actions.act
形象
形象
2
3月 16
8774
how to use tree in form view
form view tree
形象
形象
1
3月 15
8901
社区
  • 教学视频
  • 文档
  • 论坛
开源
  • 下载
  • 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