Browse Source

Reduce methods.

pull/374/head
Jairo Llopis 9 years ago
parent
commit
8d9acf8d49
  1. 12
      base_multi_image/models/image.py
  2. 11
      base_multi_image/models/owner.py

12
base_multi_image/models/image.py

@ -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()

11
base_multi_image/models/owner.py

@ -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…
Cancel
Save