Skip to Content
Menu
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
Related Posts Replies Views Activity
1
Apr 18
2456
1
Feb 23
6181
5
Sep 22
42862
3
Feb 21
16406
1
Aug 18
6745