[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.
This commit is contained in:
Christophe Monniez 2023-06-27 16:21:01 +02:00 committed by xdo
parent 1cc73a606d
commit 3c8f821695
3 changed files with 63 additions and 81 deletions

View File

@ -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

View File

@ -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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
28 access_runbot_error_reassign_wizard_admin access_runbot_module_admin access_runbot_error_reassign_wizard_admin runbot_module_admin runbot.model_runbot_error_reassign_wizard runbot.model_runbot_module runbot.group_runbot_admin 1 1 1 1
29 access_runbot_error_reassign_wizard_manager access_runbot_module_team_manager access_runbot_error_reassign_wizard_manager runbot_module_team_manager runbot.model_runbot_error_reassign_wizard runbot.model_runbot_module runbot.group_runbot_error_manager runbot.group_runbot_team_manager 1 1 1 1
30 access_runbot_module_admin access_runbot_module_user runbot_module_admin runbot_module_user runbot.model_runbot_module runbot.group_runbot_admin group_user 1 1 0 1 0 1 0
31 access_runbot_module_team_manager access_runbot_module_ownership_admin runbot_module_team_manager runbot_module_ownership_admin runbot.model_runbot_module runbot.model_runbot_module_ownership runbot.group_runbot_team_manager runbot.group_runbot_admin 1 1 1 1
32 access_runbot_module_user access_runbot_module_ownership__team_manager runbot_module_user runbot_module_ownership_team_manager runbot.model_runbot_module runbot.model_runbot_module_ownership group_user runbot.group_runbot_team_manager 1 0 1 0 1 0 1
access_runbot_module_ownership_admin runbot_module_ownership_admin runbot.model_runbot_module_ownership runbot.group_runbot_admin 1 1 1 1
access_runbot_module_ownership__team_manager runbot_module_ownership_team_manager runbot.model_runbot_module_ownership runbot.group_runbot_team_manager 1 1 1 1
33 access_runbot_module_ownership_user runbot_module_ownership_user runbot.model_runbot_module_ownership group_user 1 0 0 0
34 access_runbot_dashboard_admin runbot_dashboard_admin runbot.model_runbot_dashboard runbot.group_runbot_admin 1 1 1 1
35 access_runbot_dashboard_user runbot_dashboard_user runbot.model_runbot_dashboard group_user 1 0 0 0

View File

@ -102,6 +102,45 @@
</field>
</record>
<record model="ir.ui.view" id="runbot_error_bulk_wizard_form">
<field name="name">runbot_error_bulk_wizard</field>
<field name="model">runbot.error.bulk.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group name="team_group">
<field name="team_id"/>
<field name="responsible_id"/>
</group>
<group name="Fix">
<field name="fixing_pr_id"/>
<field name="fixing_commit"/>
</group>
<group>
<field name="chatter_comment"/>
</group>
<group name="Close">
<field name="archive"/>
</group>
<footer>
<button string="Submit" name="submit" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</sheet>
</form>
</field>
</record>
<record id="runbot_open_bulk_wizard" model="ir.actions.act_window">
<field name="name">Bulk Update Wizard</field>
<field name="res_model">runbot.error.bulk.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="runbot_error_bulk_wizard_form"/>
<field name="binding_model_id" ref="runbot.model_runbot_build_error"/>
<field name="binding_view_types">list</field>
</record>
<record id="build_error_view_tree" model="ir.ui.view">
<field name="name">runbot.build.error.tree</field>
<field name="model">runbot.build.error</field>
@ -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"
>
<header>
<button name="%(runbot.runbot_open_bulk_wizard)d" string="Bulk Update" type="action" groups="runbot.group_runbot_admin,runbot.group_runbot_error_manager"/>
</header>
<field name="module_name" readonly="1"/>
<field name="summary" readonly="1"/>
<field name="random" string="Random"/>
@ -217,66 +261,7 @@
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="runbot_error_closing_wizard_form">
<field name="name">runbot_error_closing_wizard</field>
<field name="model">runbot.error.closing.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group name="closing_group">
<field name="reason"/>
</group>
<footer>
<button string="Submit" name="submit" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</sheet>
</form>
</field>
</record>
<record id="runbot_open_error_closing_wizard" model="ir.actions.act_window">
<field name="name">Close Errors With A Reason</field>
<field name="res_model">runbot.error.closing.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="runbot_error_closing_wizard_form"/>
<field name="binding_model_id" ref="runbot.model_runbot_build_error"/>
<field name="binding_view_types">form,list</field>
</record>
<record model="ir.ui.view" id="runbot_error_reassign_wizard_form">
<field name="name">runbot_error_reassign_wizard</field>
<field name="model">runbot.error.reassign.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group name="team_group">
<field name="team_id"/>
<field name="responsible_id"/>
</group>
<group name="Fix">
<field name="fixing_pr_id"/>
<field name="fixing_commit"/>
</group>
<footer>
<button string="Submit" name="submit" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</sheet>
</form>
</field>
</record>
<record id="runbot_open_reassign_wizard" model="ir.actions.act_window">
<field name="name">Assign Team/User/PR Wizard</field>
<field name="res_model">runbot.error.reassign.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="runbot_error_reassign_wizard_form"/>
<field name="binding_model_id" ref="runbot.model_runbot_build_error"/>
<field name="binding_view_types">list</field>
</record>
</data>
</odoo>