This question has been flagged

Let's say I want to add a new, custom attribute for an existing field. In particular, I'd like to add an attribute to field `Many2one` so that I could use it when adding such fields to models:

class Model(models.Model):
    _name = 'model.name'

    my_field = fields.Many2one(
​        'comodel.name',
        my_custom_attr='something',
        string="My field"
    )

I tried to override `__init__`, `_get_attrs`, `_setup_attrs` methods, add such attribute into `__slots__` and `_slots`, use the same monkey patch used in the 'base_sparse_field' module, but nothing ever works.

How should I do this, without changing the source code in `odoo/fields.py` itself?

Avatar
Discard