pre-commit run -a

This commit is contained in:
Iván Todorovich
2026-05-20 09:50:57 -03:00
parent 16af2b988d
commit 3330aa4986
14 changed files with 26 additions and 29 deletions
+4 -4
View File
@@ -32,7 +32,7 @@ class IrAttachment(models.Model):
_inherit = "ir.attachment"
def _get_stores(self):
return ["azure"] + super(IrAttachment, self)._get_stores()
return ["azure"] + super()._get_stores()
@api.model
def _get_blob_service_client(self):
@@ -162,7 +162,7 @@ class IrAttachment(models.Model):
_logger.info("Attachment '%s' missing on object storage", fname)
return read
else:
return super(IrAttachment, self)._store_file_read(fname, bin_size)
return super()._store_file_read(fname, bin_size)
@api.model
def _store_file_write(self, key, bin_data):
@@ -189,7 +189,7 @@ class IrAttachment(models.Model):
_("The file could not be stored: %s") % str(error)
) from None
else:
_super = super(IrAttachment, self)
_super = super()
filename = _super._store_file_write(key, bin_data)
return filename
@@ -215,4 +215,4 @@ class IrAttachment(models.Model):
# user
_logger.exception("Error during deletion of the file %s" % fname)
else:
super(IrAttachment, self)._store_file_delete(fname)
super()._store_file_delete(fname)
@@ -33,7 +33,7 @@ def clean_fs(files):
_logger.info(
"_file_delete could not unlink %s", full_path, exc_info=True
)
except IOError:
except OSError:
# Harmless and needed for race conditions
_logger.info(
"_file_delete could not unlink %s", full_path, exc_info=True
@@ -124,7 +124,7 @@ class IrAttachment(models.Model):
domain = []
storage_config = self._get_storage_force_db_config()
for mimetype_key, limit in storage_config.items():
part = [("mimetype", "=like", "{}%".format(mimetype_key))]
part = [("mimetype", "=like", f"{mimetype_key}%")]
if limit:
part = AND([part, [("file_size", "<=", limit)]])
domain = OR([domain, part])
@@ -236,7 +236,7 @@ class IrAttachment(models.Model):
# using SQL to include files hidden through unlink or due to record
# rules
cr.execute(
"SELECT COUNT(*) FROM ir_attachment " "WHERE store_fname = %s", (fname,)
"SELECT COUNT(*) FROM ir_attachment WHERE store_fname = %s", (fname,)
)
count = cr.fetchone()[0]
if not count:
@@ -249,7 +249,7 @@ class IrAttachment(models.Model):
for store_name in self._get_stores():
if self.is_storage_disabled(store_name):
continue
uri = "{}://".format(store_name)
uri = f"{store_name}://"
if fname.startswith(uri):
return True
return False
@@ -340,7 +340,7 @@ class IrAttachment(models.Model):
(
normalize_domain(
[
("store_fname", "=like", "{}://%".format(storage)),
("store_fname", "=like", f"{storage}://%"),
# for res_field, see comment in
# _force_storage_to_object_storage
"|",
@@ -360,7 +360,7 @@ class IrAttachment(models.Model):
total = len(attachment_ids)
start_time = time.time()
_logger.info(
"Moving %d attachments from %s to" " DB for fast access", total, storage
"Moving %d attachments from %s to DB for fast access", total, storage
)
current = 0
for attachment_id in attachment_ids:
@@ -399,7 +399,7 @@ class IrAttachment(models.Model):
domain = [
"!",
("store_fname", "=like", "{}://%".format(storage)),
("store_fname", "=like", f"{storage}://%"),
"|",
("res_field", "=", False),
("res_field", "!=", False),
@@ -18,4 +18,4 @@ def strtobool(value):
try:
return _MAP[str(value).lower()]
except KeyError as error:
raise ValueError('"{}" is not a valid bool value'.format(value)) from error
raise ValueError(f'"{value}" is not a valid bool value') from error
+2 -2
View File
@@ -69,7 +69,7 @@ class CloudPlatform(models.AbstractModel):
self.check()
if configs.filestore.location == "remote":
self.env["ir.attachment"].sudo().force_storage()
_logger.info("cloud platform configured for {}".format(platform_kind))
_logger.info(f"cloud platform configured for {platform_kind}")
@api.model
def install(self):
@@ -125,5 +125,5 @@ class CloudPlatform(models.AbstractModel):
self._check_redis(environment_name)
def _register_hook(self):
super(CloudPlatform, self)._register_hook()
super()._register_hook()
self.sudo().check()
+1 -1
View File
@@ -18,4 +18,4 @@ def strtobool(value):
try:
return _MAP[str(value).lower()]
except KeyError as error:
raise ValueError('"{}" is not a valid bool value'.format(value)) from error
raise ValueError(f'"{value}" is not a valid bool value') from error
@@ -1,4 +1,5 @@
# Cloud Platform Azure
Cloud Platform Azure
====================
Install addons specific to the Azure setup.
@@ -5,7 +5,6 @@ import os
import re
from odoo import api, models
from odoo.addons.cloud_platform.models.cloud_platform import (
FilestoreKind,
PlatformConfig,
@@ -19,13 +18,13 @@ class CloudPlatform(models.AbstractModel):
@api.model
def _filestore_kinds(self):
kinds = super(CloudPlatform, self)._filestore_kinds()
kinds = super()._filestore_kinds()
kinds["azure"] = AZURE_STORE_KIND
return kinds
@api.model
def _platform_kinds(self):
kinds = super(CloudPlatform, self)._platform_kinds()
kinds = super()._platform_kinds()
kinds.append("azure")
return kinds
-1
View File
@@ -6,7 +6,6 @@ from odoo.tools import config
class IrQweb(models.AbstractModel):
_inherit = "ir.qweb"
def _generate_asset_nodes_cache(
+1 -1
View File
@@ -35,7 +35,7 @@ class OdooJsonFormatter(jsonlogger.JsonFormatter):
record.dbname = getattr(threading.current_thread(), "dbname", "?")
record.request_id = getattr(threading.current_thread(), "request_uuid", None)
record.uid = getattr(threading.current_thread(), "uid", None)
_super = super(OdooJsonFormatter, self)
_super = super()
return _super.add_fields(log_record, record, message_dict)
+1 -1
View File
@@ -18,4 +18,4 @@ def strtobool(value):
try:
return _MAP[str(value).lower()]
except KeyError as error:
raise ValueError('"{}" is not a valid bool value'.format(value)) from error
raise ValueError(f'"{value}" is not a valid bool value') from error
-1
View File
@@ -7,7 +7,6 @@ import logging
import werkzeug
from odoo import http
from odoo.addons.web.controllers.main import ensure_db
+2 -3
View File
@@ -72,15 +72,14 @@ def purge_fs_sessions(path):
if is_true(os.environ.get("ODOO_SESSION_REDIS")):
if sentinel_host:
_logger.debug(
"HTTP sessions stored in Redis with prefix '%s'. "
"Using Sentinel on %s:%s",
"HTTP sessions stored in Redis with prefix '%s'. Using Sentinel on %s:%s",
prefix or "",
sentinel_host,
sentinel_port,
)
else:
_logger.debug(
"HTTP sessions stored in Redis with prefix '%s' on " "%s:%s",
"HTTP sessions stored in Redis with prefix '%s' on %s:%s",
prefix or "",
host,
port,
+2 -2
View File
@@ -60,7 +60,7 @@ class RedisSessionStore(SessionStore):
else:
user_msg = "anonymous user"
_logger.debug(
"saving session with key '%s' and " "expiration of %s seconds for %s",
"saving session with key '%s' and expiration of %s seconds for %s",
key,
expiration,
user_msg,
@@ -80,7 +80,7 @@ class RedisSessionStore(SessionStore):
def get(self, sid):
if not self.is_valid_key(sid):
_logger.debug(
"session with invalid sid '%s' has been asked, " "returning a new one",
"session with invalid sid '%s' has been asked, returning a new one",
sid,
)
return self.new()
+1 -1
View File
@@ -18,4 +18,4 @@ def strtobool(value):
try:
return _MAP[str(value).lower()]
except KeyError as error:
raise ValueError('"{}" is not a valid bool value'.format(value)) from error
raise ValueError(f'"{value}" is not a valid bool value') from error