Skip to content

Commit 2247c95

Browse files
committed
[IMP] web_company_color: Add button to reset colors to default
1 parent 3fc92db commit 2247c95

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

web_company_color/models/res_company.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def unlink(self):
167167
def write(self, values):
168168
if not self.env.context.get("ignore_company_color", False):
169169
fields_to_check = (
170+
"company_colors",
170171
"color_navbar_bg",
171172
"color_navbar_bg_hover",
172173
"color_navbar_text",

web_company_color/tests/test_res_company.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ def test_reset_colors(self):
9595
}
9696
)
9797
company.button_reset_colors()
98+
company.invalidate_recordset()
99+
self.assertEqual(
100+
company.company_colors, {}, "company_colors should be empty after reset"
101+
)
98102
self.assertFalse(company.color_navbar_bg, "color_navbar_bg should be reset")
99103
self.assertFalse(
100104
company.color_navbar_bg_hover, "color_navbar_bg_hover should be reset"
@@ -112,8 +116,12 @@ def test_reset_colors(self):
112116
self.assertFalse(
113117
company.color_submenu_text, "color_submenu_text should be reset"
114118
)
115-
self.assertFalse(
116-
company.company_colors, "company_colors should be empty after reset"
119+
attachment = self.env["ir.attachment"].search(
120+
[("url", "=", company.scss_get_url())]
121+
)
122+
css = base64.b64decode(attachment.datas).decode()
123+
self.assertNotIn(
124+
"#111111", css, "SCSS should not contain old colors after reset"
117125
)
118126

119127
def test_compiled_scss(self):

0 commit comments

Comments
 (0)