Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

Hi friends,

I have a list of rules. Each rule has an is_active boolean field. This field is also in the list view. The restriction is that I want just one active rule at the moment.

I do that programmatically with @api.onchange as follows:

@api.onchange('is_active')
def_make_false_other_rule_state(self):
if self.is_active:
​rules=self.env['rule_model'].search([('id', '!=', self.env.context.get('active_id'))])
​for rule in rules:
​rule.is_active=False
But, the result doesn't update the other record's is_active field in the list view EXCEPT I reload the page

to see the result.

How can I update the field without reloading?



In Brief: The scenario is:

  • Record 2 is active,
  • Record 3 will toggle to the true state,
  • Record 2 should be toggled to false state just at the moment NOT after reloading the page.  
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 22
7778
2
thg 7 23
5652
1
thg 5 23
2898
2
thg 2 23
4193
1
thg 2 23
3635