<odoo>
    <data>
        <record id="services_settings_form" model="ir.ui.view">
            <field name="name">services.settings.form</field>
            <field name="model">services.settings</field>
            <field name="arch" type="xml">
                <form string="Services Settings">
                    <sheet>
                        <div class="oe_title">
                            <h1>
                                <field name="service_name" placeholder="Service Name" required="1"/>
                            </h1>
                        </div>
                        <group>
                            <group>
                                <field name="service_number"/>
                                <field name="service_type"/>
                                <field name="benefit_type" required="1"/>
                                <field name="allow_non_beneficiary" widget="boolean_toggle"/>
                                <field name="service_producer_id"
                                       attrs="{'invisible':['|',('service_type','=','main_service'),('is_service_producer','=',False)]}"/>
                            </group>
                            <group>
                                <field name="service_category"/>
                                <field name="parent_service"
                                       attrs="{'invisible':[('service_type','=','main_service')]}"/>
                                <field name="benefit_category_ids" widget="many2many_tags" required="1"/>
                                <field name="allowed_country_ids" widget="many2many_tags"/>
                                <field name="currency_id" groups="base.group_multi_currency"/>
                                <field name="company_id" groups="base.group_multi_company"/>
                            </group>
                        </group>
                        <notebook>
                            <page string="Settings" attrs="{'invisible':[('service_type','=','main_service')]}">
                                <group>
                                    <group>
                                        <field name="max_limit_type"/>
                                        <field name="max_amount"
                                               attrs="{'invisible': [('max_limit_type', '!=', 'fixed')]}"/>
                                        <field name="raise_amount_for_orphan"
                                               attrs="{'invisible':['|',('service_type','!=','rent'),('benefit_type','!=','family')]}"/>
                                        <field name="min_count_member"
                                               attrs="{'invisible':[('service_type','!=','buy_car')]}"/>
                                        <field name="buy_home_max_total_amount"
                                               attrs="{'invisible':['|',('service_type','!=','buy_home'),('max_limit_type', '!=', 'amount_person')]}"/>
                                        <field name="home_age"
                                               attrs="{'invisible':['|',('service_type','!=','buy_home'),('max_limit_type', '!=', 'amount_person')]}"/>
                                        <field name="member_max_payroll"
                                               attrs="{'invisible':[('service_type','!=','marriage')]}"/>
                                        <field name="fatherless_member_amount"
                                               attrs="{'invisible':[('service_type','!=','marriage')]}"/>
                                        <field name="orphan_member_amount"
                                               attrs="{'invisible':[('service_type','!=','marriage')]}"/>
                                        <field name="max_limit_period"/>
                                        <field name="allowed_period"
                                               attrs="{'invisible': [('max_limit_period', 'not in', ['year_from_request', 'calendar_year'])]}"/>
                                        <field name="max_months_limit"
                                               attrs="{'invisible': [('max_limit_period', '!=', 'month')]}"/>
                                        <field name="currency_id" invisible="1"/>
                                    </group>
                                    <group>
                                        <field name="max_age"/>
                                        <field name="in_kind" widget="boolean_toggle"/>
                                    </group>
                                </group>
                                <group>
                                    <group>
                                        <field name="allowed_recurrence"/>
                                        <label for="recurrence_interval"
                                               attrs="{'invisible': [('allowed_recurrence', '!=', 'periodic')]}"/>
                                        <div class="o_row"
                                             attrs="{'invisible': [('allowed_recurrence', '!=', 'periodic')]}">
                                            <field name="recurrence_interval" class="oe_inline" nolabel="1"/>
                                            <field name="recurrence_period" class="oe_inline" nolabel="1"/>
                                        </div>
                                    </group>
                                    <group>
                                        <field name="requires_visit" widget="boolean_toggle"/>
                                    </group>
                                </group>
                                <group>
                                    <group>
                                        <field name="is_main_service" invisible="1" widget="boolean_toggle"/>
                                        <field name="is_service_producer" widget="boolean_toggle"
                                               attrs="{'invisible':[('is_main_service','=',True)]}"/>
                                        <field name="is_this_service_for_student" widget="boolean_toggle"
                                               attrs="{'invisible':[('is_main_service','=',True)]}"/>
                                        <field name="is_this_service_for_student" invisible="1"
                                               widget="boolean_toggle"/>
                                    </group>
                                    <group>
                                        <field name="required_attach" widget="boolean_toggle"
                                               attrs="{'invisible':[('service_type','=','main_service')]}"/>
                                        <field name="is_seasonal_service" widget="boolean_toggle"/>
                                        <field name="show_in_portal" widget="boolean_toggle"/>
                                    </group>
                                </group>
                            </page>
                            <page string="Accounts" attrs="{'invisible':[('service_type','=','main_service')]}">
                                <group>
                                    <group>
                                        <field name="account_id"
                                               attrs="{'invisible':[('service_type', 'in', ['electrical_devices'])]}"/>
                                        <field name="payment_method"/>
                                    </group>
                                    <group>
                                        <field name="accountant_id"/>
                                    </group>
                                </group>
                            </page>
                            <page string="Eligibility Criteria"
                                  attrs="{'invisible':[('service_type','=','main_service')]}">
                                <group col="1" colspan="2">
                                    <field name="service_conditions"
                                           nolabel="1"
                                           placeholder="Enter eligibility conditions..."
                                    />
                                </group>
                            </page>
                            <page string="Services Attachments"
                                  attrs="{'invisible':[('required_attach','=',False)]}">
                                <field name="attachment_lines" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="name"/>
                                        <field name="notes"/>
                                        <field name="state"/>
                                        <field name="service_type" invisible="1"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Family Rent Service Settings"
                                  attrs="{'invisible':['|',('service_type','!=','rent'),('benefit_type','!=','family')]}">
                                <field name="rent_lines" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="benefit_category_id"/>
                                        <field name="benefit_count"/>
                                        <field name="estimated_rent_branches"/>
                                        <field name="estimated_rent_governorate"/>
                                        <field name="discount_rate_shared_housing"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Amounts by Categories"
                                  attrs="{'invisible':[('max_limit_type', '!=', 'category')]}">
                                <field name="category_amount_lines" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="benefit_category_id"/>
                                        <field name="max_amount"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Alternative Housing Settings"
                                  attrs="{'invisible':[('service_type','!=','alternative_housing')]}">
                                <group>
                                    <field name="rent_amount_for_alternative_housing"/>
                                    <field name="rent_period"/>
                                </group>
                            </page>
                            <page string="Home Maintenance Service Settings"
                                  attrs="{'invisible':[('service_type','!=','home_maintenance')]}">
                                <field name="home_maintenance_lines" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="maintenance_name"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Electrical Devices Settings"
                                  attrs="{'invisible':[('service_type','!=','electrical_devices')]}">
                                <field name="electrical_devices_lines" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="min_count_member"/>
                                        <field name="max_count_member"/>
                                        <field name="device_name"/>
                                        <field name="product_ids" widget="many2many_tags"/>
                                        <field name="price_unit"/>
                                        <field name="allowed_quantity"/>
                                        <field name="account_id"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Home furnishing Settings"
                                  attrs="{'invisible':[('service_type','!=','home_furnishing')]}">
                                <group>
                                    <field name="max_furnishing_amount_if_exception"/>
                                </group>
                                <field name="home_furnishing_lines" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="name"/>
                                        <field name="max_furnishing_amount"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Amounts by Categories and Number of Members"
                                  attrs="{'invisible':[('max_limit_type','!=','category_person')]}">
                                <field name="bill_lines" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="benefit_category_id"/>
                                        <field name="min_count_member"/>
                                        <field name="max_count_member"/>
                                        <field name="max_amount_for_bill"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Amounts by Number of Persons"
                                  attrs="{'invisible':[('max_limit_type', '!=', 'amount_person')]}">
                                <field name="limit_person_line_ids" widget="one2many_list">
                                    <tree editable="bottom">
                                        <field name="min_count_member"/>
                                        <field name="max_count_member"/>
                                        <field name="amount"/>
                                    </tree>
                                </field>
                            </page>
                            <page string="Service Approvals">
                                <group>
                                    <group>
                                        <field name="needs_services_head_approval" widget="boolean_toggle"/>
                                        <field name="needs_legal_approval" widget="boolean_toggle"/>
                                        <field name="needs_project_management_approval" widget="boolean_toggle"/>
                                        <field name="needs_beneficiary_manager_approval" widget="boolean_toggle"
                                               attrs="{'invisible':[('is_main_service','=',True)]}"/>
                                    </group>
                                </group>
                            </page>
                            <page string="Related Information">
                                <group>
                                    <group>
                                        <field name="family_related_fields" widget="many2many_tags"/>
                                    </group>
                                    <group>
                                        <field name="member_related_fields" widget="many2many_tags"
                                               attrs="{'invisible': [('benefit_type', '!=', 'member')]}"/>
                                    </group>
                                </group>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>
        <record id="services_settings_tree" model="ir.ui.view">
            <field name="name">services.settings.tree</field>
            <field name="model">services.settings</field>
            <field name="arch" type="xml">
                <tree string="Services Settings" decoration-info="service_type=='main_service'">
                    <field name="service_number"/>
                    <field name="service_type" invisible="1"/>
                    <field name="service_name"/>
                    <field name="service_category"/>
                    <field name="parent_service"/>
                    <field name="show_in_portal" widget="boolean_toggle"/>
                </tree>
            </field>
        </record>
    </data>
</odoo>
