Skip to content

Commit 87bf22e

Browse files
committed
🌈 pre-commit manual+auto cleanups
Signed-off-by: Vildan Safin <[email protected]>
1 parent 45885ab commit 87bf22e

File tree

8 files changed

+1593
-957
lines changed

8 files changed

+1593
-957
lines changed

theme_kit/__manifest__.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@
66
"summary": """Brand your odoo instance in few clicks""",
77
"category": "Debranding",
88
"live_test_url": "http://apps.it-projects.info/shop/product/theme-kit?version=11.0",
9-
"images": ['images/brandkit.png'],
9+
"images": ["images/brandkit.png"],
1010
"version": "11.0.1.1.2",
1111
"application": False,
12-
1312
"author": "IT-Projects LLC, Ivan Yelizariev",
1413
"website": "https://it-projects.info",
1514
"license": "GPL-3",
1615
"price": 50.00,
1716
"currency": "EUR",
18-
19-
"depends": [
20-
"web_debranding",
21-
"web_login_background",
22-
"web_widget_color",
23-
],
17+
"depends": ["web_debranding", "web_login_background", "web_widget_color"],
2418
"external_dependencies": {"python": [], "bin": []},
2519
"data": [
2620
"security/ir.model.access.csv",
@@ -30,28 +24,17 @@
3024
"views/theme.xml",
3125
"data/theme_data.xml",
3226
],
33-
"qweb": [
34-
],
35-
"demo": [
36-
],
37-
27+
"qweb": [],
28+
"demo": [],
3829
"post_load": None,
3930
"pre_init_hook": None,
4031
"post_init_hook": None,
41-
4232
"auto_install": False,
4333
"installable": True,
44-
4534
"demo_title": "Brand kit",
46-
"demo_addons": [
47-
"web_debranding",
48-
"web_login_background",
49-
],
50-
"demo_addons_hidden": [
51-
],
35+
"demo_addons": ["web_debranding", "web_login_background"],
36+
"demo_addons_hidden": [],
5237
"demo_url": "theme-kit",
5338
"demo_summary": "Brand your odoo instance in few clicks.",
54-
"demo_images": [
55-
"images/brandkit.png",
56-
]
39+
"demo_images": ["images/brandkit.png"],
5740
}

theme_kit/data/theme_data.xml

Lines changed: 237 additions & 250 deletions
Large diffs are not rendered by default.

theme_kit/models/res_config.py

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,60 @@
44

55
import hashlib
66

7-
from openerp import models, fields, api
7+
from openerp import api, fields, models
88

