コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
947 ビュー

    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
8月 25
392
1
9月 25
397
1
9月 25
334
0
8月 25
331
1
8月 25
453