<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="subcontracting_portal_production_form_view" model="ir.ui.view">
        <field name="name">subcontracting.portal.production.view.form</field>
        <field name="model">stock.picking</field>
        <field name="priority">999</field>
        <field name="arch" type="xml">
            <form js_class="subcontracting_portal_picking_form_view" string="Manufacturing Orders">
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="name" placeholder="Manufacturing Reference" nolabel="1"/>
                        </h1>
                    </div>
                    <group>
                        <field name="state" invisible='1'/>
                        <field name="scheduled_date" readonly="state in ['cancel', 'done']" required="id" decoration-warning="state not in ('done', 'cancel') and scheduled_date &lt; now" decoration-danger="state not in ('done', 'cancel') and scheduled_date &lt; current_date" decoration-bf="state not in ('done', 'cancel') and (scheduled_date &lt; current_date or scheduled_date &lt; now)"/>
                        <field name="date_deadline" invisible="state in ('done', 'cancel') or not date_deadline" decoration-danger="date_deadline and date_deadline &lt; current_date" decoration-bf="date_deadline and date_deadline &lt; current_date"/>
                        <field name="origin" placeholder="e.g. PO0032" readonly="state in ['cancel', 'done']"/>
                    </group>
                    <notebook>
                        <page string="Operations" name="operations">
                            <field name="move_ids" mode="list" context="{'default_picking_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id, 'default_date': scheduled_date}">
                                <list no_open="1">
                                    <field name="id" readonly="1" column_invisible="True"/>
                                    <field name="product_id" readonly="1"/>
                                    <field name="show_details_visible" column_invisible="True"/>
                                    <field name="description_picking" string="Description" optional="hide"/>
                                    <field name="date" optional="hide"/>
                                    <field name="date_deadline" optional="hide"/>
                                    <field name="product_uom_qty" string="Demand" readonly="1"/>
                                    <field name="product_qty" readonly="1" column_invisible="True"/>
                                    <field name="quantity" string="Done"/>
                                    <field name="product_uom" groups="uom.group_uom" widget="many2one_uom"/>
                                    <button name="action_show_details" type="object" icon="fa-list" title="Details"
                                                invisible="not show_details_visible" context="{'is_subcontracting_portal': 1}"/>
                                    <field name="show_subcontracting_details_visible" column_invisible="True"/>
                                    <button name="action_show_subcontract_details" string="Register components for subcontracted product" type="object" icon="fa-sitemap"
                                        invisible="not show_subcontracting_details_visible"/>
                                </list>
                            </field>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <record id="subcontracting_portal_view_production_action" model="ir.actions.act_window">
        <field name="name">Subcontracting Portal</field>
        <field name="res_model">stock.picking</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="subcontracting_portal_production_form_view"/>
    </record>

</odoo>
