diff --git a/runbot_merge/models/batch.py b/runbot_merge/models/batch.py index de70d67b..1d0ec945 100644 --- a/runbot_merge/models/batch.py +++ b/runbot_merge/models/batch.py @@ -52,8 +52,9 @@ class Batch(models.Model): _description = "batch of pull request" _inherit = ['mail.thread'] _parent_store = True + _order = "id desc" - name = fields.Char(compute="_compute_name") + name = fields.Char(compute="_compute_name", search="_search_name") target = fields.Many2one('runbot_merge.branch', store=True, compute='_compute_target') batch_staging_ids = fields.One2many('runbot_merge.staging.batch', 'runbot_merge_batch_id') staging_ids = fields.Many2many( @@ -183,6 +184,9 @@ class Batch(models.Model): for batch in self: batch.name = batch.prs[:1].label or batch.all_prs[:1].label + def _search_name(self, operator, value): + return [('all_prs.label', operator, value)] + @api.depends("all_prs.target") def _compute_target(self): for batch in self: diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 4623cc52..7e8e312a 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -284,7 +284,13 @@ class Branch(models.Model): self._table, ['name', 'project_id']) return res - @api.depends('active') + def name_get(self): + return [ + (id, f"{b.project_id.name}:{name}") + for b, (id, name) in zip(self, super().name_get()) + ] + + @api.depends('active', 'project_id.name') def _compute_display_name(self): super()._compute_display_name() for b in self.filtered(lambda b: not b.active): diff --git a/runbot_merge/tests/test_basic.py b/runbot_merge/tests/test_basic.py index 3b982984..c4be7fc5 100644 --- a/runbot_merge/tests/test_basic.py +++ b/runbot_merge/tests/test_basic.py @@ -770,7 +770,7 @@ def test_ff_failure_batch(env, repo, users, config): } class TestPREdition: - def test_edit(self, env, repo, config): + def test_edit(self, env, project, repo, config): """ Editing PR: * title (-> message) @@ -814,7 +814,7 @@ class TestPREdition: assert pr.target == branch_1 assert not pr.staging_id, "updated the base of a staged PR should have unstaged it" assert st.state == 'cancelled', f"expected cancellation, got {st.state}" - assert st.reason == f"{pr.display_name} target (base) branch was changed from 'master' to '1.0'" + assert st.reason == f"{pr.display_name} target (base) branch was changed from '{project.name}:master' to '{project.name}:1.0'" with repo: prx.base = '2.0' assert not pr.exists() diff --git a/runbot_merge/views/batch.xml b/runbot_merge/views/batch.xml index 7d87d94f..ed3f04ba 100644 --- a/runbot_merge/views/batch.xml +++ b/runbot_merge/views/batch.xml @@ -1,4 +1,40 @@ + + Batches + runbot_merge.batch + tree,form + + + + batches search + runbot_merge.batch + + + + + + + + + + + + + + batches list + runbot_merge.batch + + + + + + + + + + + + Batch form runbot_merge.batch diff --git a/runbot_merge/views/mergebot.xml b/runbot_merge/views/mergebot.xml index 3de9738e..eecec149 100644 --- a/runbot_merge/views/mergebot.xml +++ b/runbot_merge/views/mergebot.xml @@ -88,9 +88,9 @@ name="open" string="Open" domain="[('state', 'not in', ['merged', 'closed'])]" /> + - @@ -416,17 +416,16 @@ - - + + action="runbot_merge_action_prs" sequence="5"/> + action="runbot_merge_action_stagings" sequence="8"/> + + +