Skip to content

Commit 8067425

Browse files
committed
[FIX] runbot: reduce serialization failures (TransactionRollbackError)
Both the cron and the tests themselves need to write to the builds, which triggers the update of the `repo_id` field, as it is a stored related.
1 parent db6261e commit 8067425

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

runbot/runbot.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,18 @@ def _get_domain(self, cr, uid, ids, field_name, arg, context=None):
512512

513513
_columns = {
514514
'branch_id': fields.many2one('runbot.branch', 'Branch', required=True, ondelete='cascade', select=1),
515-
'repo_id': fields.related('branch_id', 'repo_id', type="many2one", relation="runbot.repo", string="Repository", readonly=True, store=True, ondelete='cascade', select=1),
515+
'repo_id': fields.related(
516+
'branch_id', 'repo_id', type="many2one", relation="runbot.repo",
517+
string="Repository", readonly=True, ondelete='cascade', select=1,
518+
store={
519+
'runbot.build': (lambda s, c, u, ids, ctx: ids, ['branch_id'], 20),
520+
'runbot.branch': (
521+
lambda self, cr, uid, ids, ctx: self.pool['runbot.build'].search(
522+
cr, uid, [('branch_id', 'in', ids)]),
523+
['repo_id'],
524+
10,
525+
),
526+
}),
516527
'name': fields.char('Revno', required=True, select=1),
517528
'host': fields.char('Host'),
518529
'port': fields.integer('Port'),

0 commit comments

Comments
 (0)