From da69c1870afad91dd03c50b8b62bbeb85076837d Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Tue, 29 Nov 2016 18:45:51 -0800 Subject: [PATCH] [FIX] base_multi_image: Adhere to image delete bypass * Add catch in owner unlink to allow for image delete bypass via context --- base_multi_image/README.rst | 1 + base_multi_image/models/owner.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/base_multi_image/README.rst b/base_multi_image/README.rst index df87cf021..c7d557683 100644 --- a/base_multi_image/README.rst +++ b/base_multi_image/README.rst @@ -121,6 +121,7 @@ Contributors * Rafael Blasco * Jairo Llopis * Sodexis +* Dave Lasley Maintainer ---------- diff --git a/base_multi_image/models/owner.py b/base_multi_image/models/owner.py index d0236de4c..11e5e90ce 100644 --- a/base_multi_image/models/owner.py +++ b/base_multi_image/models/owner.py @@ -90,9 +90,12 @@ class Owner(models.AbstractModel): @api.multi 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") result = super(Owner, self).unlink() - if result: + if result and not self.env.context.get('bypass_image_removal'): images.unlink() return result