Skip to content

Commit 9deba33

Browse files
committed
[IMP] runbot: add kanban view and stages to build error page
Introduce a kanban view to the runbot build error records. Kanban cards show the most valuable field with relevant icons. The concept of "state" was also introduced for the build error model. Currently there is 4 states: 1. New: default state for any new error build 2. Solved: when the issue should be solved 3. Ignored: build error currently ignored (test-tags) 4. Done: When the issue stop happening Certain states change automatically based as handled in a cron Generally, any not-ignored on-going task end up in done after some period of time if it is not seen for some time ( see full details in function `_update_stage`). The other state are expected to be used by the user. For instance after fixing an underteministic error the user can change the state from new -> solved so that it is moved to done if the build error is not seen for 7 days (instead of 15 if it was in new).
1 parent 3cf9dd6 commit 9deba33

File tree

6 files changed

+122
-3
lines changed

6 files changed

+122
-3
lines changed

runbot/__manifest__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'author': "Odoo SA",
77
'website': "http://runbot.odoo.com",
88
'category': 'Website',
9-
'version': '5.9',
9+
'version': '5.10',
1010
'application': True,
1111
'depends': ['base', 'base_automation', 'website'],
1212
'data': [
@@ -18,6 +18,7 @@
1818
'data/runbot_data.xml',
1919
'data/runbot_error_regex_data.xml',
2020
'data/website_data.xml',
21+
'data/ir_cron_data.xml',
2122

2223
'security/runbot_security.xml',
2324
'security/ir.model.access.csv',

runbot/data/ir_cron_data.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<odoo>
2+
<record id="runbot_update_build_errors_stage" model="ir.cron">
3+
<field name="name">Runbot: Update Build Errors Stage</field>
4+
<field name="model_id" ref="model_runbot_build_error"/>
5+
<field name="state">code</field>
6+
<field name="code">model._update_stage()</field>
7+
<field name="interval_number">1</field>
8+
<field name="interval_type">days</field>
9+
</record>
10+
</odoo>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
from odoo import api, SUPERUSER_ID
3+
4+
5+
def migrate(cr, version):
6+
env = api.Environment(cr, SUPERUSER_ID, {})
7+
8+
# Archived build errors are set are considered Done
9+
env['runbot.build.error'].search([['active', "=", False]]).write({'state': 'done'})
10+
# Build errors with test_tags are set to Ignored
11+
env['runbot.build.error'].search([['test_tags', '!=', False]]).write({'state': 'ignored'})

runbot/models/build_error.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ class BuildError(models.Model):
105105
error_count = fields.Integer("Error count", store=True, compute='_compute_count')
106106
previous_error_id = fields.Many2one('runbot.build.error', string="Already seen error")
107107

108+
state = fields.Selection([
109+
('new', 'New/Unsolved'),
110+
('solved', 'Solved'),
111+
('ignored', 'Ignored'),
112+
('done', 'Done'),
113+
], default='new', tracking=True, group_expand=True,
114+
help="New: Error is new and not yet solved. Build error not happening for a long time in this state will automatically move to Done\n"
115+
"Solved: Error should be solved. Build error not happening for a small time in this state will automatically move to Done\n"
116+
"Ignored: Error is ignored. No change of state will apply\n"
117+
"Done: Error is done. No change of state will apply except if issue re-appear, then it will go back to New"
118+
)
108119
responsible = fields.Many2one('res.users', 'Assigned fixer', tracking=True)
109120
customer = fields.Many2one('res.users', 'Customer', tracking=True)
110121
team_id = fields.Many2one('runbot.team', 'Assigned team', tracking=True)
@@ -586,6 +597,37 @@ def action_link_errors(self):
586597
base_error = self_sorted[0]
587598
base_error._merge(self_sorted - base_error)
588599

600+
def _update_state(self, nbr_day_solved_to_done=7, nbr_day_new_to_done=15):
601+
"""Called automatically by scheduled action to update the state of the error if necessary"""
602+
now = fields.Datetime.now()
603+
604+
# Done errors that did happen again recently are moved back to new
605+
self.search([
606+
('state', '=', 'done'),
607+
('last_seen_date', '>=', now - relativedelta(days=nbr_day_new_to_done)),
608+
]).write({'state': 'new'})
609+
610+
# New error that did not appear after a long time are marked as done
611+
# Solved error that did not appear after a short time are marked as done
612+
self.search([
613+
'|',
614+
'&',
615+
('state', '=', 'new'),
616+
('last_seen_date', '<', now - relativedelta(days=nbr_day_new_to_done)),
617+
'&',
618+
('state', '=', 'solved'),
619+
('last_seen_date', '<', now - relativedelta(days=nbr_day_solved_to_done)),
620+
]).write({'state': 'done'})
621+
622+
@api.model
623+
def _read_group_fill_results(self, domain, groupby, annoted_aggregates, read_group_result, read_group_order=None):
624+
# Override to fold ignored and done state
625+
read_groups = super()._read_group_fill_results(domain, groupby, annoted_aggregates, read_group_result, read_group_order)
626+
for read_group in read_groups:
627+
if read_group.get('state', False) in ('ignored', 'done'):
628+
read_group['__fold'] = True
629+
return read_groups
630+
589631

590632
class BuildErrorContent(models.Model):
591633

runbot/security/ir.model.access.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,3 @@ access_runbot_build_stat_regex_wizard,access_runbot_build_stat_regex_wizard,mode
151151

152152
access_runbot_host_message,access_runbot_host_message,runbot.model_runbot_host_message,runbot.group_runbot_admin,1,0,0,0
153153

154-

runbot/views/build_error_views.xml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<field name="model">runbot.build.error</field>
66
<field name="arch" type="xml">
77
<form>
8+
<header>
9+
<field name="state" widget="statusbar" options="{'clickable': '1'}"/>
10+
</header>
811
<sheet>
912
<div name="button_box">
1013
<button class="oe_stat_button" type="object" icon="fa-exclamation-circle" name="action_get_build_link_record">
@@ -329,6 +332,59 @@
329332
<field name="binding_view_types">list</field>
330333
</record>
331334

335+
<record id="build_error_view_kanban" model="ir.ui.view">
336+
<field name="name">runbot.build.error.kanban</field>
337+
<field name="model">runbot.build.error</field>
338+
<field name="arch" type="xml">
339+
<kanban default_group_by="state" quick_create="false" default_order="last_seen_date desc">
340+
<templates>
341+
<t t-name="card">
342+
<widget name="web_ribbon" title="Test-tags" bg_color="bg-danger" invisible="not test_tags"/>
343+
<field name="name" class="fw-bold fs-5"/>
344+
<group>
345+
<div style="display: flex; align-items: center;">
346+
<i class="fa fa-clock-o me-2" title="Date interval from first seen to last seen"/>
347+
<field name="first_seen_date" widget="remaining_days"/>
348+
<i class="fa fa-long-arrow-right mx-2 oe_read_only" title="to"/>
349+
<field name="last_seen_date" widget="remaining_days"/>
350+
</div>
351+
352+
<div class="d-flex align-items-center gap-1">
353+
<i class="fa fa-repeat" title="Number of occurence"/>
354+
<field name="error_count"/>
355+
</div>
356+
357+
<div class="d-flex align-items-center gap-1">
358+
<i class="fa fa-code-fork" title="Concerned Odoo versions"/>
359+
<field name="version_ids" widget="many2many_tags"/>
360+
</div>
361+
<div class="d-flex align-items-center gap-1">
362+
<i class="fa fa-bullseye" title="Triggers"/>
363+
<field name="trigger_ids" widget="many2many_tags"/>
364+
</div>
365+
</group>
366+
367+
<footer>
368+
<div class="d-flex align-items-center gap-1">
369+
<field name="activity_ids" widget="kanban_activity"/>
370+
</div>
371+
<div class="d-flex align-items-center gap-1 ms-auto">
372+
<i class="fa fa-random text-danger" title="inconsistant" invisible="not random"/>
373+
<i class="fa fa-users" title="Responsible team"/>
374+
<field name="team_id"/> <i t-if="!record.team_id.raw_value">no team</i>
375+
<i class="fa fa-address-card" title="Investigator"/>
376+
<field name="customer" widget="many2one_avatar_user"/>
377+
<i class="fa fa-wrench" title="Solver"/>
378+
<field name="responsible" widget="many2one_avatar_user"/>
379+
<field name="fixing_pr_url" widget="url" text="PR" invisible="not fixing_pr_url"/>
380+
</div>
381+
</footer>
382+
</t>
383+
</templates>
384+
</kanban>
385+
</field>
386+
</record>
387+
332388
<record id="build_error_view_tree" model="ir.ui.view">
333389
<field name="name">runbot.build.error.list</field>
334390
<field name="model">runbot.build.error</field>
@@ -478,7 +534,7 @@
478534
<field name="name">Errors</field>
479535
<field name="res_model">runbot.build.error</field>
480536
<field name="path">error</field>
481-
<field name="view_mode">list,form</field>
537+
<field name="view_mode">kanban,list,form</field>
482538
<field name="context">{'search_default_not_fixed_errors': True, 'active_test': False}</field>
483539
</record>
484540

0 commit comments

Comments
 (0)