Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
4941 Tampilan

Hello. I'm trying to add a new field here: https://prnt.sc/syh1w2

It's when you're creating a new contact and add a contact/address to it, a new window pops up which is called "child_ids" as far as I'm aware, that's where I want 'useri_id' field.


I believe that whole child_ids window is supposted to be in "Edit Form: View", this code: 



<notebook colspan="4">
                        <page string="Contacts &amp; Addresses" autofocus="autofocus">
                            <field name="child_ids" mode="kanban" context="{'default_parent_id': active_id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_lang': lang, 'default_user_id': user_id, 'default_type': 'other'}">
                                <kanban>
                                    <field name="id"/>
                                   ...
                                   ...
                                   ...
                                    </templates>
                                </kanban>
                                <form string="Contact / Address">

However, I can't seem to add anything to it that would work, anyone can give me a hand here? Thanks.
Avatar
Buang
Jawaban Terbai

Hi Spaudos:

You need to add the field inside the <form string="Contact / Address"> portion of the XML at the point indicated below.


If you are familiar with customizing views using view inheritance, you can use the following xpath expression to add the field to the form.

    <xpath expr="//field[@name='child_ids']/form/sheet/group/group[2]/field[@name='mobile']" position="after">
        <field name="your_field_name"/>
    </xpath>



Avatar
Buang
Jawaban Terbai


Inherit "base.view_partner_form" view an xpath apply "child_ids" field.
Sample code from core "sale_crm" module.

<record id="res_partner_address_type" model="ir.ui.view">
<field name="name">res.partner.form.inherit.base</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//group/group/field[@name='type']" position="attributes">
<attribute name="groups">sale.group_delivery_invoice_address</attribute>
</xpath>
<xpath expr="//field[@name='child_ids']//field[@name='type']" position="attributes">
<attribute name="groups">sale.group_delivery_invoice_address</attribute>
</xpath>
</field>
</record>
Avatar
Buang