<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- MME Planner Starts -->

<record id="action_sos_mme_planner" model="ir.actions.act_window">
    <field name="name">MME Planner</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sos_mme_history_card_line</field>
    <field name="view_mode">tree,calendar</field>
    <field name="domain">[('is_latest', '=', True)]</field>
    <field name="context">{'create': False}</field>
    

</record>

<record id="view_sos_mme_history_card_line_tree" model="ir.ui.view">
    <field name="name">sos.mme.history.card.line.tree</field>
    <field name="model">sos_mme_history_card_line</field>
    <field name="arch" type="xml">
        <tree string="MME History Card Line" default_order="ref_id asc">
          <header>
                    <button name="action_mme_list" string="Report" type="object" class="oe_highlight" display="always"/>
                </header>
            <field name="name"/>
            <field name="mme_id"/>
            <field name="mme_used_in"/>
            <field name="next_calibration_on"/>
<field name="remaining_days" 
       decoration-success="remaining_days &gt;= 0" 
       decoration-danger="remaining_days &lt; 0"/>
       <field name="write_uid" string="Last Edited By" optional="hide"/>
                <field name="write_date" string="Last Edited On" optional="hide"/>
               </tree>
    </field>
</record>

<record id="view_sos_mme_history_card_line_calendar" model="ir.ui.view">
    <field name="name">sos.mme.history.card.line.calendar</field>
    <field name="model">sos_mme_history_card_line</field>
    <field name="arch" type="xml">
        <calendar string="Next Calibration" date_start="next_calibration_on" color="name" mode="year">
            <field name="name"/>
            <field name="mme_id"/>
            <field name="mme_used_in"/>
            <field name="next_calibration_on"/>
        </calendar>
    </field>
</record>

<!-- MME Planner Ends -->
 <record id="action_sos_mme_history_card" model="ir.actions.act_window">
    <field name="name">MME History Card</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">sos_mme_history_card</field>
    <field name="view_mode">tree,form,kanban</field>
</record>


    <record id="action_sos_mme_history_card_tree" model="ir.ui.view">
        <field name="name">sos_mme_history_card.view.tree</field>
        <field name="model">sos_mme_history_card</field>
        <field name="arch" type="xml">
            <tree> 
            <field name="mme_history_card_no"/>

                <field name="name"/>
                <field name="mme_id"/>
                <field name="mme_range"/>
                <field name="calibration_frequency"/>
                <field name="mme_opreating_range"/>
                <field name="calibrated_at"/>
                <field name="margin_tolerance"/>
                <field name="iso_std"/>
                <field name="mme_used_in"/>
                <field name="inhouse_mme_name"/>
            </tree>
        </field>
    </record>

       <record id="sos_mme_history_card_form_view" model="ir.ui.view">
      <field name="name">Form</field>
        <field name="model">sos_mme_history_card</field>
        <field name="arch" type="xml">
  <form string="Model Form">
<sheet>
<group>
<group>
<field name="mme_history_card_no"/>
<field name="name"/>
<field name="mme_id"/>
<field name="mme_range"/>
<field name="calibration_frequency"/>
<field name="mme_opreating_range"/>
</group>
<group>
<field name="calibrated_at"/>
<field name="margin_tolerance"/>
<field name="iso_std"/>
<field name="mme_used_in"/>
<field name="inhouse_mme_name"  invisible="calibrated_at != 'In-House'"/>
</group>
</group>
 <notebook>
 <page string="Components">
 <field name="line_ids">
<tree editable="bottom">                    
 <field name="company_name"/>
<field name="calibration_due_date"/>
<field name="actual_calibrated_date"/>
<field name="certificate_no"/>
<field name="calibration_results"/>
<field name="next_calibration_on"/>
<field name="next_turn_around_time"/>
</tree>
</field>

 </page>
  <page string="Certification">
 <field name="line_ids">
<tree editable="bottom">                    
 <field name="company_name"/>
<field name="certificate"/>
<field name="certificate_filename" column_invisible="1"/>
<button name="action_view_certificate" invisible="not certificate" string="View" type="object" class="btn-primary" icon="fa-eye"/>
</tree>
</field>

 </page>
  </notebook>
</sheet>
                </form>
        </field>
    </record>
 <menuitem id="sos_mme_history_card_menu"
                name="MME History Card"
                action="action_sos_mme_history_card"
                parent="mme_forms_menu_root" groups="sos_inventory.sos_healthcare_user,sos_inventory.sos_scg_group_manager,sos_inventory.sos_scg_group_user,sos_inventory.sos_qc_user,sos_inventory.sos_qa_user,sos_inventory.sos_management_user" />
                
    <menuitem id="sos_mme_history_calendar_menu"
                name="MME Calibration Planner"
                action="action_sos_mme_planner"
                parent="mme_forms_menu_root" groups="sos_inventory.sos_healthcare_user,sos_inventory.sos_scg_group_manager,sos_inventory.sos_scg_group_user,sos_inventory.sos_qc_user,sos_inventory.sos_qa_user,sos_inventory.sos_management_user" />
                          

</odoo>
