Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Set existing field required. What is right way?

By
vital_zaq6
on 5/20/14, 3:19 AM 1,575 views

For example i have

'property_account_position': fields.property(
            'account.fiscal.position',
            type='many2one',
            relation='account.fiscal.position',
            string="Fiscal Position",
            view_load=True,
            help="The fiscal position will determine taxes and accounts used for the partner.",
        )

1 way :

inherit model and redefine field

'property_account_position': fields.property(
            'account.fiscal.position',
            type='many2one',
            relation='account.fiscal.position',
            string="Fiscal Position",
            view_load=True,
            help="The fiscal position will determine taxes and accounts used for the partner.",

required=true,

        )

but i think it's not good redefine field just to set it required or set new caption

2 way:

set required in xml

<field name="property_account_position" position="replace">

<field name="property_account_position" required="true"/>

</field>

but in this way i need to set it all xml views

---------------

May be here is a good way just set some field option ?

something like field_name['option_name'] = new_value

0
Jaakko Komulainen
On 5/20/14, 5:14 AM

You can set it in xml by inheriting the original view and setting the required attribute of a field.

<field name="property_account_position" position="attributes">

    <attribute name="required">True</attribute>

</field>

 

if we inheriting this original view, is necessary use the <xpath>?

NIKHIL KRISHNAN
on 7/13/16, 12:06 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/20/14, 3:19 AM
Seen: 1575 times
Last updated: 3/16/15, 8:10 AM