mirror of
https://github.com/odoo/runbot.git
synced 2025-03-17 16:35:47 +07:00

The freeze wizard has support for merging freeze / release PRs on each of the newly created branches. But since this would be done by, well, merging, those PRs would get forward-ported to master, and would have to be closed there. This creates additional work for the freeze master, and noise / parasitic PRs. Obviously it's possible for the freeze master to set some nonsense `up to` (nonsense because the "real" limit doesn't exist yet at that point), but really it never makes any sense to forward port release PRs, so the wizard should do it.
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
from odoo import models
|
|
|
|
|
|
class FreezeWizard(models.Model):
|
|
""" Override freeze wizard to disable the forward port cron when one is
|
|
created (so there's a freeze ongoing) and re-enable it once all freezes are
|
|
done.
|
|
|
|
If there ever is a case where we have lots of projects,
|
|
"""
|
|
_inherit = 'runbot_merge.project.freeze'
|
|
|
|
def create(self, vals_list):
|
|
r = super().create(vals_list)
|
|
self.env.ref('forwardport.port_forward').active = False
|
|
return r
|
|
|
|
def unlink(self):
|
|
r = super().unlink()
|
|
if not self.search_count([]):
|
|
self.env.ref('forwardport.port_forward').active = True
|
|
return r
|
|
|
|
def action_freeze(self):
|
|
# have to store wizard content as it's removed during freeze
|
|
project = self.project_id
|
|
branches_before = project.branch_ids
|
|
prs = self.mapped('release_pr_ids.pr_id')
|
|
r = super().action_freeze()
|
|
new_branch = project.branch_ids - branches_before
|
|
prs.write({'limit_id': new_branch.id})
|
|
return r
|