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
32 changes: 16 additions & 16 deletions web_company_color/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..utils import convert_to_image, image_to_rgb, n_rgb_to_hex

URL_BASE = "/web_company_color/static/src/scss/"
URL_SCSS_GEN_TEMPLATE = URL_BASE + "custom_colors.%d.gen.scss"
URL_SCSS_GEN_TEMPLATE = f"{URL_BASE}custom_colors.%d.gen.scss"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 11-11 refactored with the following changes:



class ResCompany(models.Model):
Expand Down Expand Up @@ -96,7 +96,7 @@ def write(self, values):

result = super().write(values)

if any([field in values for field in fields_to_check]):
if any(field in values for field in fields_to_check):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResCompany.write refactored with the following changes:

self.scss_create_or_update_attachment()
else:
result = super().write(values)
Expand All @@ -108,24 +108,24 @@ def _scss_get_sanitized_values(self):
# This allow extend company_colors and only sanitize selected fields
# or add custom values
values = dict(self.company_colors or {})
values.update(
{
"color_navbar_bg": (values.get("color_navbar_bg") or "$o-brand-odoo"),
"color_navbar_bg_hover": (
values.get("color_navbar_bg_hover")
or "$o-navbar-inverse-link-hover-bg"
),
"color_navbar_text": (values.get("color_navbar_text") or "#FFF"),
}
)
values |= {
"color_navbar_bg": (values.get("color_navbar_bg") or "$o-brand-odoo"),
"color_navbar_bg_hover": (
values.get("color_navbar_bg_hover")
or "$o-navbar-inverse-link-hover-bg"
),
"color_navbar_text": (values.get("color_navbar_text") or "#FFF"),
}
Comment on lines -111 to +118
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResCompany._scss_get_sanitized_values refactored with the following changes:

return values

def _scss_generate_content(self):
self.ensure_one()
# ir.attachment need files with content to work
if not self.company_colors:
return "// No Web Company Color SCSS Content\n"
return self.SCSS_TEMPLATE % self._scss_get_sanitized_values()
return (
self.SCSS_TEMPLATE % self._scss_get_sanitized_values()
if self.company_colors
else "// No Web Company Color SCSS Content\n"
)
Comment on lines -126 to +128
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResCompany._scss_generate_content refactored with the following changes:


def scss_get_url(self):
self.ensure_one()
Expand All @@ -149,6 +149,6 @@ def scss_create_or_update_attachment(self):
if custom_attachment:
custom_attachment.sudo().write(values)
else:
values.update({"type": "binary", "mimetype": "text/scss"})
values |= {"type": "binary", "mimetype": "text/scss"}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResCompany.scss_create_or_update_attachment refactored with the following changes:

IrAttachmentObj.sudo().create(values)
self.env["ir.qweb"].sudo().clear_caches()
2 changes: 1 addition & 1 deletion web_company_color/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def normalize_vec3(vec3):
rgb_sum = [0, 0, 0]
# Mix. image colors using addition method
RGBA_WHITE = (255, 255, 255, 255)
for i in range(0, height * width):
for i in range(height * width):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function image_to_rgb refactored with the following changes:

rgba = img.getpixel((i % width, i / width))
if rgba[3] > 128 and rgba != RGBA_WHITE:
rgb_sum[0] += rgba[0]
Expand Down
12 changes: 6 additions & 6 deletions web_notify/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class ResUsers(models.Model):
def _compute_channel_names(self):
for record in self:
res_id = record.id
record.notify_success_channel_name = "notify_success_%s" % res_id
record.notify_danger_channel_name = "notify_danger_%s" % res_id
record.notify_warning_channel_name = "notify_warning_%s" % res_id
record.notify_info_channel_name = "notify_info_%s" % res_id
record.notify_default_channel_name = "notify_default_%s" % res_id
record.notify_success_channel_name = f"notify_success_{res_id}"
record.notify_danger_channel_name = f"notify_danger_{res_id}"
record.notify_warning_channel_name = f"notify_warning_{res_id}"
record.notify_info_channel_name = f"notify_info_{res_id}"
record.notify_default_channel_name = f"notify_default_{res_id}"
Comment on lines -23 to +27
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResUsers._compute_channel_names refactored with the following changes:


