[IMP] runbot: add an action to reassign team automaticaly

This commit is contained in:
Xavier-Do 2022-12-20 17:45:09 +01:00 committed by Christophe Monniez
parent af7a0751fc
commit ada69222c9
3 changed files with 24 additions and 8 deletions

View File

@ -19,4 +19,14 @@
records.clean_content()
</field>
</record>
<record model="ir.actions.server" id="action_reassign_build_errors">
<field name="name">Re-assign build errors</field>
<field name="model_id" ref="runbot.model_runbot_build_error" />
<field name="binding_model_id" ref="runbot.model_runbot_build_error" />
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
records.assign()
</field>
</record>
</odoo>

View File

@ -59,8 +59,6 @@ class BuildError(models.Model):
@api.model_create_multi
def create(self, vals_list):
cleaners = self.env['runbot.error.regex'].search([('re_type', '=', 'cleaning')])
teams = None
repos = None
for vals in vals_list:
content = vals.get('content')
cleaned_content = cleaners.r_sub('%', content)
@ -68,13 +66,20 @@ class BuildError(models.Model):
'cleaned_content': cleaned_content,
'fingerprint': self._digest(cleaned_content)
})
if 'team_id' not in vals and 'file_path' in vals:
teams = teams or self.env['runbot.team'].search(['|', ('path_glob', '!=', False), ('module_ownership_ids', '!=', False)])
repos = repos or self.env['runbot.repo'].search([])
team = teams._get_team(vals['file_path'], repos)
records = super().create(vals_list)
records.assign()
return records
def assign(self):
if not any((not record.responsible and not record.team_id and record.file_path) for record in self):
return
teams = self.env['runbot.team'].search(['|', ('path_glob', '!=', False), ('module_ownership_ids', '!=', False)])
repos = self.env['runbot.repo'].search([])
for record in self:
if not record.responsible and not record.team_id and record.file_path:
team = teams._get_team(record.file_path, repos)
if team:
vals.update({'team_id': team.id})
return super().create(vals_list)
record.team_id = team
def write(self, vals):
if 'active' in vals:

View File

@ -117,6 +117,7 @@
<field name="last_seen_date" string="Last Seen"/>
<field name="build_count"/>
<field name="responsible"/>
<field name="team_id"/>
<field name="test_tags"/>
</tree>
</field>