支持的视图类型:form、tree、search ...

支持的定位方法:

                 <notebook position="inside">

       <xpath expr="//page[@name='page_history']" position="inside">

                 <field name="mobile" position="after">

<filter name="consumable" position="after">

                 <group name="bank" position="after">

<xpath expr="//field[@name='standard_price']" position="replace">

                 <xpath expr="//button[@name='open_ui']" position="replace">

<xpath expr="//div[@class='oe_employee_details']/h4/a"
position="after">

                
<xpath
expr="/form/sheet/notebook/page/field[@name='line_ids']/tree/field[@name='analytic_account_id']"
position="replace">

                
<xpath
expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='analytic_account_id']"
position="replace">

支持的规则:before、after、replace、inside、attributes

插入:

position='before'
position="after"

      <field name="mobile" position="after">
       <field name="sale_order_count"/>
      </field>

<filter name="consumable"
position="after">
                  
<separator/>
                  
<filter name="filter_to_qty_available" string="在手数量>0"
icon="terp-accessories-archiver+" domain="[('qty_available', '>',
0)]"/>
                  
<filter name="filter_to_virtual_available" string="预测数量>0"
icon="terp-accessories-archiver+" domain="[('virtual_available', '>',
0)]"/>
               
</filter>
替换:
position="replace"

<xpath expr="//field[@name='standard_price']"
position="replace">
                       
<group name='cost_prices' colspan="2"
col="4">
                           
<field name="standard_price" nolabel="1"
attrs="{'readonly':[('cost_method','=','average')]}"/>
                           
<field name="cost_price_extra"
groups="product.group_product_variant"/>
                       
</group>
                
</xpath>

<xpath expr="//button[@name='open_ui']"
position="replace">
                    
<button name="open_ui" type="object" string="Start Selling"
attrs="{'invisible' : [('pos_state', 'not in', ('opened',))]}"
class="oe_highlight"
invisible="True"/>
                
</xpath>
内部创建:?

position="inside"

<xpath expr="//page[@name='page_history']" position="inside">
                    <group name="grp_task" string="Tasks">
                        <field name="task_ids" colspan="4" nolabel="1">
                            <tree string="Tasks" editable="bottom">
                                <field name="name"/>
                                <field name="user_id"/>
                                <field name="date_deadline"/>
                                <field name="state" invisible="1"/>
                               
<button name="do_open" states="pending,draft,done,cancelled"
string="Start Task" type="object" icon="gtk-media-play" help="For
changing to open state"
invisible="context.get('set_visible',False)"/>
                               
<button name="action_close" states="draft,pending,open"
string="Done" type="object" icon="terp-dialog-close" help="For changing
to done state"/>
                            </tree>
                        </field>
                      </group>
                </xpath>

修改属性:修改属性能够实现的功能,不要使用 replace
position="attributes"

<xpath expr="//field[@name='name']"
position="attributes">
                       
<attribute
name="required">1</attribute>
                   
</xpath>


示例代码:

<record
id="product_normal_variant_form_view"
model="ir.ui.view">
           
<field
name="name">product.normal.variant.form</field>
           
<field
name="model">product.product</field>
           
<field
name="type">form</field>
           
<field name="inherit_id" ref="product.product_normal_form_view"
/>
           
<field name="arch"
type="xml">
           
 <data>
                   
<xpath expr="//field[@name='name']"
position="attributes">
                       
<attribute
name="required">1</attribute>
                   
</xpath>
                   
<xpath expr="//field[@name='standard_price']"
position="replace">
                       
<group name='cost_prices' colspan="2"
col="4">
                           
<field name="standard_price" nolabel="1"
attrs="{'readonly':[('cost_method','=','average')]}"/>
                           
<field name="cost_price_extra"
groups="product.group_product_variant"/>
                       
</group>
                   
</xpath>
               
<sheet>
                   
<group col="2" colspan="2" groups="base.group_extended"
position="replace">
                        
<group colspan="2" col="6" name="weight"
groups="base.group_extended">
                           
<field name="is_multi_variants"
invisible="1"/>
                           
<group colspan="2"
col="2">
                               
<separator string="Template Weights"
colspan="2"/>
                               
<field digits="(14, 3)" name="volume"
attrs="{'readonly':[('type','=','service')]}"/>
                               
<field digits="(14, 3)" name="weight"
attrs="{'readonly':[('type','=','service')]}"/>
                               
<field digits="(14, 3)" name="weight_net"
attrs="{'readonly':[('type','=','service')]}"/>
                           
