<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!--  Achievement Report RECORD RULE-->
<record id="sos_sales_achievement_report_own_records_rule" model="ir.rule">
    <field name="name">Sos Achievement Report: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_achievement_report"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_management_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_sales_achievement_report_all_records_rule" model="ir.rule">
    <field name="name">Sos Achievement Report: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_achievement_report"/>
    <field name="domain_force">[
    ('create_uid', '=', 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>
<!--  Sales Target RECORD RULE-->
<record id="sos_sales_plan_target_own_records_rule" model="ir.rule">
    <field name="name">Sos Sales Target: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_plan_target"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_management_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_sales_plan_target_all_records_rule" model="ir.rule">
    <field name="name">Sos Sales Target: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_plan_target"/>
    <field name="domain_force">[
    '|',
    ('create_uid', '=', user.id),
    ('sales_executive', '=', 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>
<!--  sales_action RECORD RULE-->
<record id="sos_sales_action_plan_own_records_rule" model="ir.rule">
    <field name="name">Sos sales action plan: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_action_plan"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_management_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_sales_action_plan_all_records_rule" model="ir.rule">
    <field name="name">Sos sales action plan: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_action_plan"/>
    <field name="domain_force">[
    '|',
    ('create_uid', '=', user.id),
    ('sales_executive', '=', 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>
      <!--  customers RECORD RULE-->
<record id="sos_customers_own_records_rule" model="ir.rule">
    <field name="name">Sos customers: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_customers"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_management_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_customers_all_records_rule" model="ir.rule">
    <field name="name">Sos customers: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_customers"/>
     <field name="domain_force">[
           '|', '|',
            ('create_uid', '=', user.id),
            ('reporting_to', '=', user.id),
            ('responsible', '=', 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>

      <!--  case_diary RECORD RULE-->
<record id="sos_case_diary_own_records_rule" model="ir.rule">
    <field name="name">Sos Case Diary: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_case_diary"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_management_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_case_diary_all_records_rule" model="ir.rule">
    <field name="name">Sos Case Diary: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_case_diary"/>
    <field name="domain_force">
        [
            '|', '|',
            ('create_uid', '=', user.id),
            ('reporting_to', '=', user.id),
            ('sales_person', '=', 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>
       <!--  Case Diary Report RECORD RULE-->
<record id="sos_case_diary_report_own_records_rule" model="ir.rule">
    <field name="name">Sos Case Diary Report: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_case_diary_report"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (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_case_diary_report_all_records_rule" model="ir.rule">
    <field name="name">Sos Case Diary Report: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_case_diary_report"/>
    <field name="domain_force">[
            '|',
            ('create_uid', '=', 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="0"/>
    <field name="perm_unlink" eval="0"/>
</record> 
      <!--  Leads RECORD RULE-->
<record id="sos_sales_leads_own_records_rule" model="ir.rule">
    <field name="name">Sos Leads: Own Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_leads"/>
    <field name="domain_force">[(1, '=', 1)]</field>
    <field name="groups" eval="[
        (4, ref('sos_inventory.sos_management_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_sales_leads_all_records_rule" model="ir.rule">
    <field name="name">Sos Leads: All Records - Read Access</field>
    <field name="model_id" ref="model_sos_sales_leads"/>
     <field name="domain_force">[
            '|',
            ('create_uid', '=', user.id),
            ('lead_generated_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="0"/>
    <field name="perm_unlink" eval="0"/>
</record>
</odoo>
