Reduce methods.
parent
b661e8bf72
commit
f18c876c26
|
@ -127,18 +127,6 @@ class Image(models.Model):
|
||||||
"image_small": False}
|
"image_small": False}
|
||||||
s.update(vals)
|
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
|
@api.model
|
||||||
def _make_name_pretty(self, name):
|
def _make_name_pretty(self, name):
|
||||||
return name.replace('_', ' ').capitalize()
|
return name.replace('_', ' ').capitalize()
|
||||||
|
|
|
@ -41,13 +41,10 @@ class Owner(models.AbstractModel):
|
||||||
had one image per record.
|
had one image per record.
|
||||||
"""
|
"""
|
||||||
for s in self:
|
for s in self:
|
||||||
s.image_main = False
|
first = s.image_ids[:1]
|
||||||
s.image_main_medium = False
|
s.image_main = first.image_main
|
||||||
s.image_main_small = False
|
s.image_main_medium = first.image_medium
|
||||||
if s.image_ids:
|
s.image_main_small = first.image_small
|
||||||
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
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _set_multi_image(self, image=False, name=False):
|
def _set_multi_image(self, image=False, name=False):
|
||||||
|
|
Loading…
Reference in New Issue