pre-commit run -a

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