|
13 | 13 | from werkzeug.exceptions import NotFound
|
14 | 14 |
|
15 | 15 | from odoo import api, fields, models, tools, http
|
| 16 | +from odoo.addons.base.models.ir_model import MODULE_UNINSTALL_FLAG |
16 | 17 | from odoo.addons.http_routing.models.ir_http import slugify, _guess_mimetype, url_for
|
17 | 18 | from odoo.addons.website.models.ir_http import sitemap_qs2dom
|
18 | 19 | from odoo.addons.portal.controllers.portal import pager
|
@@ -238,9 +239,11 @@ def _handle_favicon(self, vals):
|
238 | 239 | vals['favicon'] = tools.image_process(vals['favicon'], size=(256, 256), crop='center', output_format='ICO')
|
239 | 240 |
|
240 | 241 | def unlink(self):
|
241 |
| - website = self.search([('id', 'not in', self.ids)], limit=1) |
242 |
| - if not website: |
243 |
| - raise UserError(_('You must keep at least one website.')) |
| 242 | + if not self.env.context.get(MODULE_UNINSTALL_FLAG, False): |
| 243 | + website = self.search([('id', 'not in', self.ids)], limit=1) |
| 244 | + if not website: |
| 245 | + raise UserError(_('You must keep at least one website.')) |
| 246 | + |
244 | 247 | # Do not delete invoices, delete what's strictly necessary
|
245 | 248 | attachments_to_unlink = self.env['ir.attachment'].search([
|
246 | 249 | ('website_id', 'in', self.ids),
|
|
0 commit comments