mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +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:
|
for params in self:
|
||||||
params.commit_ids = params.commit_link_ids.commit_id
|
params.commit_ids = params.commit_link_ids.commit_id
|
||||||
|
|
||||||
def create(self, values):
|
@api.model_create_multi
|
||||||
params = self.new(values)
|
def create(self, values_list):
|
||||||
match = self._find_existing(params.fingerprint)
|
records = self.browse()
|
||||||
if match:
|
for values in values_list:
|
||||||
return match
|
params = self.new(values)
|
||||||
values = self._convert_to_write(params._cache)
|
record = self._find_existing(params.fingerprint)
|
||||||
return super().create(values)
|
if record:
|
||||||
|
records |= record
|
||||||
|
else:
|
||||||
|
values = self._convert_to_write(params._cache)
|
||||||
|
records |= super().create(values)
|
||||||
|
return records
|
||||||
|
|
||||||
def _find_existing(self, fingerprint):
|
def _find_existing(self, fingerprint):
|
||||||
return self.env['runbot.build.params'].search([('fingerprint', '=', fingerprint)], limit=1)
|
return self.env['runbot.build.params'].search([('fingerprint', '=', fingerprint)], limit=1)
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
|
if not self.env.registry.loaded:
|
||||||
|
return
|
||||||
raise UserError('Params cannot be modified')
|
raise UserError('Params cannot be modified')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user