odoo14、15里tree上加button【系统原生功能】

odoo14、15里面tree视图已经添加了跟form一样的header标签,后面列表写button可以由此处扩展

系统案例:注意:按钮要选择数据后才出现

 

 代码如下:

                <tree string="Manufacturing Orders" js_class="lazy_column_list" default_order="priority desc, date_planned_start desc" multi_edit="1" sample="1" decoration-info="state == 'draft'">
                    <header>
                        <button name="button_plan" type="object" string="Plan"/>
                        <button name="do_unreserve" type="object" string="Unreserve"/>
                    </header>
                    <field name="priority" optional="show" widget="priority" nolabel="1"/>
                    <field name="message_needaction" invisible="1"/>
                    <field name="name" decoration-bf="1"/>
                    <field name="date_planned_start" readonly="1" optional="show" widget="remaining_days"/>
                    <field name="date_deadline" widget="remaining_days" attrs="{'invisible': [('state', 'in', ['done', 'cancel'])]}" optional="hide"/>
                    <field name="product_id" readonly="1" optional="show"/>
                    <field name="lot_producing_id" optional="hide"/>
                    <field name="bom_id" readonly="1" optional="hide"/>
                    <field name="activity_ids" string="Next Activity" widget="list_activity" optional="show" nolabel="1"/>
                    <field name="origin" optional="show"/>
                    <field name="user_id" optional="hide" widget="many2one_avatar_user"/>
                    <field name="components_availability_state" invisible="1" options="{&quot;lazy&quot;: true}"/>
                    <field name="components_availability" options="{&quot;lazy&quot;: true}" attrs="{'invisible': [('state', 'not in', ['confirmed', 'progress'])]}" optional="show" decoration-success="reservation_state == 'assigned' or components_availability_state == 'available'" decoration-warning="reservation_state != 'assigned' and components_availability_state in ('expected', 'available')" decoration-danger="reservation_state != 'assigned' and components_availability_state == 'late'"/>
                    <field name="reservation_state" optional="hide" decoration-danger="reservation_state == 'confirmed'" decoration-success="reservation_state == 'assigned'"/>
                    <field name="product_qty" sum="Total Qty" string="Quantity" readonly="1" optional="show"/>
                    <field name="product_uom_id" string="UoM" options="{'no_open':True,'no_create':True}" groups="uom.group_uom" optional="show"/>
                    <field name="production_duration_expected" attrs="{'invisible': [('production_duration_expected', '=', 0)]}" groups="mrp.group_mrp_routings" widget="float_time" sum="Total expected duration" optional="show"/>
                    <field name="production_real_duration" attrs="{'invisible': [('production_real_duration', '=', 0)]}" groups="mrp.group_mrp_routings" widget="float_time" sum="Total real duration" optional="show"/>
                    <field name="company_id" readonly="1" groups="base.group_multi_company" optional="show"/>
                    <field name="state" decoration-success="state in ('done', 'to_close')" decoration-warning="state == 'progress'" decoration-info="state in ('confirmed', 'draft')" optional="show" widget="badge"/>
                    <field name="activity_exception_decoration" widget="activity_exception"/>
                    <field name="delay_alert_date" invisible="1"/>
                    <field nolabel="1" name="json_popover" widget="stock_rescheduling_popover" attrs="{'invisible': [('json_popover', '=', False)]}"/>
                </tree>

 

 

 

 

 

posted @ 2022-03-04 11:04  何双新  阅读(533)  评论(1编辑  收藏  举报