From 92e8eecbb54a33329da991501b457cb11d66bbb9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 21 Jun 2024 10:42:37 +0200 Subject: [PATCH] [FIX] runbot_merge: ability to create PRs via the UI This is useful to repro issues. 60c4b5141d55ebb73b5f8e4b1f1738c80369722e added `inverse=readonly` hooks to various newly computed fields to ensure they can not be *written* to, either overwriting the content (stored) or silently being dropped (non-stored). However because they're `inverse` hooks this had the effect of making them writeable from the backend UI since the ORM uses `inverse` as a signal to make the field writeable. This then caused the web client to send stuff for those fields, which are not necessarily even visible in the form, leading to write errors when trying to save a PR creation. By marking the fields as `readonly` explicitly we make sure that doesn't happen, and we can create PRs from the backend UI (kinda, I think the label is still an issue). --- runbot_merge/models/pull_requests.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index f657011e..5685721e 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -335,6 +335,7 @@ class PullRequests(models.Model): merge_date = fields.Datetime( related='batch_id.merge_date', inverse=readonly, + readonly=True, tracking=True, store=True, ) @@ -383,7 +384,7 @@ class PullRequests(models.Model): reviewed_by = fields.Many2one('res.partner', index=True, tracking=True) delegates = fields.Many2many('res.partner', help="Delegate reviewers, not intrinsically reviewers but can review this PR") - priority = fields.Selection(related="batch_id.priority", inverse=readonly) + priority = fields.Selection(related="batch_id.priority", inverse=readonly, readonly=True) overrides = fields.Char(required=True, default='{}', tracking=True) statuses = fields.Text(help="Copy of the statuses from the HEAD commit, as a Python literal", default="{}") @@ -396,12 +397,12 @@ class PullRequests(models.Model): ('pending', 'Pending'), ('failure', 'Failure'), ('success', 'Success'), - ], compute='_compute_statuses', store=True, inverse=readonly, column_type=enum(_name, 'status')) + ], compute='_compute_statuses', store=True, inverse=readonly, readonly=True, column_type=enum(_name, 'status')) previous_failure = fields.Char(default='{}') batch_id = fields.Many2one('runbot_merge.batch', index=True) - staging_id = fields.Many2one('runbot_merge.stagings', compute='_compute_staging', inverse=readonly, store=True) - staging_ids = fields.Many2many('runbot_merge.stagings', string="Stagings", compute='_compute_stagings', inverse=readonly, context={"active_test": False}) + staging_id = fields.Many2one('runbot_merge.stagings', compute='_compute_staging', inverse=readonly, readonly=True, store=True) + staging_ids = fields.Many2many('runbot_merge.stagings', string="Stagings", compute='_compute_stagings', inverse=readonly, readonly=True, context={"active_test": False}) @api.depends('batch_id.batch_staging_ids.runbot_merge_stagings_id.active') def _compute_staging(self):