تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2230 أدوات العرض

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
ديسمبر 22
7778
2
يوليو 23
5652
1
مايو 23
2898
2
فبراير 23
4190
1
فبراير 23
3634