mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Fix singleton error
This commit is contained in:
@@ -21,24 +21,32 @@ class ResPartner(models.Model):
|
|||||||
|
|
||||||
@api.constrains("url_file", "url_file_fname")
|
@api.constrains("url_file", "url_file_fname")
|
||||||
def _check_url_file_fname(self):
|
def _check_url_file_fname(self):
|
||||||
rec = self.search([("url_file_fname", "=", self.url_file_fname)])
|
for rec in self:
|
||||||
if len(rec) > 1:
|
match = self.search(
|
||||||
|
[("url_file_fname", "=", rec.url_file_fname), ("id", "!=", rec.id)],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
if match:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_(
|
_(
|
||||||
"This file name is already used on an existing record. "
|
"This file name is already used on an existing record. "
|
||||||
"Please use another file name or delete the url_file on :\n"
|
"Please use another file name or delete the url_file on :\n"
|
||||||
"Model: %s Id: %s" % (self._name, rec.id)
|
"Model: %s Id: %s" % (self._name, match.id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.constrains("url_image", "url_image_fname")
|
@api.constrains("url_image", "url_image_fname")
|
||||||
def _check_url_image_fname(self):
|
def _check_url_image_fname(self):
|
||||||
rec = self.search([("url_image_fname", "=", self.url_image_fname)])
|
for rec in self:
|
||||||
if len(rec) > 1:
|
match = self.search(
|
||||||
|
[("url_image_fname", "=", rec.url_image_fname), ("id", "!=", rec.id)],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
if match:
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_(
|
_(
|
||||||
"This file name is already used on an existing record. "
|
"This file name is already used on an existing record. "
|
||||||
"Please use another file name or delete the url_image on :\n"
|
"Please use another file name or delete the url_image on :\n"
|
||||||
"Model: %s Id: %s" % (self._name, rec.id)
|
"Model: %s Id: %s" % (self._name, match.id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user