</group>
                           
<group colspan="2" col="2"
attrs="{'invisible':[('is_multi_variants','=',False)]}">
                               
<separator string="Variant Weights"
colspan="2"/>
                               
<field digits="(14, 3)" name="additional_volume"
attrs="{'readonly':[('type','=','service')]}"/>
                               
<field digits="(14, 3)" name="additional_weight"
attrs="{'readonly':[('type','=','service')]}"/>
                               
<field digits="(14, 3)" name="additional_weight_net"
attrs="{'readonly':[('type','=','service')]}"/>
                           
</group>
                           
<group colspan="2" col="2"
attrs="{'invisible':[('is_multi_variants','=',False)]}">
                               
<separator string="Total Weights"
colspan="2"/>
                               
<field digits="(14, 3)"
name="total_volume"/>
                               
<field digits="(14, 3)"
name="total_weight"/>
                               
<field digits="(14, 3)"
name="total_weight_net"/>
                           
</group>
                       
</group>
                   
</group>
               
</sheet>
               
</data>
           
</field>
       
</record>   

<!-- 隐藏 open_ui 按钮
-->
        <record
model="ir.ui.view"
id="pos_session_opening_form_view_openui">
           
<field
name="name">pos.session.opening.form.view.openui</field>
           
<field
name="model">pos.session.opening</field>
           
<field name="inherit_id"
ref="point_of_sale.pos_session_opening_form_view"/>
           
<field name="arch"
type="xml">
                
<xpath expr="//button[@name='open_ui']"
position="replace">
                    
<button name="open_ui" type="object" string="Start Selling"
attrs="{'invisible' : [('pos_state', 'not in', ('opened',))]}"
class="oe_highlight"
invisible="True"/>
                
</xpath>
           
</field>
        </record>

<record
id="product_search_form_view_filter"
model="ir.ui.view">
           
<field
name="name">product.search.form.filter</field>
           
<field
name="model">product.product</field>
           
<field name="inherit_id"
ref="product.product_search_form_view"/>
           
<field name="arch"
type="xml">
               
<filter name="consumable"
position="after">
                  
<separator/>
                  
<filter name="filter_to_qty_available" string="在手数量>0"
icon="terp-accessories-archiver+" domain="[('qty_available', '>',
0)]"/>
                  
<filter name="filter_to_virtual_available" string="预测数量>0"
icon="terp-accessories-archiver+" domain="[('virtual_available', '>',
0)]"/>
               
</filter>
           
</field>
       
</record>

        <!-- Partner kanban view inherte -->
        <record
model="ir.ui.view"
id="crm_lead_partner_kanban_view">
           
<field
name="name">res.partner.kanban.saleorder.inherit</field>
           
<field
name="model">res.partner</field>
           
<field name="inherit_id"
ref="base.res_partner_kanban_view"/>
           
<field name="priority"
eval="20"/>
           
<field name="arch"
type="xml">
               
<field name="mobile"
position="after">

                   
<field
name="sale_order_count"/>
               
</field>

               
<xpath expr="//div[@class='oe_kanban_partner_links']"
position="inside">

                   
<a name="%(sale.act_res_partner_2_sale_order)d" type="action"
t-if="record.sale_order_count.value>0">
                       
<t t-esc="record.sale_order_count.value"/>
Sales
                   
</a>
               
</xpath>

           
</field>
        </record>

         <!--  Partners inherited form -->
        <record
id="view_task_partner_info_form"
model="ir.ui.view">
           
<field
name="name">res.partner.task.info.inherit</field>
           
<field
name="model">res.partner</field>
           
<field name="inherit_id"
ref="base.view_partner_form"/>
           
<field name="arch"
type="xml">
               
<xpath expr="//page[@name='page_history']"
position="attributes">

                   
<attribute
name="invisible">False</attribute>
               
</xpath>
               
<xpath expr="//page[@name='page_history']"
position="inside">

                   
<group name="grp_task"
string="Tasks">
                       
<field name="task_ids" colspan="4"
nolabel="1">
                           
<tree string="Tasks"
editable="bottom">
                               
<field
name="name"/>
                               
<field
name="user_id"/>
                               
<field
name="date_deadline"/>
                               
<field name="state"
invisible="1"/>
                               
<button name="do_open" states="pending,draft,done,cancelled" string="Start
Task" type="object" icon="gtk-media-play" help="For changing to open state"
invisible="context.get('set_visible',False)"/>
                               
<button name="action_close" states="draft,pending,open" string="Done"
type="object" icon="terp-dialog-close" help="For changing to done
state"/>
                           
</tree>
                       
</field>
                     
</group>
               
</xpath>

           
</field>
       </record>

openerp学习笔记 视图继承(tree、form、search)的更多相关文章

  1. openerp学习笔记 视图(tree\form)中隐藏按钮( 创建、编辑、删除 ),tree视图中启用编辑

    视图(tree\form)中隐藏按钮( 创建.编辑.删除 )create="false" edit="false" delete="false&quo ...

  2. openerp学习笔记 视图样式(表格行颜色、按钮,字段只读、隐藏,按钮状态、类型、图标、权限,group边距,聚合[合计、平均],样式)

    表格行颜色:             <tree string="请假单列表" colors="red:state == 'refuse';blue:state = ...

  3. openerp学习笔记 对象继承,对象初始化数据

    1.对象继承     _inherit = "product.product" 继承产品对象,给产品对象添加字段或方法,不需要设置 _name._table 等属性     注意: ...

  4. openerp学习笔记 视图中字段只变化(on_change)联动其他字段值、选择和过滤

    1.修改产品数量时,自动计算产品销售金额.销售成本和销售利润<field name="num" on_change="on_change_product(produ ...

  5. openerp学习笔记 视图更新时删除已存在的菜单或其他对象

    删除菜单示例: <delete id="base.menu_module_updates" model="ir.ui.menu"/><dele ...

  6. c++学习笔记之继承篇

    title: c++学习笔记之继承篇 date: 2017-03-26 16:36:33 tags: [c++,继承,public,virtual,private,protected] categor ...

  7. openerp学习笔记 统计、分析、报表(过滤条件向导、分组报表、图形分析、比率计算、追加视图排序)

    待解决:图形中当改变分组时,图例不正确            存储比率计算时,分组合计不正确 wizard:过滤条件向导,用于输入过滤条件 wizard/sale_chart.py # -*- cod ...

  8. openerp学习笔记 搜索视图(自己创建的、自己的、本部门的、本部门及下属部门的、今日的、日期从,日期至、多条件模糊搜索、or、and)

    自己创建的: domain="[('create_uid','=',uid)]" 自己的: domain="[('employee_id','=','#kl_user_e ...

  9. openerp学习笔记 context 的应用

    1.在Action中定义,context用于传递搜索条件和分组条件,在搜索视图中默认显示: 示例代码: <record model="ir.actions.act_window&quo ...

随机推荐

  1. Android之greenDao,一个orm的使用

    转自:http://blog.csdn.net/krislight/article/details/9391455 greenDaoMaster的学习研究 分类: 心得笔记 2013-07-20 16 ...

  2. Android之录音工具类

    /** * 录音工具类 * * @author rendongwei * */ public class RecordUtil { private static final int SAMPLE_RA ...

  3. 从阿里Java开发手册学习线程池的正确创建方法

    前言 最近看阿里的 Java开发手册,上面有线程池的一个建议: [强制]线程池不允许使用 Executors 去创建,而是通过 ThreadPoolExecutor 的方式,这样的处理方式让写的同学更 ...

  4. JavaScript:Date 对象

    ylbtech-JavaScript:Date 对象 1.返回顶部 Date 对象 Date 对象用于处理日期和时间. 创建 Date 对象的语法: var myDate=new Date() 注释: ...

  5. Palindrome Partitioning leetcode java

    题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return ...

  6. 集合 enum 枚举 简介 案例 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  7. Android基于RecyclerView实现高亮搜索列表

    这篇应该是RecycleView的第四篇了,RecycleView真是新生代的宠儿能做这么多的事情. 转载请注明作者AndroidMsky及原文链接 http://blog.csdn.net/Andr ...

  8. 【Spark】Spark-空RDD判断与处理

    Spark-空RDD判断与处理 SparkKafkaDemo - Streaming Statistics rdd isempty count_百度搜索 Spark RDD.isEmpty costs ...

  9. 艾伦AI研究院发布AllenNLP:基于PyTorch的NLP工具包

    https://www.jiqizhixin.com/articles/2017-09-09-5 AllenNLP 可以让你轻松地设计和评估几乎所有 NLP 问题上最新的深度学习模型,并同基础设施一起 ...

  10. LDA(latent dirichlet allocation)的应用

    http://www.52ml.net/1917.html 主题模型LDA(latent dirichlet allocation)的应用还是很广泛的,之前我自己在检索.图像分类.文本分类.用户评论的 ...