From 3c8f8216958f39059a8ff425fef34a3492c606d6 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Tue, 27 Jun 2023 16:21:01 +0200 Subject: [PATCH] [IMP] runbot: unify build error wizards There are two wizards for the runbot build errors: - One to close an error with a reason - One to update the team/user or PR With this commit, the two wizards are merged into one wizard that helps to update errors in bulk. Also, a button is added in the list view that allow to save a mouse click. The `NEW` button is removed from the tree view as it should not be of any use. --- runbot/models/build_error.py | 33 +++++---- runbot/security/ir.model.access.csv | 6 +- runbot/views/build_error_views.xml | 105 ++++++++++++---------------- 3 files changed, 63 insertions(+), 81 deletions(-) diff --git a/runbot/models/build_error.py b/runbot/models/build_error.py index 063b0061..12d0595c 100644 --- a/runbot/models/build_error.py +++ b/runbot/models/build_error.py @@ -286,28 +286,16 @@ class ErrorRegex(models.Model): return False -class ErrorClosingWizard(models.TransientModel): - _name = 'runbot.error.closing.wizard' - _description = "Errors Closing Wizard" - - reason = fields.Char("Closing Reason", help="Reason that will appear in the chatter") - - def submit(self): - error_ids = self.env['runbot.build.error'].browse(self.env.context.get('active_ids')) - if error_ids: - for build_error in error_ids: - build_error.message_post(body=self.reason, subject="Closing Error") - error_ids['active'] = False - - -class ErrorReassignWizard(models.TransientModel): - _name = 'runbot.error.reassign.wizard' - _description = "Errors reassign Wizard" +class ErrorBulkWizard(models.TransientModel): + _name = 'runbot.error.bulk.wizard' + _description = "Errors Bulk Wizard" team_id = fields.Many2one('runbot.team', 'Assigned team') responsible_id = fields.Many2one('res.users', 'Assigned fixer') fixing_pr_id = fields.Many2one('runbot.branch', 'Fixing PR', domain=[('is_pr', '=', True)]) fixing_commit = fields.Char('Fixing commit') + archive = fields.Boolean('Close error (archive)', default=False) + chatter_comment = fields.Text('Chatter Comment') def submit(self): error_ids = self.env['runbot.build.error'].browse(self.env.context.get('active_ids')) @@ -320,3 +308,14 @@ class ErrorReassignWizard(models.TransientModel): error_ids['fixing_pr_id'] = self.fixing_pr_id if self.fixing_commit: error_ids['fixing_commit'] = self.fixing_commit + if self.archive: + error_ids['active'] = False + if self.chatter_comment: + for build_error in error_ids: + build_error.message_post(body=self.chatter_comment, subject="Bullk Wizard Comment") + + @api.onchange('fixing_commit', 'chatter_comment') + def _onchange_commit_comment(self): + for record in self: + if record.fixing_commit or record.chatter_comment: + record.archive = True diff --git a/runbot/security/ir.model.access.csv b/runbot/security/ir.model.access.csv index 1b0273ae..64e3d20a 100644 --- a/runbot/security/ir.model.access.csv +++ b/runbot/security/ir.model.access.csv @@ -28,10 +28,8 @@ access_runbot_build_error_tag_manager,runbot_build_error_tag_manager,runbot.mode access_runbot_team_admin,runbot_team_admin,runbot.model_runbot_team,runbot.group_runbot_admin,1,1,1,1 access_runbot_team_team_manager,runbot_team_team_manager,runbot.model_runbot_team,runbot.group_runbot_team_manager,1,1,1,1 access_runbot_team_user,runbot_team_user,runbot.model_runbot_team,group_user,1,0,0,0 -access_runbot_error_closing_wizard_admin,access_runbot_error_closing_wizard_admin,runbot.model_runbot_error_closing_wizard,runbot.group_runbot_admin,1,1,1,1 -access_runbot_error_closing_wizard_manager,access_runbot_error_closing_wizard_manager,runbot.model_runbot_error_closing_wizard,runbot.group_runbot_error_manager,1,1,1,1 -access_runbot_error_reassign_wizard_admin,access_runbot_error_reassign_wizard_admin,runbot.model_runbot_error_reassign_wizard,runbot.group_runbot_admin,1,1,1,1 -access_runbot_error_reassign_wizard_manager,access_runbot_error_reassign_wizard_manager,runbot.model_runbot_error_reassign_wizard,runbot.group_runbot_error_manager,1,1,1,1 +access_runbot_error_bulk_wizard_admin,access_runbot_error_bulk_wizard_admin,runbot.model_runbot_error_bulk_wizard,runbot.group_runbot_admin,1,1,1,1 +access_runbot_error_bulk_wizard_manager,access_runbot_error_bulk_wizard_manager,runbot.model_runbot_error_bulk_wizard,runbot.group_runbot_error_manager,1,1,1,1 access_runbot_module_admin,runbot_module_admin,runbot.model_runbot_module,runbot.group_runbot_admin,1,1,1,1 access_runbot_module_team_manager,runbot_module_team_manager,runbot.model_runbot_module,runbot.group_runbot_team_manager,1,1,1,1 diff --git a/runbot/views/build_error_views.xml b/runbot/views/build_error_views.xml index 8d17e499..45858519 100644 --- a/runbot/views/build_error_views.xml +++ b/runbot/views/build_error_views.xml @@ -102,6 +102,45 @@ + + runbot_error_bulk_wizard + runbot.error.bulk.wizard + +
+ + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + Bulk Update Wizard + runbot.error.bulk.wizard + form + new + + + list + + runbot.build.error.tree runbot.build.error @@ -110,7 +149,12 @@ decoration-danger="test_tags and (fixing_pr_alive or not fixing_pr_id)" decoration-success="fixing_pr_id and not test_tags and not fixing_pr_alive" decoration-warning="test_tags and fixing_pr_id and not fixing_pr_alive" - multi_edit="1"> + multi_edit="1" + create="False" + > +
+
@@ -217,66 +261,7 @@ tree,form
- - runbot_error_closing_wizard - runbot.error.closing.wizard - -
- - - - -
-
-
-
-
-
- - Close Errors With A Reason - runbot.error.closing.wizard - form - new - - - form,list - - - - runbot_error_reassign_wizard - runbot.error.reassign.wizard - -
- - - - - - - - - -
-
-
-
-
-
- - - Assign Team/User/PR Wizard - runbot.error.reassign.wizard - form - new - - - list -