Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions brand_external_report_layout/models/res_brand.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def _get_asset_style_b64(self):
{"brand_ids": self.sudo().search([])},
raise_if_not_found=False,
)
# An empty attachment cannot be read by the assets compiler,
# which breaks the report assets when there is no brand yet.
if not brand_styles.strip():
brand_styles = "/* No brand-specific styles configured */"
return base64.b64encode(brand_styles.encode())

def _update_asset_style(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,8 @@ def test_brand_document_layout_get_asset_style(self):
)
result = wizard._get_asset_style()
self.assertIsInstance(result, markupsafe.Markup)

def test_asset_style_not_empty_without_brand(self):
self.env["res.brand"].search([]).unlink()
content = base64.b64decode(self.env["res.brand"]._get_asset_style_b64())
self.assertTrue(content.strip())
Loading