<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2016-2024 Akretion (http://www.akretion.com/)
  @author Alexis de Lattre <alexis.delattre@akretion.com>
  License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

<odoo>


<record id="mrp_bom_form_view" model="ir.ui.view">
    <field name="name">mrp_average_cost.mrp.bom.form</field>
    <field name="model">mrp.bom</field>
    <field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//page[@name='miscellaneous']/group" position="inside">
            <group name="costs">
                <field name="total_components_cost" widget="monetary"
                    options="{'currency_field': 'company_currency_id'}"/>
                <field name="total_labour_cost" widget="monetary"
                    options="{'currency_field': 'company_currency_id'}"/>
                <field name="extra_cost" widget="monetary"
                    options="{'currency_field': 'company_currency_id'}"/>
                <label for="total_cost"/>
                <div>
                    <field name="total_cost" widget="monetary"
                        options="{'currency_field': 'company_currency_id'}"
                        class="oe_inline"/>
                    <button type="object" name="manual_update_product_standard_price"
                        string="Update Cost Price of Product" class="oe_link"/>
                </div>
                <field name="company_currency_id" invisible="1"/>
            </group>
        </xpath>
        <notebook position="inside">
            <page string="Labour" name="labour_lines">
                <group name="labour_lines_grp">
                    <field name="labour_line_ids" nolabel="1"/>
                </group>
            </page>
        </notebook>
        <xpath expr="//field[@name='bom_line_ids']/tree/field[@name='operation_id']" position="after">
            <field name="standard_price"/>
        </xpath>
    </field>
</record>

<record id="mrp_bom_labour_line_tree" model="ir.ui.view">
    <field name="name">mrp_bom_labour_line.tree</field>
    <field name="model">mrp.bom.labour.line</field>
    <field name="arch" type="xml">
        <tree string="Labour Lines" editable="bottom">
            <field name="bom_id" invisible="not context.get('mrp_bom_labour_line_main_view')"/>
            <field name="labour_time" string="Labour Time (hours)"/>
            <field name="labour_cost_profile_id"/>
            <field name="note"/>
        </tree>
    </field>
</record>

<record id="mrp_bom_labour_line_form" model="ir.ui.view">
    <field name="name">mrp_bom_labour_line.form</field>
    <field name="model">mrp.bom.labour.line</field>
    <field name="arch" type="xml">
        <form string="Labour Line">
            <group name="main">
                <field name="bom_id" invisible="not context.get('mrp_bom_labour_line_main_view')"/>
                <label for="labour_time"/>
                <div name="labour_time">
                    <field name="labour_time" class="oe_inline"/> hours
                </div>
                <field name="labour_cost_profile_id"/>
                <field name="note"/>
            </group>
        </form>
    </field>
</record>



<record id="labour_cost_profile_form" model="ir.ui.view">
    <field name="name">labour_cost_profile_form</field>
    <field name="model">labour.cost.profile</field>
    <field name="arch" type="xml">
        <form string="Labour Cost Profile">
            <group name="main">
                <field name="name"/>
                <field name="hour_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
                <field name="company_id" groups="base.group_multi_company"/>
                <field name="company_currency_id" invisible="1"/>
            </group>
        </form>
    </field>
</record>

<record id="labour_cost_profile_tree" model="ir.ui.view">
    <field name="name">labour_cost_profile_tree</field>
    <field name="model">labour.cost.profile</field>
    <field name="arch" type="xml">
        <tree string="Labour Cost Profiles">
            <field name="name"/>
            <field name="hour_cost"/>
            <field name="company_currency_id"/>
        </tree>
    </field>
</record>

<record id="labour_cost_profile_action" model="ir.actions.act_window">
    <field name="name">Labour Cost Profile</field>
    <field name="res_model">labour.cost.profile</field>
    <field name="view_mode">tree,form</field>
</record>

<menuitem id="labour_cost_profile_menu" action="labour_cost_profile_action"
    parent="mrp.menu_mrp_configuration" sequence="200"/>

<record id="mrp_production_form_view" model="ir.ui.view">
    <field name="name">mrp_average_cost.mrp_production_form</field>
    <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
    <field name="model">mrp.production</field>
    <field name="arch" type="xml">
        <xpath expr="//page[@name='miscellaneous']//field[@name='origin']/.." position="inside">
            <field name="extra_cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
            <field name="company_currency_id" invisible="1"/>
        </xpath>
    </field>
</record>


</odoo>
