mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot: fix duplicate id and improve global_state
This commit is contained in:
parent
c58d1626ea
commit
d75c4f085f
@ -14,7 +14,7 @@ class JsonDictField(Field):
|
|||||||
|
|
||||||
def convert_to_column(self, value, record, values=None, validate=True):
|
def convert_to_column(self, value, record, values=None, validate=True):
|
||||||
val = self.convert_to_cache(value, record, validate=validate)
|
val = self.convert_to_cache(value, record, validate=validate)
|
||||||
return Json(value) if val else val
|
return Json(val) if val else False
|
||||||
|
|
||||||
def convert_to_cache(self, value, record, validate=True):
|
def convert_to_cache(self, value, record, validate=True):
|
||||||
return value.dict if isinstance(value, FieldDict) else value if isinstance(value, dict) else None
|
return value.dict if isinstance(value, FieldDict) else value if isinstance(value, dict) else None
|
||||||
|
@ -126,10 +126,14 @@ class runbot_build(models.Model):
|
|||||||
for record in self:
|
for record in self:
|
||||||
if record.duplicate_id:
|
if record.duplicate_id:
|
||||||
record.global_state = record.duplicate_id.global_state
|
record.global_state = record.duplicate_id.global_state
|
||||||
|
elif record.global_state == 'done' and self.local_state == 'done':
|
||||||
|
# avoid to recompute if done, mostly important whith many orphan childrens
|
||||||
|
record.global_state = 'done'
|
||||||
else:
|
else:
|
||||||
waiting_score = record._get_state_score('waiting')
|
waiting_score = record._get_state_score('waiting')
|
||||||
if record._get_state_score(record.local_state) > waiting_score and record.children_ids: # if finish, check children
|
children_ids = [child for child in record.children_ids if not child.orphan_result]
|
||||||
children_state = record._get_youngest_state([child.global_state for child in record.children_ids])
|
if record._get_state_score(record.local_state) > waiting_score and children_ids: # if finish, check children
|
||||||
|
children_state = record._get_youngest_state([child.global_state for child in children_ids])
|
||||||
if record._get_state_score(children_state) > waiting_score:
|
if record._get_state_score(children_state) > waiting_score:
|
||||||
record.global_state = record.local_state
|
record.global_state = record.local_state
|
||||||
else:
|
else:
|
||||||
@ -248,7 +252,7 @@ class runbot_build(models.Model):
|
|||||||
'|', ('local_result', '=', False), ('local_result', '!=', 'skipped'), # had to reintroduce False posibility for selections
|
'|', ('local_result', '=', False), ('local_result', '!=', 'skipped'), # had to reintroduce False posibility for selections
|
||||||
('config_id', '=', build_id.config_id.id),
|
('config_id', '=', build_id.config_id.id),
|
||||||
('extra_params', '=', build_id.extra_params),
|
('extra_params', '=', build_id.extra_params),
|
||||||
('config_data', '=', build_id.config_data),
|
('config_data', '=', build_id.config_data or False),
|
||||||
]
|
]
|
||||||
candidates = self.search(domain)
|
candidates = self.search(domain)
|
||||||
if candidates and nb_deps:
|
if candidates and nb_deps:
|
||||||
|
@ -89,6 +89,40 @@ class Test_Build(RunbotCase):
|
|||||||
build.env.cr.execute("SELECT config_data, config_data->'test_write' AS written, config_data->'test_build' AS test_build FROM runbot_build WHERE id = %s", [build.id])
|
build.env.cr.execute("SELECT config_data, config_data->'test_write' AS written, config_data->'test_build' AS test_build FROM runbot_build WHERE id = %s", [build.id])
|
||||||
self.assertEqual([({'test_write': 'written', 'test_build': 'foo'}, 'written', 'foo')], self.env.cr.fetchall())
|
self.assertEqual([({'test_write': 'written', 'test_build': 'foo'}, 'written', 'foo')], self.env.cr.fetchall())
|
||||||
|
|
||||||
|
def test_config_data_duplicate(self):
|
||||||
|
|
||||||
|
build = self.create_build({
|
||||||
|
'branch_id': self.branch.id,
|
||||||
|
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
|
||||||
|
})
|
||||||
|
|
||||||
|
build2 = self.create_build({
|
||||||
|
'branch_id': self.branch.id,
|
||||||
|
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
|
||||||
|
})
|
||||||
|
self.assertEqual(build2.duplicate_id, build)
|
||||||
|
|
||||||
|
build3 = self.create_build({
|
||||||
|
'branch_id': self.branch.id,
|
||||||
|
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
|
||||||
|
'config_data': {'test':'aa'},
|
||||||
|
})
|
||||||
|
self.assertFalse(build3.duplicate_id)
|
||||||
|
build4 = self.create_build({
|
||||||
|
'branch_id': self.branch.id,
|
||||||
|
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
|
||||||
|
'config_data': {'test':'aa'},
|
||||||
|
})
|
||||||
|
self.assertEqual(build4.duplicate_id, build3)
|
||||||
|
|
||||||
|
build5 = self.create_build({
|
||||||
|
'branch_id': self.branch.id,
|
||||||
|
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
|
||||||
|
'config_data': {'test':'bb'},
|
||||||
|
})
|
||||||
|
self.assertFalse(build5.duplicate_id)
|
||||||
|
|
||||||
|
|
||||||
@patch('odoo.addons.runbot.models.build.runbot_build._get_repo_available_modules')
|
@patch('odoo.addons.runbot.models.build.runbot_build._get_repo_available_modules')
|
||||||
def test_filter_modules(self, mock_get_repo_mods):
|
def test_filter_modules(self, mock_get_repo_mods):
|
||||||
""" test module filtering """
|
""" test module filtering """
|
||||||
|
Loading…
Reference in New Issue
Block a user