تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4495 أدوات العرض

hi all,

how i can hide a page under notebook conditionally after inheriting view 

below is xml code where i tried to add the code but it is showing error when restart odoo server.

output when restarting server.

Element '<xpath expr="//page[@String='Wallets']">' cannot be located in parent view
View name: Contacts Custom FieldsError context: view: ir.ui.view(1292,) xmlid: view_res_partner_form_inherit view.model: res.partner view.parent: ir.ui.view(118,) file: /home/odoo/odoo-dev/odoo/custom_addons/tests/views/contactx.xml

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <record id="view_res_partner_form_inherit" model="ir.ui.view">
        <field name="name">Contacts Custom Fields</field>
        <field name="model">res.partner</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='category_id']" position="after">
                <field name="zone_id" string="Zone"/>
            </xpath>
            <!-- 
                added below lines to hide conditionally page Wallets
            -->
            <xpath expr="//page[@String='Wallets']" position="attributes">
                <attribute name="attrs">{'invisible': [('category_id.name','not like','%Customer%')]}</attribute>
            </xpath>
            <xpath expr="//notebook" position="inside">
                <page string="Wallets">
                    <group>
                        <field name="wallet_amount"/>
                        <field name="wallet_credits"/>
                        <field name="wallet_description"/>
                    </group>
                </page>
            </xpath>
        </field>
    </record>
</odoo>
الصورة الرمزية
إهمال
الكاتب

why not people even says that it is not possible in odoo framework...

أفضل إجابة

I got the same issue and I found not a lot of solution in the forums.

I found by myself something which worked for me in odoo v12, not tested in v14 :


<page name="input" string="Input" autofocus="autofocus" attrs="{'invisible': [('type', '!=', 'input')]}">


if it can help...

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

In the latest versions, you cannot use string attribute in the xpath, try to xpath using the name of the page and see.

Sample:

<xpath expr="//page[@name='accounting']/group" position="inside">
<group string="Accounting Documents" name="accounting_documents">
<field name="l10n_ar_special_purchase_document_type_ids" widget="many2many_tags"/>
</group>
</xpath>


Thanks

الصورة الرمزية
إهمال
الكاتب

thanks @Niyas Raphy, but not worked, i have used name="wallets" to create page and

<xpath expr="//page[@name='wallets']" position="attributes">

<attribute name="attrs">{'invisible': [('category_id.name','not like','%Customer%')]}</attribute>

</xpath>

...

please advise...

الكاتب

any help... ?

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يوليو 22
10990
1
يونيو 21
2601
2
مايو 23
2643
2
أغسطس 22
22982
1
يوليو 22
5850