I have a model 'shop' inherited from 'stock.location'. It keeps necessary data for shops. It has a field 'shop_manager_id' which is many2one to 'res.users'. Now this shop managers will be users as you can see. I want a logged shop manager(user) should see only his shop in tree/form view. Admin will see every shop. I tried following code in xml but admin can not see any shop as he is not shop manager of any shop! Do you have any idea how to do it so that users can see only shops where they are managers and administrator can see all the shops. Thanks in advance.
<record id="inherited_shop_action" model="ir.actions.act_window">
<field name="name">Shops</field>
<field name="res_model">stock.location</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="inherited_stock_location_view_form_inherit_store" />
<field name="context">{'default_is_shop':
True,'search_default_state':
'done','default_usage':
'internal'}
</field>
<field name="domain">[('is_shop','=',True), ('shop_manager_id', '=', uid)]</field>
<field name="search_view_id"
ref="inherited_stock_location_view_search_inherit_store" />
<field name="help" type="html">
<p class="oe_view_nocontent_create">Create Shops
</p>
</field>
</record>
Hope this will helps:
1- http://learnopenerp.blogspot.com/2020/01/odoo-server-action.html
2- https://learnopenerp.blogspot.com/2017/11/show-records-on-treeview-that-are-related-to-active-user-odoo.html