zoukankan      html  css  js  c++  java
  • openerp学习笔记 视图继承(tree、form、search)

    支持的视图类型: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>

  • 相关阅读:
    react性能检测与优化
    react组件在项目中的应用(基础知识)
    前端性能优化
    我们一起来详细的了解react的语法以及组件的使用方法
    和我一起使用webpack构建react项目
    babel与ES6环境的搭建
    Razor 在JS中嵌入后台变量
    HttpClient + ASP.NET Web API, WCF之外的另一个选择
    《大型网站技术架构》读书笔记[3]
    Remote Desktop Connection Manager 多个远程管理
  • 原文地址:https://www.cnblogs.com/cnshen/p/3164275.html
Copyright © 2011-2022 走看看