<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- 工作中心看板 -->
    <record id="mrp_production_view_form_inherit_maintenance" model="ir.ui.view">
        <field name="name">mrp.production.view.form.inherit.maintenance</field>
        <field name="model">mrp.production</field>
        <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
        <field name="arch" type="xml">
            <button name="action_cancel" position="before">
                <button name="button_maintenance_req" type="object" string="维修请求"/>
            </button>
            <div name="button_box" position="inside">
                <button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
                        attrs="{'invisible': [('maintenance_count', '=', 0)]}"
                        context="{'search_default_production_id': active_id}">
                    <div class="o_field_widget o_stat_info">
                        <span class="o_stat_value">
                            <field name="maintenance_count"/>
                        </span>
                        <span class="o_stat_text">Maintenance</span>
                    </div>
                </button>
            </div>
        </field>
    </record>

    <!--    <record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">-->
    <!--        <field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>-->
    <!--        <field name="model">mrp.workcenter</field>-->
    <!--        <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>-->
    <!--        <field name="arch" type="xml">-->
    <!--            &lt;!&ndash; Desktop view &ndash;&gt;-->
    <!--            <xpath expr="//div[@name='o_wo']" position="inside">-->
    <!--                <button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object"-->
    <!--                        context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}"-->
    <!--                        title="Work orders" aria-label="Work orders"/>-->
    <!--            </xpath>-->
    <!--        </field>-->
    <!--    </record>-->

    <!-- override to change the no content image -->
    <record id="mrp.action_work_orders" model="ir.actions.act_window">
        <field name="help" type="html">
            <p class="o_view_nocontent_workorder">
                没有工单要做！
            </p>
            <p>
                工作订单是作为制造订单的一部分执行的操作。
                工序在物料清单中定义或直接添加到制造订单中。
            </p>
            <p>
                使用工作台工作中心控制面板直接登记车间中的操作.
                平板电脑为您的工人提供工作表，并允许他们报废产品，跟踪时间,
                发起维护请求，执行质量测试等.
            </p>
        </field>
    </record>
    <record id="mrp_workcenter_kanban_action1" model="ir.actions.act_window">
        <field name="name">工作中心看板</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp.workcenter</field>
        <field name="view_mode">kanban,form</field>
        <field name="view_id" ref="mrp.mrp_workcenter_kanban"/>
        <field name="search_view_id" ref="mrp.view_mrp_workcenter_search"/>
        <field name="domain">[('users_ids','in',uid)]</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                创建新的工作中心
            </p>
            <p>
                制造业务在工作中心处理。工作中心可以由
                工人和/或机器，它们用于成本核算、调度、产能规划等。
                它们可以通过配置菜单定义。
            </p>
        </field>
    </record>

    <menuitem id="menu_mrp_dashboard"
              name="工作中心看板"
              action="mrp_workcenter_kanban_action1"
              groups="mrp.group_mrp_routings"
              parent="mrp.menu_mrp_root"
              sequence="5"/>

    <!-- MRP.WORKCENTER -->
    <record model="ir.ui.view" id="view_mrp_workcenter_form_inherit_sf">
        <field name="name">mrp.workcenter.form.inherit.sf</field>
        <field name="model">mrp.workcenter</field>
        <field name="inherit_id" ref="mrp.mrp_workcenter_view"/>
        <field name="arch" type="xml">
            <xpath expr="//notebook" position="inside">
                <page string="Equipment" name="equipment">
                    <field name="equipment_ids" widget="many2many">
                        <tree string="Equipments">
                            <field name="name"/>
                            <field name="technician_user_id"/>
                            <field name="category_id"/>
                            <field name="mtbf"/>
                            <field name="mttr"/>
                            <field name="estimated_next_failure" string="Est. Next Failure"/>
                        </tree>
                    </field>
                </page>
            </xpath>
            <xpath expr="//field[@name='company_id']" position="after">
                <field name="users_ids" widget="many2many_tags" string="可操作用户"/>
            </xpath>

            <xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
                <field name="machine_tool_id" domain="[('is_binding','=',False)]"/>
            </xpath>
        </field>
    </record>

    <record id="mrp_workcenter_view_kanban_inherit_maintenance" model="ir.ui.view">
        <field name="name">mrp.workcenter.view.kanban.inherit.maintenance</field>
        <field name="model">mrp.workcenter</field>
        <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
        <field name="arch" type="xml">
            <xpath expr="//div[@name='plan_order']" position="after">
                <div>
                    <a name="%(maintenance.hr_equipment_request_action)d" type="action">Maintenance</a>
                </div>
            </xpath>
        </field>
    </record>

    <!-- MRP.PRODUCTION -->
    <record id="mrp_production_view_form_inherit_maintenance" model="ir.ui.view">
        <field name="name">mrp.production.view.form.inherit.maintenance</field>
        <field name="model">mrp.production</field>
        <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
        <field name="arch" type="xml">
            <button name="action_cancel" position="before">
                <button name="button_maintenance_req" type="object" string="维修请求"/>
            </button>
            <div name="button_box" position="inside">
                <button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
                        attrs="{'invisible': [('maintenance_count', '=', 0)]}"
                        context="{'search_default_production_id': active_id}">
                    <div class="o_field_widget o_stat_info">
                        <span class="o_stat_value">
                            <field name="maintenance_count"/>
                        </span>
                        <span class="o_stat_text">Maintenance</span>
                    </div>
                </button>
            </div>
            <field name="product_id" position="after">
                <field name="model_file" string="产品模型" readonly="1" widget="Viewer3D"/>
            </field>
        </field>
    </record>


</odoo>
