Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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.  
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
gru 22
7748
2
lip 23
5640
1
maj 23
2882
2
lut 23
4174
1
lut 23
3621