Browse Source

Merge pull request #629 from laslabs/bugfix/10.0/base_multi_image-unlink_bypass

[FIX][10.0] base_multi_image: Adhere to image delete bypass
pull/734/head
Pedro M. Baeza 8 years ago
committed by GitHub
parent
commit
5fa168cc96
  1. 1
      base_multi_image/README.rst
  2. 7
      base_multi_image/models/owner.py

1
base_multi_image/README.rst

@ -121,6 +121,7 @@ Contributors
* Rafael Blasco <rafabn@antiun.com> * Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com> * Jairo Llopis <yajo.sk8@gmail.com>
* Sodexis <dev@sodexis.com> * Sodexis <dev@sodexis.com>
* Dave Lasley <dave@laslabs.com>
Maintainer Maintainer
---------- ----------

7
base_multi_image/models/owner.py

@ -90,9 +90,12 @@ class Owner(models.AbstractModel):
@api.multi @api.multi
def unlink(self): def unlink(self):
"""Mimic `ondelete="cascade"` for multi images."""
"""Mimic `ondelete="cascade"` for multi images.
Will be skipped if ``env.context['bypass_image_removal']`` == True
"""
images = self.mapped("image_ids") images = self.mapped("image_ids")
result = super(Owner, self).unlink() result = super(Owner, self).unlink()
if result:
if result and not self.env.context.get('bypass_image_removal'):
images.unlink() images.unlink()
return result return result
Loading…
Cancel
Save