From 6ee8ee2183e52e28e71f861b02c4ee6f41cf8379 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 16 Jun 2022 11:10:54 +0000 Subject: [PATCH] [FIX] web_unsplash, website: fix deps between website and web_unsplash Website has no dependency to web_unsplash, we cannot warranty the order of the execution of the overwrite done in 5ef8300. So to avoid to create a new module bridge, with a lot of code, we prefer to make a check for website user directly in unsplash module. It is 'safe' since if you don't have website, the group `group_website_designer` doesn't exists and so it will do a `or False`. closes odoo/odoo#93885 X-original-commit: 05f9f5db372b1a3644f85cb1de3c443b722ef309 Signed-off-by: Romain Derie (rde) --- addons/web_unsplash/models/res_users.py | 8 ++++++-- addons/website/models/res_users.py | 6 ------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/web_unsplash/models/res_users.py b/addons/web_unsplash/models/res_users.py index 375a0ce37ad..4a8dd6ad517 100644 --- a/addons/web_unsplash/models/res_users.py +++ b/addons/web_unsplash/models/res_users.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, models +from odoo import models class ResUsers(models.Model): @@ -8,4 +8,8 @@ class ResUsers(models.Model): def _has_unsplash_key_rights(self): self.ensure_one() - return self.has_group('base.group_erp_manager') + # Website has no dependency to web_unsplash, we cannot warranty the order of the execution + # of the overwrite done in 5ef8300. + # So to avoid to create a new module bridge, with a lot of code, we prefer to make a check + # here for website's user. + return self.has_group('base.group_erp_manager') or self.has_group('website.group_website_designer') diff --git a/addons/website/models/res_users.py b/addons/website/models/res_users.py index 71a507e878c..1d582a128de 100644 --- a/addons/website/models/res_users.py +++ b/addons/website/models/res_users.py @@ -19,12 +19,6 @@ class ResUsers(models.Model): ('login_key', 'unique (login, website_id)', 'You can not have two users with the same login!'), ] - def _has_unsplash_key_rights(self): - self.ensure_one() - if self.has_group('website.group_website_designer'): - return True - return super(ResUsers, self)._has_unsplash_key_rights() - @api.constrains('login', 'website_id') def _check_login(self): """ Do not allow two users with the same login without website """