Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd

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.  
Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
dec. 22
7771
2
jul. 23
5646
1
mei 23
2898
2
feb. 23
4189
1
feb. 23
3627