コンテンツへスキップ
メニュー
この質問にフラグが付けられました

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.  
アバター
破棄
関連投稿 返信 ビュー 活動
1
12月 22
7800
2
7月 23
5679
1
5月 23
2904
2
2月 23
4215
1
2月 23
3645