[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.
This commit is contained in:
Olivier Dony 2016-01-18 14:18:21 +01:00
parent 431a3f6d5b
commit be34ac72c9

View File

@ -512,7 +512,18 @@ class runbot_build(osv.osv):
_columns = {
'branch_id': fields.many2one('runbot.branch', 'Branch', required=True, ondelete='cascade', select=1),
'repo_id': fields.related('branch_id', 'repo_id', type="many2one", relation="runbot.repo", string="Repository", readonly=True, store=True, ondelete='cascade', select=1),
'repo_id': fields.related(
'branch_id', 'repo_id', type="many2one", relation="runbot.repo",
string="Repository", readonly=True, ondelete='cascade', select=1,
store={
'runbot.build': (lambda s, c, u, ids, ctx: ids, ['branch_id'], 20),
'runbot.branch': (
lambda self, cr, uid, ids, ctx: self.pool['runbot.build'].search(
cr, uid, [('branch_id', 'in', ids)]),
['repo_id'],
10,
),
}),
'name': fields.char('Revno', required=True, select=1),
'host': fields.char('Host'),
'port': fields.integer('Port'),