<odoo>

  <record id="action_open_return_reason_wizard" model="ir.actions.act_window">
    <field name="name">سبب الإرجاع</field>
    <field name="res_model">pa.return.reason.wizard</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
  </record>

  <!-- Levels Views -->
  <record id="view_pa_program_level_tree" model="ir.ui.view">
    <field name="name">pa.program.level.tree</field>
    <field name="model">pa.program.level</field>
    <field name="arch" type="xml">
      <tree>
        <field name="code"/>
        <field name="name"/>
        <field name="type"/>
        <field name="active"/>
        <field name="track_ids" string="المسارات المرتبطة" widget="many2many_tags"/>
      </tree>
    </field>
  </record>

  <record id="view_pa_program_level_form" model="ir.ui.view">
    <field name="name">pa.program.level.form</field>
    <field name="model">pa.program.level</field>
    <field name="arch" type="xml">
      <form>
        <sheet>
          <group>
            <field name="code" readonly="1"/>
            <field name="name" required="1" placeholder="مسارات تقنية - ثقافية – معرفية – دينية"/>
            <field name="type" widget="selection" required="1"/>
            <field name="description"/>
            <field name="active"/>
          </group>
          <notebook>
            <page string="المسارات المرتبطة">
              <field name="track_ids" context="{'default_level_id': active_id}">
                <tree editable="bottom">
                  <field name="code"/>
                  <field name="name"/>
                  <field name="branch"/>
                  <field name="gender"/>
                  <field name="age_category"/>
                  <field name="study_category"/>
                  <field name="hobby"/>
                  <field name="study_status"/>
                  <field name="health_status"/>
                  <field name="education_status"/>
                  <field name="partner_id"/>
                  <field name="active"/>
                </tree>
              </field>
            </page>
          </notebook>
        </sheet>
      </form>
    </field>
  </record>



  <record id="view_pa_program_level_search" model="ir.ui.view">
    <field name="name">pa.program.level.search</field>
    <field name="model">pa.program.level</field>
    <field name="arch" type="xml">
      <search>
        <field name="code"/>
        <field name="name"/>
        <filter name="active_filter" string="نشط" domain="[('active', '=', True)]"/>
      </search>
    </field>
  </record>

  <record id="action_pa_program_level" model="ir.actions.act_window">
    <field name="name">مستويات البرامج</field>
    <field name="res_model">pa.program.level</field>
    <field name="view_mode">tree,form</field>
    <field name="search_view_id" ref="view_pa_program_level_search"/>
  </record>

  <!-- Tracks Views -->
  <record id="view_pa_program_track_tree" model="ir.ui.view">
    <field name="name">pa.program.track.tree</field>
    <field name="model">pa.program.track</field>
    <field name="arch" type="xml">
      <tree>
        <field name="code"/>
        <field name="name"/>
        <field name="branch"/>
        <field name="gender"/>
        <field name="age_category"/>
        <field name="study_category"/>
        <field name="hobby"/>
        <field name="study_status"/>
        <field name="health_status"/>
        <field name="education_status"/>
        <field name="partner_id"/>
        <field name="active"/>
        <field name="level_id"/>
      </tree>
    </field>
  </record>

  <record id="view_pa_program_track_form" model="ir.ui.view">
    <field name="name">pa.program.track.form</field>
    <field name="model">pa.program.track</field>
    <field name="arch" type="xml">
      <form>
        <sheet>
          <group>
            <field name="code" readonly="1"/>
            <field name="name" required="1"/>
            <field name="description"/>
          </group>
          <group>
            <field name="branch"/>
            <field name="gender" widget="selection"/>
            <field name="age_category" />
            <field name="study_category"/>
            <field name="hobby"/>
            <field name="study_status"/>
            <field name="health_status"/>
            <field name="education_status"/>
            <field name="partner_id"/>
            <field name="active"/>
            <field name="level_id" required="1"/>
          </group>
        </sheet>
      </form>
    </field>
  </record>



  <record id="view_pa_program_track_search" model="ir.ui.view">
    <field name="name">pa.program.track.search</field>
    <field name="model">pa.program.track</field>
    <field name="arch" type="xml">
      <search>
        <field name="code"/>
        <field name="name"/>
        <field name="level_id" string="المستوى المرتبط"/>
        <filter name="active_filter" string="نشط" domain="[('active', '=', True)]"/>
      </search>
    </field>
  </record>
  <record id="action_pa_program_track" model="ir.actions.act_window">
    <field name="name">مسارات البرامج</field>
    <field name="res_model">pa.program.track</field>
    <field name="view_mode">tree,form</field>
    <field name="search_view_id" ref="view_pa_program_track_search"/>
  </record>

  <!-- Programs Views -->
  <record id="view_pa_program_tree" model="ir.ui.view">
    <field name="name">pa.program.tree</field>
    <field name="model">pa.program</field>
    <field name="arch" type="xml">
      <tree>
        <field name="code"/>
        <field name="name"/>
        <field name="program_type_id" />
        <!--        <field name="kind"/>-->
        <field name="payment_type"/>
        <field name="sponsor_id"/>
        <field name="sponsor_support_amount"/>
        <field name="budget"/>
        <field name="location"/>
        <field name="active"/>
        <field name="track_id"/>
      </tree>
    </field>
  </record>

  <record id="view_pa_program_form" model="ir.ui.view">
    <field name="name">pa.program.form</field>
    <field name="model">pa.program</field>
    <field name="arch" type="xml">
      <form string="البرنامج">
        <sheet>
          <group>
            <field name="code" readonly="1"/>
            <field name="name" required="1"/>
            <field name="program_type_id" />
            <!--            <field name="kind" widget="selection" required="1"/>-->
            <field name="payment_type" required="1"/>
            <field name="sponsor_id" attrs="{'invisible': [('payment_type','!=','paid')]}"/>
            <field name="sponsor_support_amount"/>
            <field name="budget"/>
            <field name="location" widget="selection" required="1"/>
            <field name="description"/>
          </group>
          <group>
            <field name="track_id" required="1"/>
            <field name="analytic_account_id" options="{'no_create': True}" readonly="1"/>
            <!--            <field name="estimated_budget"/>-->
            <field name="active"/>
          </group>
        </sheet>
      </form>
    </field>
  </record>

  <record id="action_pa_program" model="ir.actions.act_window">
    <field name="name">البرامج</field>
    <field name="res_model">pa.program</field>
    <field name="view_mode">tree,form</field>
  </record>

  <!-- Activities Views -->
  <record id="view_pa_program_activity_tree" model="ir.ui.view">
    <field name="name">pa.program.activity.tree</field>
    <field name="model">pa.program.activity</field>
    <field name="arch" type="xml">
      <tree>
        <field name="code"/>
        <field name="name"/>
        <field name="program_id"/>
        <field name="location"/>
        <field name="date_start"/>
        <field name="date_end"/>
        <field name="active"/>
      </tree>
    </field>
  </record>

  <record id="view_pa_program_activity_form" model="ir.ui.view">
    <field name="name">pa.program.activity.form</field>
    <field name="model">pa.program.activity</field>
    <field name="arch" type="xml">
      <form string="النشاط">
        <sheet>
          <group>
            <field name="code" readonly="1"/>
            <field name="name" required="1"/>
            <field name="description"/>
          </group>
          <group>
            <field name="program_id" required="1"/>
            <field name="location" widget="selection" required="1"/>
            <field name="date_start"/>
            <field name="date_end"/>
            <field name="analytic_account_id" options="{'no_create': True}" readonly="1"/>
            <!--            <field name="estimated_budget"/>-->
            <field name="active"/>
          </group>
        </sheet>
      </form>
    </field>
  </record>

  <record id="action_pa_program_activity" model="ir.actions.act_window">
    <field name="name">الأنشطة</field>
    <field name="res_model">pa.program.activity</field>
    <field name="view_mode">tree,form</field>
  </record>

  <!-- Medad Views -->
  <record id="view_pa_program_medad_tree" model="ir.ui.view">
    <field name="name">pa.program.medad.tree</field>
    <field name="model">pa.program.medad</field>
    <field name="arch" type="xml">
      <tree>
        <field name="code"/>
        <field name="name"/>
        <field name="medad_type"/>
        <field name="activity_id"/>
        <field name="active"/>
      </tree>
    </field>
  </record>

  <record id="view_pa_program_medad_form" model="ir.ui.view">
    <field name="name">pa.program.medad.form</field>
    <field name="model">pa.program.medad</field>
    <field name="arch" type="xml">
      <form string="مداد">
        <sheet>
          <group>
            <field name="code" readonly="1"/>
            <field name="name" required="1"/>
            <field name="description"/>
          </group>
          <group>
            <field name="medad_type" widget="selection" required="1"/>
            <field name="activity_id" required="0"/>
            <field name="analytic_account_id" options="{'no_create': True}" readonly="1"/>
            <!--            <field name="estimated_budget"/>-->
            <field name="active"/>
          </group>
        </sheet>
      </form>
    </field>
  </record>

  <record id="action_pa_program_medad" model="ir.actions.act_window">
    <field name="name">مداد</field>
    <field name="res_model">pa.program.medad</field>
    <field name="view_mode">tree,form</field>
  </record>



  <record id="view_pa_program_activity_registration_form" model="ir.ui.view">
    <field name="name">pa.program.activity.registration.form</field>
    <field name="model">pa.program.activity.registration</field>
    <field name="arch" type="xml">
      <form string="تسجيل الأنشطة">
        <sheet>
          <header>
            <field name="state" widget="statusbar"
                   statusbar_visible="draft,social_specialist,operation_manager,branch_manager,activity_head,finance_manager,approved,refused"/>
            <button name="action_to_social_specialist"
                    string="اعتماد الاخصائي الاجتماعي" type="object"
                    class="oe_highlight" states="draft"
                    groups="odex_benefit.group_pa_social_specialist"/>
            <button name="action_approve" string="اعتماد" type="object"
                    states="social_specialist,operation_manager,branch_manager,activity_head,finance_manager"
                    groups="odex_benefit.group_pa_operation_manager,odex_benefit.group_pa_branch_manager,odex25_program_activity.group_pa_activity_head,odex_benefit.group_pa_finance_manager"/>
            <button name="action_refuse" string="رفض" type="object"
                    states="draft,social_specialist,operation_manager,branch_manager,activity_head,finance_manager"
                    groups="odex25_program_activity.group_social_specialist,odex_benefit.group_pa_operation_manager,odex_benefit.group_pa_branch_manager,odex25_program_activity.group_pa_activity_head,odex_benefit.group_pa_finance_manager"/>
            <button type="object" name="action_return_to_draft"
                    string="إعادة إلى المسودة"

                    groups="odex25_program_activity.group_social_specialist,odex_benefit.group_pa_operation_manager"
                    states="social_specialist,operation_manager"/>
            <button type="object" name="action_return_to_draft"
                    string="إعادة إلى الأخصائي الاجتماعي"
                    groups="odex_benefit.group_pa_operation_manager" states="operation_manager"/>
          </header>

          <group string="معلومات الإنشاء" col="2">
            <field name="name" readonly="1"/>
            <field name="request_date" readonly="1"/>
            <field name="creator_id" readonly="1"/>
            <field name="date_from"/>
            <field name="date_to"/>
          </group>

          <group string="معلومات الأسرة" col="2">
            <!--            domain="[('mother_marital_status','=','widow')]"-->
            <!--            <field name="family_id" />-->
            <field name="familye_id" />
            <field name="branch_custom_id" />
            <field name="benefit_category_id" />
            <field name="gender" />
            <field name="nationality_id" />
            <field name="graduation_status" />
            <field name="health_status" />
            <field name="education_status" />

            <!--            <field name="familye_member"/>-->
            <field name="beneficiary_relation"/>
            <!--            <field name="beneficiary_ids"/>-->
            <field name="sms_phone" readonly="1"/>
          </group>

          <group string="معلومات البرامج والأنشطة" col="2">
            <field name="level_id" required="1"/>
            <field name="track_id"/>
            <field name="program_id"/>
            <field name="activity_id"/>
            <field name="medad_id"/>
            <field name="want_transport"/>
            <field name="return_reason"/>
          </group>

          <notebook string="بيانات احصائية">
            <page string="بيانات الأبناء">
              <group>
                <field name="sons" readonly="1"/>
                <field name="daughters" readonly="1"/>
              </group>
            </page>
            <page string="بيانات الأم">
              <group>
                <field name="mother_is_life" readonly="1"/>
                <field name="mother_location_conf" readonly="1"/>
                <field name="is_mother_work" readonly="1"/>
                <field name="education_status" readonly="1"/>
                <!--                <field name="mother_education" readonly="1"/>-->
                <field name="housing_type" readonly="1"/>
              </group>
            </page>

            <page string="بيانات المستفيد">
              <field name="member_ids" widget="one2many_list"
                     readonly="1" edit="0" create="0">
                <form string="Family Member">
                  <widget name="web_ribbon" title="Non Benefit Member" bg_color="bg-danger"
                          attrs="{'invisible': [('member_status', '!=', 'non_benefit')]}"/>
                  <widget name="web_ribbon" title="Benefit Member" bg_color="bg-success"
                          attrs="{'invisible': [('member_status', '!=', 'benefit')]}"/>
                  <sheet>
                    <group>
                      <label for="relationn" string="Relation"/>
                      <div>
                        <field name="relationn" class="oe_inline" nolabel="1"
                               attrs="{'readonly':[('parent.state','not in',['draft','new','complete_info'])]}"
                               options='{"no_open": True,"no_create_edit": True}'
                               required="1"/>
                        <field name="relation" class="oe_inline" nolabel="1" invisible="1"/>
                      </div>
                    </group>
                    <group>
                      <group>
                        <field placeholder="Name" name="name" class="oe_inline" readonly="1"
                               force_save="1" invisible="1"/>
                        <field name="is_mother" invisible="1"/>
                        <field name="member_first_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
                        <field name="mother_first_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',False)],'required':[('is_mother','=',True)]}"/>
                        <field name="member_third_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
                        <field name="mother_third_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',False)],'required':[('is_mother','=',True)]}"/>
                        <field name="member_id_number" required="1"/>
                        <field name="is_dead"/>
                        <field name="death_certificate" widget="many2many_attachment_preview"
                               attrs="{'invisible':[('is_dead','=',False)]}"/>
                        <!--                                                     <field name="gender" required="1"/>-->
                        <field name="member_location" force_save="1" invisible="1"/>
                        <field name="relationn_type" invisible="1"/>
                        <field name="member_location_conf" required="1" domain="[('location_type', '=', relationn_type in ['mother','replacement_mother'] and 'mother_location' or 'member')]"
                               options="{'no_create': True, 'no_create_edit': True}"/>
                        <field name="is_work" attrs="{'invisible':[('age','&lt;',18)]}"/>
                        <field name="member_income"
                               attrs="{'invisible':['|',('age','&lt;',18),('is_work','=',False)], 'required':[('is_work','=',True)]}"/>
                        <field name="salary_certificate" widget="many2many_attachment_preview" attrs="{'invisible':['|',('age','&lt;',18),('is_work','=',False)]}"/>
                        <field name="minor_siblings" readonly="1" force_save="1"/>
                        <field name="sponsor_id"/>
                        <field name="is_excluded_suspension" invisible="1" readonly="1" force_save="1"/>
                        <field name="member_status" readonly="1" widget="badge"
                               decoration-success="member_status == 'benefit'"
                               decoration-danger="member_status == 'non_benefit'"/>
                      </group>
                      <group>
                        <field name="member_second_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
                        <field name="mother_second_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',False)],'required':[('is_mother','=',True)]}"/>
                        <field name="member_family_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
                        <field name="mother_family_name" force_save="1"
                               attrs="{'invisible':[('is_mother','=',False)],'required':[('is_mother','=',True)]}"/>
                        <field name="benefit_ids" invisible="1"/>
                        <field name="member_phone"
                               attrs="{'invisible':[('is_mother','=',True)]}"/>
                        <field name="birth_date" required="1"/>
                        <field name="age" required="1"/>
                        <field name="age_status"/>
                        <field name="is_married"
                               attrs="{'invisible':[('is_mother','=',True)]}"/>

                        <field name="need_trans"/>
                        <field name="need_medicin"/>
                        <field name="need_mental_dis"/>

                        <field name="marriage_certificate"
                               widget="many2many_attachment_preview"
                               attrs="{'invisible':['|',('is_mother','=',True),('is_married','=',False)]}"/>
                        <field name="mother_marital_conf"
                               attrs="{'invisible':[('is_mother','=',False)]}"
                               options="{'no_create': True, 'no_create_edit': True}"
                               groups="!odex_benefit.group_benefit_manager"/>
                        <field name="mother_location" invisible="1"/>
                      </group>
                    </group>
                    <notebook>
                      <page string="الهوايات">
                        <field name="hobbies_attachment_ids" widget="one2many_list">
                          <tree editable="bottom">
                            <field name="hobbies_id" required="1"/>
                            <field name="name"/>
                            <field name="datas" widget="binary"
                                   filename="attachment_file_name"/>
                            <button name="action_preview_attachment" type="object"
                                    string="Preview Attachment"/>
                            <field name="expiration_date"/>
                            <field name="attach_status"/>
                            <field name="member_id" invisible="1"/>
                          </tree>
                        </field>
                      </page>
                      <page string="الامراض">
                        <field name="diseases_attachment_ids" widget="one2many_list">
                          <tree editable="bottom">
                            <field name="diseases_id" required="1"/>
                            <field name="name"/>
                            <field name="datas" widget="binary"
                                   filename="attachment_file_name"/>
                            <button name="action_preview_attachment" type="object"
                                    string="Preview Attachment"/>
                            <field name="expiration_date"/>
                            <field name="attach_status"/>
                            <field name="member_id" invisible="1"/>
                          </tree>
                        </field>
                      </page>
                      <page string="الاعاقات">
                        <field name="disabilities_attachment_ids" widget="one2many_list">
                          <tree editable="bottom">
                            <field name="disabilities_id" required="1"/>
                            <field name="name"/>
                            <field name="datas" widget="binary"
                                   filename="attachment_file_name"/>
                            <button name="action_preview_attachment" type="object"
                                    string="Preview Attachment"/>
                            <field name="expiration_date"/>
                            <field name="attach_status"/>
                            <field name="member_id" invisible="1"/>
                          </tree>
                        </field>
                      </page>
                      <page string="الحالة التعليمية">
                        <h3>Education Status</h3>
                        <field name="member_education_status_ids" mode="tree,form"/>
                      </page>
                      <page string="المستندات التعريفية">
                        <field name="attachment_ids" widget="one2many_list">
                          <tree editable="bottom" delete="0">
                            <field name="name" string="Attachment Name"
                                   attrs="{'readonly':[('is_default','=',True)]}"
                                   force_save="1"/>
                            <field name="attach_id" invisible="1"/>
                            <field name="datas" widget="binary"
                                   filename="attachment_file_name"/>
                            <button name="action_preview_attachment" type="object"
                                    string="Preview Attachment"/>
                            <field name="expiration_date"/>
                            <field name="attach_status"/>
                            <field name="allow_days"/>
                            <field name="benefit_id" invisible="1"/>
                            <field name="is_required" invisible="1"/>
                            <field name="is_default" invisible="1"/>
                          </tree>
                        </field>
                        <group>
                          <field name="state" invisible="1"/>
                          <field name="required_attach"
                                 attrs="{'required':[('state','not in',['draft','new'])]}"/>
                        </group>
                      </page>

                    </notebook>
                  </sheet>
                </form>
                <tree string="Family Members" delete="0" create="0" edit="0">
                  <field name="name" force_save="1"/>
                  <!--                    <field name="gender" required="1"/>-->
                  <field name="relationn"/>
                  <field name="member_location_conf"/>
                  <field name="member_status" string="Is Benefit?"/>
                  <field name="age"/>
                  <field name="benefit_id"/>
                  <field name="state"/>
                </tree>
              </field>
            </page>



          </notebook>
        </sheet>
      </form>
    </field>
  </record>

  <!-- Tree View -->
  <record id="view_pa_program_activity_registration_tree" model="ir.ui.view">
    <field name="name">pa.program.activity.registration.tree</field>
    <field name="model">pa.program.activity.registration</field>
    <field name="arch" type="xml">
      <tree string="طلبات تسجيل الأنشطة">
        <field name="name"/>
        <field name="familye_id"/>
        <field name="level_id"/>
        <field name="state"/>
        <field name="request_date"/>
      </tree>
    </field>
  </record>

  <!-- Action -->
  <record id="action_pa_program_activity_registration" model="ir.actions.act_window">
    <field name="name">تسجيل الأنشطة</field>
    <field name="res_model">pa.program.activity.registration</field>
    <field name="view_mode">tree,form</field>
  </record>


  <!-- Wizard form and action -->
  <record id="view_pa_return_reason_wizard_form" model="ir.ui.view">
    <field name="name">pa.return.reason.wizard.form</field>
    <field name="model">pa.return.reason.wizard</field>
    <field name="arch" type="xml">
      <form string="سبب الإرجاع" >
        <group>
          <field name="reason" />
        </group>
        <footer>
          <button string="تأكيد" type="object" name="action_confirm_return" class="btn-primary"/>
          <button string="إلغاء" class="btn-secondary" special="cancel"/>
        </footer>
      </form>
    </field>
  </record>




  <record id="pa_program_type_tree" model="ir.ui.view">
    <field name="name">pa.program.type.tree</field>
    <field name="model">pa.program.type</field>
    <field name="arch" type="xml">
      <tree>

        <field name="pg_type"/>

      </tree>
    </field>
  </record>

  <record id="pa_program_type_form" model="ir.ui.view">
    <field name="name">pa.program.type.form</field>
    <field name="model">pa.program.type</field>
    <field name="arch" type="xml">
      <form>
        <sheet>
          <group>

            <field name="pg_type" required="1" />
          </group>

        </sheet>
      </form>
    </field>
  </record>

  <record id="action_pa_program_type" model="ir.actions.act_window">
    <field name="name">انواع البرامج</field>
    <field name="res_model">pa.program.type</field>
    <field name="view_mode">tree,form</field>
  </record>







  <!-- Root Settings Menu -->
  <!-- Menu -->
  <menuitem id="menu_pa_root" name="Programs and Activities" web_icon="odex25_program_activity,static/description/icon.png" sequence="1" groups="odex25_program_activity.group_activity_social_specialist"/>
  <menuitem id="menu_pa_registration" parent="menu_pa_root" name="Activity Registration" sequence="20" action="action_pa_program_activity_registration"/>

  <menuitem id="menu_pa_settings" name="Settings" parent="menu_pa_root" sequence="90"/>

  <!-- Levels menu -->
  <menuitem id="menu_pa_levels" name="Program Levels" parent="menu_pa_settings" action="action_pa_program_level"/>

  <!-- Tracks menu -->
  <menuitem id="menu_pa_tracks" name="Program Tracks" parent="menu_pa_settings" action="action_pa_program_track"/>

  <!-- Programs menu -->
  <menuitem id="menu_pa_programs" name="Programs" parent="menu_pa_settings" action="action_pa_program"/>
  <menuitem id="menu_pa_program_type" name="Program Types" parent="menu_pa_settings" action="action_pa_program_type"/>

  <!-- Activities menu -->
  <menuitem id="menu_pa_activities" name="Activities" parent="menu_pa_settings" action="action_pa_program_activity"/>

  <!-- Medad menu -->
  <menuitem id="menu_pa_medad" name="Medad" parent="menu_pa_settings" action="action_pa_program_medad"/>

</odoo>
