添加功能

This commit is contained in:
zhou
2025-05-30 16:43:50 +08:00
parent a3e01f9c5c
commit fa7fa02aa0
+16 -8
View File
@@ -408,14 +408,22 @@ class SoongWorkflowNodeButton(models.Model):
@api.onchange('is_automatic', 'is_logged_by', 'is_by_company', 'is_by_group')
def _onchange_boolean_fields(self):
"""确保每次只有一个布尔字段为True"""
# 获取触发onchange的字段名
triggered_field = self._context.get('last_changed_field')
# 如果有字段被触发且设为True,则将其他字段设为False
if triggered_field and getattr(self, triggered_field):
for field in ['is_automatic', 'is_logged_by', 'is_by_company', 'is_by_group']:
if field != triggered_field:
setattr(self, field, False)
checked_count = sum([
self.is_automatic,
self.is_logged_by,
self.is_by_company,
self.is_by_group
])
if checked_count > 1:
# 弹出警告并清空所有勾选(可选)
self.is_automatic = self.is_logged_by = self.is_by_company = self.is_by_group = False
return {
'warning': {
'title': '警告',
'message': '只能勾选一个匹配方式!',
}
}
@api.onchange('users_role_id', 'users_role_group_ids')
def _onchange_role_selection(self):