<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
@author: BADEP
@author: Quentin DUPONT (quentin.dupont@grap.coop)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

  <record id="mrp_bom_form_view_section" model="ir.ui.view">
      <field name="model">mrp.bom</field>
      <field name="inherit_id" ref="mrp.mrp_bom_form_view" />
      <field name="arch" type="xml">
        <!-- Add new page -->
          <xpath expr="//page[1]" position="before">
            <page string="Components and sections" name="components_w_sections_notes">
                <field
                        name="bom_line_with_sectionnote_ids"
                        widget="section_and_note_one2many"
                        context="{'default_parent_product_tmpl_id': product_tmpl_id, 'default_product_id': False, 'default_bom_id': id}"
                    >
                    <tree editable="bottom">
                        <control>
                            <create name="add_product_control" string="Add a product" />
                            <create
                                    name="add_section_control"
                                    string="Add a section"
                                    context="{'default_display_type': 'line_section'}"
                                />
                            <create
                                    name="add_note_control"
                                    string="Add a note"
                                    context="{'default_display_type': 'line_note'}"
                                />
                        </control>
                        <field name="display_type" invisible="1" />
                        <field name="company_id" invisible="1" />
                        <field name="sequence" widget="handle" />
                        <field
                                name="product_id"
                                attrs="{
                              'required': [('display_type', '=', False)],
                              'invisible': [('display_type', '=', True)],
                            }"
                                context="{
                              'default_type': 'product',
                              'default_detailed_type': 'product'
                            }"
                            />
                        <field
                                name="name"
                                widget="section_and_note_text"
                                optional="show"
                            />

                        <field name="product_tmpl_id" invisible="1" />
                        <button
                                name="action_see_attachments"
                                type="object"
                                icon="fa-files-o"
                                aria-label="Product Attachments"
                                title="Product Attachments"
                                class="float-end"
                            />
                        <field name="attachments_count" class="text-start" string=" " />
                        <field
                                name="product_qty"
                                attrs="{
                                  'invisible': [('display_type', '=', True)],
                              }"
                            />
                        <field name="product_uom_category_id" invisible="1" />
                        <field name="parent_product_tmpl_id" invisible="1" />
                        <field
                                name="product_uom_id"
                                options="{'no_open':True,'no_create':True}"
                                groups="uom.group_uom"
                                attrs="{
                                   'required': [('display_type', '=', False)],
                                   'invisible': [('display_type', '=', True)],
                                }"
                            />
                        <field
                                name="possible_bom_product_template_attribute_value_ids"
                                invisible="1"
                            />
                        <field
                                name="bom_product_template_attribute_value_ids"
                                optional="hide"
                                widget="many2many_tags"
                                options="{'no_create': True}"
                                attrs="{
                                'column_invisible': [('parent.product_id', '!=', False)],
                                'invisible': [('display_type', '=', True)]
                                }"
                                groups="product.group_product_variant"
                            />
                        <field name="allowed_operation_ids" invisible="1" />
                        <field
                                name="operation_id"
                                groups="mrp.group_mrp_routings"
                                optional="hidden"
                                attrs="{
                                  'column_invisible': [('parent.type','not in', ('normal', 'phantom'))],
                                  'invisible': [('display_type', '=', True)]
                                  }"
                                options="{'no_quick_create':True,'no_create_edit':True}"
                            />
                        <field name="manual_consumption_readonly" invisible="1" />
                        <field
                                name="manual_consumption"
                                optional="hide"
                                width="1.0"
                                attrs="{
                                  'readonly': [('manual_consumption_readonly', '=', True)],
                                  'invisible': [('display_type', '=', True)],
                                  }"
                                force_save="1"
                            />
                    </tree>
                </field>
            </page>
          </xpath>
      </field>
  </record>

</odoo>
