Odoo Help

1

Set existing field required. What is right way?

By
vital_zaq6
on 5/20/14, 3:19 AM 2,359 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
Jérôme Thériault
On 4/3/17, 4:01 PM
  • Go into the view in developper mode.

  • In the debug menu, select edit view

  • In the dialog, select "Inherited views" and click Add new. This creates a new inherited view in the database, so you don't need to develope a whole module.

  • Give it a name you'll recognize. Could be anything but for uniformity, I suggest you follow what other views do.

  • Set the inheritance mode to Extension View

  • In the architecture field, enter what you'd normally enter in a XML view file. See below for an example:

<data>

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

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

</field>

</data>

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

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/20/14, 3:19 AM
Seen: 2359 times
Last updated: 4/3/17, 4:01 PM