summaryrefslogtreecommitdiff
path: root/addons/website/models/website.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website/models/website.py')
-rw-r--r--addons/website/models/website.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/website/models/website.py b/addons/website/models/website.py
index a81721d9f10..8ce3d46568a 100644
--- a/addons/website/models/website.py
+++ b/addons/website/models/website.py
@@ -174,6 +174,18 @@ class Website(models.Model):
if 'favicon' in vals:
vals['favicon'] = tools.image_process(vals['favicon'], size=(256, 256), crop='center', output_format='ICO')
+ def unlink(self):
+ # Do not delete invoices, delete what's strictly necessary
+ attachments_to_unlink = self.env['ir.attachment'].search([
+ ('website_id', 'in', self.ids),
+ '|', '|',
+ ('key', '!=', False), # theme attachment
+ ('url', 'ilike', '.custom.'), # customized theme attachment
+ ('url', 'ilike', '.assets\\_'),
+ ])
+ attachments_to_unlink.unlink()
+ return super(Website, self).unlink()
+
# ----------------------------------------------------------
# Page Management
# ----------------------------------------------------------