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


    <!--  MON RECORD RULE-->
  <record id="sos_on_all_records_rule" model="ir.rule">
    <field name="name">Sos ON: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_mon"/>
    <field name="domain_force">[('prepared_by_name', '!=', False)]</field>
    <field name="groups" eval="[(4, ref('sos_inventory.sos_scg_group_user')), (4, ref('sos_inventory.sos_management_user'))]"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_write" eval="1"/>
    <field name="perm_create" eval="1"/>
    <field name="perm_unlink" eval="0"/>
</record>
<record id="sos_on_own_records_rule" model="ir.rule">
<field name="name">Sos ON: Own Records - Read Access</field>
<field name="model_id" ref="model_sos_mon"/>    
<field name="domain_force">[
'|',
('filled_by', '=', user.id),
('reporting_to', '=', user.id)
]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_create" eval="1"/>
<field name="perm_unlink" eval="0"/>
</record>
      <!--  NCMR RECORD RULE-->
<record id="sos_ncmr_own_records_rule" model="ir.rule">
    <field name="name">Sos NCMR: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_ncmr"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_scg_group_user')), 
        (4, ref('sos_inventory.sos_management_user')), 
        (4, ref('sos_inventory.sos_qc_user')), 
        (4, ref('sos_inventory.sos_qa_user')),
        (4, ref('sos_inventory.sos_production_user'))
    ]"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_write" eval="1"/>
    <field name="perm_create" eval="1"/>
    <field name="perm_unlink" eval="0"/>
</record>
<record id="sos_ncmr_all_records_rule" model="ir.rule">
    <field name="name">Sos NCMR: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_ncmr"/>
    <field name="domain_force">
        ['|',
            ('rd_user', 'in', [user.id]),
            ('rework_responsible_rd_user', '=', user.id)
        ]
    </field>
    <field name="groups" eval="[(4, ref('base.group_user'))]"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_write" eval="1"/>
    <field name="perm_create" eval="0"/>
    <field name="perm_unlink" eval="0"/>
</record>



    <!--  MIN RECORD RULE-->
  <record id="sos_in_all_records_rule" model="ir.rule">
    <field name="name">Sos IN: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_min"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[(4, ref('sos_inventory.sos_finance_user')),(4, ref('sos_inventory.sos_scg_group_user')), (4, ref('sos_inventory.sos_management_user'))]"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_write" eval="1"/>
    <field name="perm_create" eval="1"/>
    <field name="perm_unlink" eval="0"/>
</record>
  
 <record id="sos_in_own_records_rule" model="ir.rule">
    <field name="name">Sos IN: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_min"/>
    <field name="domain_force">[
            '|',
            '|',
            ('mon_created_by', '=', user.id),
            ('reporting_to', '=', user.id),
            ('manual_received_by', '=', user.id)
        ]</field>
        <field name="groups" eval="[(4, ref('base.group_user'))]"/>
 <field name="perm_read" eval="1"/>
        <field name="perm_write" eval="1"/>
        <field name="perm_create" eval="1"/>
        <field name="perm_unlink" eval="0"/>
</record>

  <!--  MRN RECORD RULE-->
  <record id="sos_rn_all_records_rule" model="ir.rule">
    <field name="name">Sos RN: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_mrn"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[(4, ref('sos_inventory.sos_scg_group_user')), (4, ref('sos_inventory.sos_management_user')), (4, ref('sos_inventory.sos_qa_user')), (4, ref('sos_inventory.sos_finance_user'))]"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_write" eval="1"/>
    <field name="perm_create" eval="1"/>
    <field name="perm_unlink" eval="0"/>
</record>
  
 <record id="sos_rn_own_records_rule" model="ir.rule">
    <field name="name">Sos RN: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_mrn"/>
        

    <field name="domain_force">[
            '|',
            ('filled_by', '=', user.id),
            ('reporting_to', '=', user.id)
        ]</field>
        <field name="groups" eval="[(4, ref('base.group_user'))]"/>
 <field name="perm_read" eval="1"/>
        <field name="perm_write" eval="1"/>
        <field name="perm_create" eval="1"/>
        <field name="perm_unlink" eval="0"/>
</record>
    <!--  FG BOM RECORD RULE-->
  <record id="sos_fg_bom_full_access_rule" model="ir.rule">
    <field name="name">Sos FG BOM: Full Access</field>
    <field name="model_id" ref="model_sos_fg_bom"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_finance_user')),
        (4, ref('sos_inventory.sos_scg_group_user')),
        (4, ref('sos_inventory.sos_scg_group_manager')),
        (4, ref('sos_inventory.sos_management_user'))
    ]"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_write" eval="1"/>
    <field name="perm_create" eval="1"/>
    <field name="perm_unlink" eval="0"/>
</record>
<record id="sos_fg_bom_restricted_access_rule" model="ir.rule">
    <field name="name">Sos FG BOM: Restricted Access</field>
    <field name="model_id" ref="model_sos_fg_bom"/>
    <field name="domain_force">[
        '|',
        ('responsible_person', '=', user.id),
        ('create_uid', '=', user.id)
    ]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_rd_user'))
    ]"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_write" eval="0"/>
    <field name="perm_create" eval="0"/>
    <field name="perm_unlink" eval="0"/>
</record>

  
</odoo>
