<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <record model="ir.ui.view" id="app_vpicktree">
        <field name="name">app.stock.picking.tree</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.vpicktree"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='state']" position="before">
                <field name="product_qty_total" sum="Total"/>
                <field name="qty_done_total" sum="Total"/>
                <field name="package_count" sum="Total"/>
                <field name="package_done_count" sum="Total"/>
                <field name="weight_done_total" sum="Total"/>
            </xpath>
        </field>
    </record>

    <record model="ir.ui.view" id="app_view_picking_form">
        <field name="name">app.stock.picking.form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="arch" type="xml">
            <!--扫码视图下隐藏部份内容,此字段不用，用context取代-->
            <xpath expr="//field[@name='partner_id']" position="before">
                <field name="is_barcode_view" invisible="1"/>
            </xpath>
            <xpath expr="//header" position="attributes">
                <attribute name="invisible">context.get('form_view_initial_mode')</attribute>
            </xpath>
            <xpath expr="//h1[1]" position="attributes">
                <attribute name="invisible">context.get('form_view_initial_mode')</attribute>
            </xpath>
            <xpath expr="//h1[1]" position="after">
                <h1>
                    <field name="header_title" readonly="1"
                           invisible="not context.get('form_view_initial_mode')"/>
                </h1>
            </xpath>
            <xpath expr="//div[@name='button_box']" position="inside">
                <button class="oe_stat_button" name="action_see_packages" type="object" icon="fa-cubes"
                 attrs="{'invisible': [('result_package_count', '&lt;', 1)]}">
                    <field string="Packages" name="result_package_count" widget="statinfo"/>
                </button>
            </xpath>
            <xpath expr="//group[1]" position="attributes">
                <attribute name="invisible">context.get('form_view_initial_mode')</attribute>
            </xpath>
            <xpath expr="//group[1]" position="after">
                <group>
                    <field name="result_package_ids" widget="many2many_tags" readonly="1"/>
                </group>
                <div class="row" readonly="1">
                    <div class="col-xs-6 col-md-2">
                        Product：
                        <field name="product_qty_total" class="oe_inline o_form_label"/>
                        ->
                        <field name="qty_done_total" class="oe_inline o_form_label"/>
                    </div>
                    <div class="col-xs-6 col-md-2">
                        Package：
                        <field name="package_count" class="oe_inline o_form_label"/>
                        ->
                        <field name="package_done_count" class="oe_inline o_form_label"/>
                    </div>
                    <div class="col-xs-6 col-md-2">
                        Weight Total：
                        <field name="weight_done_total" class="oe_inline o_form_label"/>
                        <span class="ml4">kg</span>
                    </div>
                    <div class="col-xs-12 col-md-6">
                        <label for="last_op_product"/>
                        <div>
                            <strong>
                                <field name="last_op_product"/>
                            </strong>
                            <button class="btn btn-primary oe_right" name="put_in_pack2" type="object" string="&#8627;放入包裹"
                                    attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}" groups="stock.group_tracking_lot"/>
                            <button class="btn btn-primary oe_right mb4 mr4" name="set_current" type="object" string="刷新扫码视图"
                                    attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}" icon="fa-refresh"/>
                        </div>
                    </div>
                </div>
            </xpath>
            <!--实时扫码操作-->
            <xpath expr="//notebook/page[1]" position="before">
                <page name="current_op" string="Working Product " attrs="{'invisible': [('state', 'in', ('draft', 'confirmed', 'waiting'))]}">
                    <field name="pack_operation_product_current_ids" options="{'reload_on_button': True}"
                           mode="kanban" attrs="{'invisible': [('state', 'in', ('draft', 'confirmed', 'waiting'))]}"
                           context="{'default_picking_id': id}"/>
                </page>
            </xpath>
            <!--显示总数量-->
            <xpath expr="//field[@name='pack_operation_product_ids']/tree/field[@name='product_qty']" position="attributes">
                <attribute name="sum">Total</attribute>
            </xpath>
            <xpath expr="//field[@name='pack_operation_product_ids']/tree/field[@name='qty_done']" position="attributes">
                <attribute name="sum">Total</attribute>
            </xpath>
        </field>
    </record>
</odoo>