Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
9033 Lượt xem

I have created a record rule using xml as follows:


<record id="filter_user_hotel" model="ir.rule">
            <field name="name">Filter Hotel Allowed</field>
            <field name="model_id" search="[('model','=','hotel.reservation')]" model="ir.model"/>
            <field name="groups" eval="[(4, ref('hotel.group_hotel_user'))]"/>
            <field name="domain_force">[('warehouse_id.id','=',user.warehouse_id_hotel.id)]</field>
     </record>

I created a new field in res.users "warehouse_id_hotel" so each user could see the records related to his warehouse only.

whenever I change the warehouse of the user changes don't take effect until I restart the server ,so  what is causing this behavior ?

Ảnh đại diện
Huỷ bỏ

You save my life too)))

Thanks, it works at odoo 15.

Câu trả lời hay nhất

Hi Mohammed,

you have to override create and write method of hotel reservation. and use this code inside

@api.model
def create(self, vals):
    self.clear_caches()
    return super(HotelReservation, self).create(vals)

@api.multi
def write(self, vals):
    self.clear_caches()
    return super(HotelReservation, self).write(vals)

Hope it will help.

Thanks.

Ảnh đại diện
Huỷ bỏ

You saved my life

Same problem in v12, clear_caches() helped, thanks !

Same issue faced with employee department in odoo 10. And clear_caches() worked. Thank You..

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 9 19
6798
0
thg 11 17
2949
1
thg 6 17
3857
0
thg 6 23
1874
1
thg 4 19
4857