Reduce methods.
parent
b661e8bf72
commit
f18c876c26
|
@ -127,18 +127,6 @@ class Image(models.Model):
|
|||
"image_small": False}
|
||||
s.update(vals)
|
||||
|
||||
@api.multi
|
||||
def _check_filestore(self):
|
||||
"""check if the filestore is created, and do it otherwise."""
|
||||
for s in self:
|
||||
dir_path = os.path.dirname(s.path)
|
||||
try:
|
||||
if not os.path.exists(dir_path):
|
||||
os.makedirs(dir_path)
|
||||
except OSError as e:
|
||||
raise exceptions.Warning(
|
||||
_('The image filestore cannot be created, %s') % e)
|
||||
|
||||
@api.model
|
||||
def _make_name_pretty(self, name):
|
||||
return name.replace('_', ' ').capitalize()
|
||||
|
|
|
@ -41,13 +41,10 @@ class Owner(models.AbstractModel):
|
|||
had one image per record.
|
||||
"""
|
||||
for s in self:
|
||||
s.image_main = False
|
||||
s.image_main_medium = False
|
||||
s.image_main_small = False
|
||||
if s.image_ids:
|
||||
s.image_main = s.image_ids[0].image_main
|
||||
s.image_main_medium = s.image_ids[0].image_medium
|
||||
s.image_main_small = s.image_ids[0].image_small
|
||||
first = s.image_ids[:1]
|
||||
s.image_main = first.image_main
|
||||
s.image_main_medium = first.image_medium
|
||||
s.image_main_small = first.image_small
|
||||
|
||||
@api.multi
|
||||
def _set_multi_image(self, image=False, name=False):
|
||||
|
|
Loading…
Reference in New Issue