I have this ir.rule. I want a group only see their own records on account.voucher.
<record id="ir_rule_account_voucher_restrictions" model="ir.rule">
<field name="name">Voucher Restrictions</field>
<field name="model_id" ref='model_account_voucher'/>
<field name="groups" eval="[(4, ref('group_users_restrictions'))]"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
</record>
account.voucher didn't have a user_id field, so I have to create it now. The only way I have to recover the older user_id is with message_follower_ids field, so I have this new field
class AccountVoucher(models.Model):
_inherit = 'account.voucher'
user_id = fields.Char(string='Salesperson', related="message_follower_ids.name", store=True)
And it's working OK with the new records I'm creating, but I also need the old records to make the ir.rule work
I think the problem is the same with computed fields, they don't get stored on db. How should I add to accomplish my task?

message_follower_idsis aMany2manyfield. Relatinguser_idasCharfield might be inconsistent.I'm not sure comparing
namewithuser.idwould work. Consider storingidfield instead.Also you are storing
.namefield so this would return an error in case there should be multiple followers.To recompute fields in Odoo v8 you can use server actions:
You can anyway avoid creating a related field because
message_follower_idsis already present in your model (since you are inheritingmail_thread)So your domain can be semplified:
<field name="domain_force">[('message_follower_ids', 'in', [user.id])]</field>Note i'm using
inoperator sincemessage_follower_idsis parsed as a list ofids, so correct operation is to check ifmessage_follower_idscontains your current logged inuser.idIn my advice, best practice would be to have a real relation (not based on
message_follower_ids) inaccount.vouchermodel.Then migrate (manually or via script) previous records.
If you're going to use odoo shell, don't forget to: