콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
967 화면

    nationality = fields.Selection([

        ('pakistani', 'Pakistani'),

        ('non_pakistani', 'Non-Pakistani')

    ], string="Nationality", required=True, default='pakistani')


    show_pakistani_fields = fields.Boolean(

        string="Show Pakistani Fields",

        compute="_compute_show_fields"

    )


    show_non_pakistani_fields = fields.Boolean(

        string="Show Non-Pakistani Fields",

        compute="_compute_show_fields"

    )

    # پاکستانی فیلڈز

    cnic_or_bform = fields.Char(string="شناختی کارڈ/ب فارم نمبر")

    division_id = fields.Many2one('madrasa.divisions', string="ڈویژن")

    district_id = fields.Many2one('madrasa.districts', string="تحصیل")

    town_id = fields.Many2one('madrasa.town', string="ٹاؤن")


    # غیر پاکستانی فیلڈز

    country = fields.Many2one('madrasa.countries', string="ملک")

    passport = fields.Char(string="پاسپورٹ نمبر")

    visa_type = fields.Char(string="ویزا کی قسم")

    visa_expiry = fields.Date(string="ویزا کی میعاد")



اوڈو17 کے انٹرنل ویو میں پاکستانی اور غیر ملکی کی سلیکشن پر نیچے کی فیلڈ سب ہی نظر آرہی ہیں
نہ ہی جاوا سے مسئلہ حل ہو رہا ہے پائتھن فائل کے فنکشن سے بھی ہینڈل نہیں ہورہا اور  ویو فائل میں attr کو اوڈو قبول نہیں کررہا
کیا حل کیا جائے؟

 

아바타
취소
작성자 베스트 답변

Thanks a lot, now it is working, 


아바타
취소
베스트 답변

Hi,

To show and hide fields dynamically based on the selection of another field (e.g., nationality) in Odoo 17, you can use the invisible attribute in the XML view definition. The invisible attribute allows you to conditionally show or hide fields based on the value of another field.


Here’s how you can solve your problem step by step:

<sheet>

                <!-- Nationality Field -->

                <field name="nationality"/>

                <!-- Pakistani Fields -->

                <group invisible="nationality == 'non_pakistani'">

                    <field name="cnic_or_bform"/>

                    <field name="division_id"/>

                    <field name="district_id"/>

                    <field name="town_id"/>

                </group>

                <!-- Non-Pakistani Fields -->

                <group invisible="nationality == 'pakistan'">

                    <field name="country"/>

                    <field name="passport"/>

                    <field name="visa_type"/>

                    <field name="visa_expiry"/>

                </group>

            </sheet>


Hope it helps

아바타
취소
관련 게시물 답글 화면 활동
2
9월 25
157
2
8월 25
433
1
9월 25
419
1
9월 25
368
0
8월 25
347