notify_success_channel_name = fields.Char(compute="_compute_channel_names")
notify_danger_channel_name = fields.Char(compute="_compute_channel_names")
Expand Down Expand Up @@ -62,7 +62,7 @@ def _notify_channel(
raise exceptions.UserError(
_("Sending a notification to another user is forbidden.")
)
channel_name_field = "notify_{}_channel_name".format(type_message)
channel_name_field = f"notify_{type_message}_channel_name"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResUsers._notify_channel refactored with the following changes:

bus_message = {
"type": type_message,
"message": message,
Expand Down
10 changes: 5 additions & 5 deletions web_notify/tests/test_res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_notify_success(self):
self.env.user.notify_success(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
test_msg.update({"type": SUCCESS})
test_msg["type"] = SUCCESS
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestResUsers.test_notify_success refactored with the following changes:

self.assertDictEqual(test_msg, json.loads(news.message))

def test_notify_danger(self):
Expand All @@ -34,7 +34,7 @@ def test_notify_danger(self):
self.env.user.notify_danger(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
test_msg.update({"type": DANGER})
test_msg["type"] = DANGER
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestResUsers.test_notify_danger refactored with the following changes:

self.assertDictEqual(test_msg, json.loads(news.message))

def test_notify_warning(self):
Expand All @@ -47,7 +47,7 @@ def test_notify_warning(self):
self.env.user.notify_warning(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
test_msg.update({"type": WARNING})
test_msg["type"] = WARNING
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestResUsers.test_notify_warning refactored with the following changes:

self.assertDictEqual(test_msg, json.loads(news.message))

def test_notify_info(self):
Expand All @@ -58,7 +58,7 @@ def test_notify_info(self):
self.env.user.notify_info(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
test_msg.update({"type": INFO})
test_msg["type"] = INFO
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestResUsers.test_notify_info refactored with the following changes:

self.assertDictEqual(test_msg, json.loads(news.message))

def test_notify_default(self):
Expand All @@ -71,7 +71,7 @@ def test_notify_default(self):
self.env.user.notify_default(**test_msg)
news = bus_bus.search(domain) - existing
self.assertEqual(1, len(news))
test_msg.update({"type": DEFAULT})
test_msg["type"] = DEFAULT
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestResUsers.test_notify_default refactored with the following changes:

self.assertDictEqual(test_msg, json.loads(news.message))

def test_notify_many(self):
Expand Down
4 changes: 1 addition & 3 deletions web_pwa_oca/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def service_worker(self):
urls = []
urls.extend(self.get_asset_urls("web.assets_common"))
urls.extend(self.get_asset_urls("web.assets_backend"))
version_list = []
for url in urls:
version_list.append(url.split("/")[3])
version_list = [url.split("/")[3] for url in urls]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PWA.service_worker refactored with the following changes:

cache_version = "-".join(version_list)
mimetype = "text/javascript;charset=utf-8"
content = qweb.render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ def values_char_field(self):
def values_int_field(self):
min_value = int(self.env.context.get("min"))
max_value = int(self.env.context.get("max"))
options = []
for value in range(min_value, max_value + 1):
options.append((value, str(value)))
return options
return [(value, str(value)) for value in range(min_value, max_value + 1)]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function WebWidgetDropdownDynamicExample.values_int_field refactored with the following changes:


@api.model
def values_selection_field(self):
Expand Down
4 changes: 1 addition & 3 deletions web_widget_x2many_2d_matrix_example/models/x2m_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class X2MDemo(models.Model):

def _open_x2m_matrix(self, view_xmlid):
wiz = self.env["x2m.matrix.demo.wiz"].create({})
view_id = self.env.ref(
"web_widget_x2many_2d_matrix_example.%s" % view_xmlid,
).id
view_id = self.env.ref(f"web_widget_x2many_2d_matrix_example.{view_xmlid}").id
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function X2MDemo._open_x2m_matrix refactored with the following changes:

return {
"name": "Try x2many 2D matrix widget",
"type": "ir.actions.act_window",
Expand Down
10 changes: 4 additions & 6 deletions web_widget_x2many_2d_matrix_example/wizard/x2m_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ def _default_line_ids(self):
recs = self.env["x2m.demo"].search([])
users = self.env["x2m.demo.line"].search([]).mapped("user_id")
return [
(
(4, rec.line_ids.filtered(lambda x: x.user_id == usr)[0].id)
if rec.line_ids.filtered(lambda x: x.user_id == usr)
else (
0,
0,
{
"name": "{}'s task on {}".format(usr.name, rec.name),
"name": f"{usr.name}'s task on {rec.name}",
"demo_id": rec.id,
"user_id": usr.id,
},
)
# if there isn't a demo line record for the user, create a new one
if not rec.line_ids.filtered(lambda x: x.user_id == usr) else
# otherwise, return the line
(4, rec.line_ids.filtered(lambda x: x.user_id == usr)[0].id)
Comment on lines -19 to -31
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function X2mMatrixDemoWiz._default_line_ids refactored with the following changes:

This removes the following comments ( why? ):

# if there isn't a demo line record for the user, create a new one
# otherwise, return the line

for rec in recs
for usr in users
]