[FIX] website: prevent user to unlink default_website
Previously when we tried to delete default_website it was deleted. In this commit we have fixed this issue by preventing user to unlink default_website.Also we remvoe _unlink_except_last_remaining_website method. sentry-3874625419 closes odoo/odoo#113405 X-original-commit: 637af9f747bda0d6b4607d02a0e51d44cf889a89 Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
@@ -10303,6 +10303,14 @@ msgstr ""
|
||||
msgid "You can't remove the submit button of the form"
|
||||
msgstr ""
|
||||
|
||||
#. module: website
|
||||
#. odoo-python
|
||||
#: code:addons/website/models/website.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You cannot delete default website %s. Try to change its settings instead"
|
||||
msgstr ""
|
||||
|
||||
#. module: website
|
||||
#. odoo-javascript
|
||||
#: code:addons/website/static/src/snippets/s_website_form/options.js:0
|
||||
@@ -10338,13 +10346,6 @@ msgstr ""
|
||||
msgid "You may opt-out of a third-party's use of cookies by visiting the"
|
||||
msgstr ""
|
||||
|
||||
#. module: website
|
||||
#. odoo-python
|
||||
#: code:addons/website/models/website.py:0
|
||||
#, python-format
|
||||
msgid "You must keep at least one website."
|
||||
msgstr ""
|
||||
|
||||
#. module: website
|
||||
#: model_terms:ir.ui.view,arch_db:website.s_faq_collapse
|
||||
msgid ""
|
||||
|
||||
@@ -282,10 +282,10 @@ class Website(models.Model):
|
||||
raise ValidationError(_("The homepage URL should be relative and start with '/'."))
|
||||
|
||||
@api.ondelete(at_uninstall=False)
|
||||
def _unlink_except_last_remaining_website(self):
|
||||
website = self.search([('id', 'not in', self.ids)], limit=1)
|
||||
if not website:
|
||||
raise UserError(_('You must keep at least one website.'))
|
||||
def _unlink_except_default_website(self):
|
||||
default_website = self.env.ref('website.default_website', raise_if_not_found=False)
|
||||
if default_website and default_website in self:
|
||||
raise UserError(_("You cannot delete default website %s. Try to change its settings instead", default_website.name))
|
||||
|
||||
def unlink(self):
|
||||
self._remove_attachments_on_website_unlink()
|
||||
|
||||
Reference in New Issue
Block a user