mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: make params work in create multi
The main motivation is to allow to create params from data the "new" method was called with a value list instead of a dict. Also, makes it possible to update params when the registry is not laoded
This commit is contained in:
parent
d164d9a745
commit
2488228b7b
@ -107,18 +107,25 @@ class BuildParameters(models.Model):
|
||||
for params in self:
|
||||
params.commit_ids = params.commit_link_ids.commit_id
|
||||
|
||||
def create(self, values):
|
||||
params = self.new(values)
|
||||
match = self._find_existing(params.fingerprint)
|
||||
if match:
|
||||
return match
|
||||
values = self._convert_to_write(params._cache)
|
||||
return super().create(values)
|
||||
@api.model_create_multi
|
||||
def create(self, values_list):
|
||||
records = self.browse()
|
||||
for values in values_list:
|
||||
params = self.new(values)
|
||||
record = self._find_existing(params.fingerprint)
|
||||
if record:
|
||||
records |= record
|
||||
else:
|
||||
values = self._convert_to_write(params._cache)
|
||||
records |= super().create(values)
|
||||
return records
|
||||
|
||||
def _find_existing(self, fingerprint):
|
||||
return self.env['runbot.build.params'].search([('fingerprint', '=', fingerprint)], limit=1)
|
||||
|
||||
def write(self, vals):
|
||||
if not self.env.registry.loaded:
|
||||
return
|
||||
raise UserError('Params cannot be modified')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user