Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
9640 Näkymät

Hi Experts,

For example, I have many2one (res.partner) relation in crm.lead, and when in the form view the user clicks "Create and Edit.." link, I wanted to redirect to a simple form (only a few fields eg name, address, etc). Is there such way to customize the view without affecting the rest. 

For instance, for some case I want to enable some flag automatically, and in some cases I want to put some other default values like is company is ticked by default, etc. 


Avatar
Hylkää
Paras vastaus

Try this

By passing form_view_ref: external id of form will load that particular form when you open with it. 
Also, to pass default values, send the value through context 
e.g. context="{'default_name': name}"

 <record model="ir.ui.view" id="crm_case_form_view_oppor_inherit">
            <field name="name">Opportunities</field>
            <field name="model">crm.lead</field>
            <field name="inherit_id" ref="crm.crm_case_form_view_oppor" />
            <field name="arch" type="xml">
                     <xpath expr="//field[@name='partner_id']" position="attributes">
                                <attribute name="context">{'default_name': partner_name, 'default_email': email_from, 'default_phone': phone,'form_view_ref': 'base.view_partner_simple_form','default_is_company': True} </attribute
                     </xpath>
             </field>
</record>

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
toukok. 25
3936
1
kesäk. 17
5134
3
heinäk. 24
2857
1
marrask. 22
4797
0
maalisk. 15
3638