[IMP] *: merge fw overrides into their parent

Not actually useful in any way, but it does remove a few lines, avoids
a few dupe writes, and furthers the cause of #789
This commit is contained in:
Xavier Morel 2024-06-21 10:40:06 +02:00
parent f303674434
commit 737cbd5de2
2 changed files with 12 additions and 22 deletions

View File

@ -262,25 +262,6 @@ class PullRequests(models.Model):
)
return r
def _try_closing(self, by):
r = super()._try_closing(by)
if r:
self.with_context(forwardport_detach_warn=False).write({
'parent_id': False,
'detach_reason': f"Closed by {by}",
})
self.search([('parent_id', '=', self.id)]).write({
'parent_id': False,
'detach_reason': f"{by} closed parent PR {self.display_name}",
})
return r
def _validate(self, statuses):
failed = super()._validate(statuses)
self.batch_id._schedule_fp_followup()
return failed
def _commits_lazy(self):
s = requests.Session()
s.headers['Authorization'] = 'token %s' % self.repository.project_id.fp_github_token

View File

@ -1067,6 +1067,7 @@ class PullRequests(models.Model):
status = statuses.get(ci) or {'state': 'pending'}
if status['state'] in ('error', 'failure'):
pr._notify_ci_new_failure(ci, status)
self.batch_id._schedule_fp_followup()
def modified(self, fnames, create=False, before=False):
""" By default, Odoo can't express recursive *dependencies* which is
@ -1443,12 +1444,20 @@ class PullRequests(models.Model):
WHERE id = %s AND state != 'merged' AND state != 'closed'
FOR UPDATE SKIP LOCKED;
''', [self.id])
r = self.env.cr.fetchone()
if not r:
if not self.env.cr.rowcount:
return False
self.unstage("closed by %s", by)
self.write({'closed': True, 'reviewed_by': False})
self.with_context(forwardport_detach_warn=False).write({
'closed': True,
'reviewed_by': False,
'parent_id': False,
'detach_reason': f"Closed by {by}",
})
self.search([('parent_id', '=', self.id)]).write({
'parent_id': False,
'detach_reason': f"{by} closed parent PR {self.display_name}",
})
return True