9-
CUSTOM_CSS_ARCH = '''<?xml version="1.0"?>
9+
CUSTOM_CSS_ARCH = """<?xml version="1.0"?>
1010
<t t-name="theme_kit.custom_css">
1111
%s
1212
</t>
13-
'''
13+
"""
1414

1515

1616
class Config(models.TransientModel):
1717

18-
_name = 'theme_kit.config'
19-
_inherit = 'res.config.settings'
18+
_name = "theme_kit.config"
19+
_inherit = "res.config.settings"
2020

21-
theme_id = fields.Many2one('theme_kit.theme', string="Color Scheme")
22-
favicon_id = fields.Many2one('ir.attachment', string="Favicon")
21+
theme_id = fields.Many2one("theme_kit.theme", string="Color Scheme")
22+
favicon_id = fields.Many2one("ir.attachment", string="Favicon")
2323

24-
page_title = fields.Char('Page Title', help='''Anything you want to see in page title, e.g.
24+
page_title = fields.Char(
25+
"Page Title",
26+
help="""Anything you want to see in page title, e.g.
2527
* CompanyName
2628
* CompanyName's Portal
2729
* CompanyName's Operation System
2830
* etc.
29-
''')
30-
system_name = fields.Char('System Name', help='''e.g.
31+
""",
32+
)
33+
system_name = fields.Char(
34+
"System Name",
35+
help="""e.g.
3136
* CompanyName's Portal
3237
* CompanyName's Operation System
3338
* etc.
34-
''')
35-
company_logo = fields.Binary('Company Logo', help="Due to browser cache, old logo may be still shown. To fix that, clear browser cache")
36-
37-
wallpapers_count = fields.Integer('Wallpapers', readonly=True)
38-
39-
new_documentation_website = fields.Char('Documentation Website', help='''Replaces links to documentation to custom website e.g.
39+
""",
40+
)
41+
company_logo = fields.Binary(
42+
"Company Logo",
43+
help="Due to browser cache, old logo may be still shown. To fix that, clear browser cache",
44+
)
45+
46+
wallpapers_count = fields.Integer("Wallpapers", readonly=True)
47+
48+
new_documentation_website = fields.Char(
49+
"Documentation Website",
50+
help="""Replaces links to documentation to custom website e.g.
4051
* "Help" in Import tool
4152
* "How-to" in paypal
4253
* etc.
43-
''')
54+
""",
55+
)
4456

4557
@api.model
4658
def get_values(self):
4759
res = super(Config, self).get_values()
48-
ICPSudo = self.env['ir.config_parameter'].sudo()
60+
ICPSudo = self.env["ir.config_parameter"].sudo()
4961

5062
theme_id = ICPSudo.get_param("theme_kit.current_theme_id", default=False)
5163
if theme_id:
@@ -55,9 +67,13 @@ def get_values(self):
5567
favicon_id = int(favicon_id)
5668
page_title = ICPSudo.get_param("web_debranding.new_title", default=False)
5769
system_name = ICPSudo.get_param("web_debranding.new_name", default=False)
58-
new_documentation_website = ICPSudo.get_param("web_debranding.new_documentation_website", default=False)
70+
new_documentation_website = ICPSudo.get_param(
71+
"web_debranding.new_documentation_website", default=False
72+
)
5973
company_logo = self.env.user.company_id.logo
60-
wallpapers_count = self.env['ir.attachment'].search_count([('use_as_background', '=', True)])
74+
wallpapers_count = self.env["ir.attachment"].search_count(
75+
[("use_as_background", "=", True)]
76+
)
6177

6278
res.update(
6379
company_logo=company_logo,
@@ -66,37 +82,46 @@ def get_values(self):
6682
page_title=page_title,
6783
system_name=system_name,
6884
new_documentation_website=new_documentation_website,
69-
wallpapers_count=wallpapers_count
85+
wallpapers_count=wallpapers_count,
7086
)
7187
return res
7288

7389
@api.multi
7490
def set_values(self):
7591
super(Config, self).set_values()
76-
ICPSudo = self.env['ir.config_parameter'].sudo()
77-
ICPSudo.set_param('theme_kit.current_theme_id', getattr(self, 'theme_id').id or '')
78-
ICPSudo.set_param('theme_kit.current_favicon_id', getattr(self, 'favicon_id').id or '')
79-
ICPSudo.set_param('web_debranding.new_title', getattr(self, 'page_title') or '')
80-
ICPSudo.set_param('web_debranding.new_name', getattr(self, 'system_name') or '')
81-
ICPSudo.set_param('web_debranding.new_documentation_website', getattr(self, 'new_documentation_website') or '')
92+
ICPSudo = self.env["ir.config_parameter"].sudo()
93+
ICPSudo.set_param(
94+
"theme_kit.current_theme_id", getattr(self, "theme_id").id or ""
95+
)
96+
ICPSudo.set_param(
97+
"theme_kit.current_favicon_id", getattr(self, "favicon_id").id or ""
98+
)
99+
ICPSudo.set_param("web_debranding.new_title", self.page_title or "")
100+
ICPSudo.set_param("web_debranding.new_name", self.system_name or "")
101+
ICPSudo.set_param(
102+
"web_debranding.new_documentation_website",
103+
self.new_documentation_website or "",
104+
)
82105

83106
# set company logo
84107
self.env.user.company_id.logo = self.company_logo
85108

86109
# set theme
87-
custom_css = self.env.ref('theme_kit.custom_css')
88-
code = ''
110+
custom_css = self.env.ref("theme_kit.custom_css")
111+
code = ""
89112
if self.theme_id:
90113
code = self.theme_id.code
91114
arch = CUSTOM_CSS_ARCH % code
92-
custom_css.write({'arch': arch})
115+
custom_css.write({"arch": arch})
93116

94117
# set favicon
95-
url = ''
118+
url = ""
96119
if self.favicon_id:
97120
url = self.favicon_id.url or self._attachment2url(self.favicon_id)
98-
ICPSudo.set_param('web_debranding.favicon_url', url)
121+
ICPSudo.set_param("web_debranding.favicon_url", url)
99122

100123
def _attachment2url(self, att):
101-
sha = hashlib.sha1(getattr(att, '__last_update').encode('utf-8')).hexdigest()[0:7]
102-
return '/web/image/%s-%s' % (att.id, sha)
124+
sha = hashlib.sha1(getattr(att, "__last_update").encode("utf-8")).hexdigest()[
125+
0:7
126+
]
127+
return "/web/image/{}-{}".format(att.id, sha)

0 commit comments

Comments
 (0)