Odoo lets you define attributes of a Field in-place during declaration. Though optional attributes can be defined in Views, it can not possibly be the best place since the attributes defined in one view can not be reused in another, unless you want to change the attributes value specific to a particular view.

Attributes of fields defined in python can be overridden by redefining them in respective view’s xml.

class goal_task(models.Model):

    _name = "goal.task"
    # Lets give the optional attribute `required` a value
    review_members = fields.Many2one(comodel_name='res.users', required=True)
<record id="goal_task_form_view" model="ir.ui.view">
   <field name="name">goal.task.form</field>
   <field name="model">goal.task</field>
   <field name="arch" type="xml">
      <form string="Tasks">
         <!-- Here an extra attribute `string` is defined and the value of attribute `required` is redefined  -->
         <field name="review_members" string="Review Panel Members" required="0">

In the case of inherited fields (fields inherited via extending a model class) if an attribute value needs to be redefined globally irrespective of a particular view then redefining it in view is not the right way to do it, since it will involve duplicating the attribute value in every possible view there were and will be in future.

The existing attributes of an inherited field can be overridden and extra attributes can be added via Incremental definition, just like the normal field definition but instead of passing all the required attributes as parameter you pass only the attributes you wish to change/add.

# Extending Model Class `goal.task`
class work_task(models.Model):

    _inherit = "goal.task"
    # change the value of existing attribute `required`
    # add an extra attribute 'string'
    review_members = fields.One2many(required=False, string="Review Panel Members")


Machines and Visions