How to restrict writes on a functional o2m field

In I created the following field:

sales = fields.Function(fields.One2Many(‘’), ‘get_sales’)

The user has rights for creating new sales but as the field has no setter I expected that sao would not allow the user to change sales. But this is not what happens.

The user cannot create new records or delete them using the o2m field but she can modify some of the fields of the sale and then try to save. Which crashes with an error because no setter field has been defined for the sales field.

Any ideas on how to properly manage that, provided I would prefer not to create a setter method?

For me you have to implement a setter because the user has the right to modify the model but you must also explicitly set the Function as read only if you can not manage to add/remove.
We should probably add a test that Function field of One2Many must have a setter.

Otherwise you have to use a Many2Many field.


Thanks for the feedback!