diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-08-20 12:17:04 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-08-20 12:17:04 +0200 |
| commit | f26de445e5579913e27ea6a630bcee6d40eefc7d (patch) | |
| tree | 8b8e06be8a9d5fd3c1e5c31634611127446b9948 /addons/website/models/website.py | |
| parent | bc6accc5688d3c38a35949751779f808e9c2063f (diff) | |
| parent | 6f55fd65da8c50d36ca97654a920fb075076f125 (diff) | |
[MERGE] forward port branch saas-12.3 up to 6f55fd65da8
Diffstat (limited to 'addons/website/models/website.py')
| -rw-r--r-- | addons/website/models/website.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 3daec56e121..2e10d7d1cc4 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -170,6 +170,19 @@ class Website(models.Model): if 'favicon' in vals: vals['favicon'] = tools.image_process(vals['favicon'], size=(256, 256), crop='center', output_format='ICO') + @api.multi + 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 # ---------------------------------------------------------- |
