Skip to content

Commit

Permalink
[IMP] *: automatic changes by pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lef-adhoc committed Jan 16, 2025
1 parent 733a2f4 commit c919999
Show file tree
Hide file tree
Showing 59 changed files with 563 additions and 584 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: pre-commit
on:
push:
branches: "*.0"
pull_request:
pull_request_target:

jobs:
pre-commit:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

exclude: |
(?x)
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
# Library files can have extraneous formatting (even minimized)
Expand Down
2 changes: 1 addition & 1 deletion attachment_s3/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
},
"website": "https://github.com/camptocamp/odoo-cloud-platform",
"data": [],
'installable': False,
"installable": False,
}
12 changes: 4 additions & 8 deletions attachment_s3/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
_logger.debug("Cannot 'import boto3'.")


class S3BucketClientRegistry(object):
class S3BucketClientRegistry:
bucket_dict = {}

@classmethod
Expand Down Expand Up @@ -131,9 +131,7 @@ def _store_file_read(self, fname):
try:
bucket = self._get_s3_bucket(name=s3uri.bucket())
except exceptions.UserError:
_logger.exception(
"error reading attachment '%s' from object storage", fname
)
_logger.exception("error reading attachment '%s' from object storage", fname)
return ""
try:
key = s3uri.item()
Expand Down Expand Up @@ -164,7 +162,7 @@ def _store_file_write(self, key, bin_data):
# TODO handle this on a better way
try:
if obj.content_length:
_logger.info('Skip uploading object %s, already exists', filename)
_logger.info("Skip uploading object %s, already exists", filename)
return filename
except Exception:
pass
Expand All @@ -173,9 +171,7 @@ def _store_file_write(self, key, bin_data):
except ClientError as error:
# log verbose error from s3, return short message for user
_logger.exception("Error during storage of the file %s" % filename)
raise exceptions.UserError(
_("The file could not be stored: %s") % str(error)
) from None
raise exceptions.UserError(_("The file could not be stored: %s") % str(error)) from None
else:
_super = super()
filename = _super._store_file_write(key, bin_data)
Expand Down
3 changes: 1 addition & 2 deletions attachment_s3/s3uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import re


class S3Uri(object):

class S3Uri:
_url_re = re.compile("^s3:///*([^/]*)/?(.*)", re.IGNORECASE | re.UNICODE)

def __init__(self, uri):
Expand Down
40 changes: 19 additions & 21 deletions base_dynamic_message/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,25 @@
#
##############################################################################
{
'name': 'Dynamic Message',
'version': "18.0.1.0.0",
'category': 'Base',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'images': [
"name": "Dynamic Message",
"version": "18.0.1.0.0",
"category": "Base",
"sequence": 14,
"summary": "",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
"images": [],
"depends": [
"base",
],
'depends': [
'base',
"data": [
"security/res_groups.xml",
"security/ir.model.access.csv",
"views/ir_model_dynamic_message_views.xml",
],
'data': [
'security/res_groups.xml',
'security/ir.model.access.csv',
'views/ir_model_dynamic_message_views.xml',
],
'demo': [
],
'installable': True,
'auto_install': False,
'application': False,
"demo": [],
"installable": True,
"auto_install": False,
"application": False,
}
96 changes: 52 additions & 44 deletions base_dynamic_message/models/ir_model_dynamic_message.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
from odoo import models, fields, api
import ast
import textwrap

from odoo import api, fields, models


class IrModelDynamicMessage(models.Model):
_name = 'ir.model.dynamic_message'
_description = 'ir.model.dynamic_message'
_name = "ir.model.dynamic_message"
_description = "ir.model.dynamic_message"

name = fields.Char(required=True)
description = fields.Text()
model_id = fields.Many2one('ir.model', required=True, ondelete='cascade')
model_name = fields.Char(related='model_id.model', string='Model Name')
line_ids = fields.One2many('ir.model.dynamic_message.line', 'dynamic_message_id', copy=True)
code = fields.Text(compute='_compute_code')
depends = fields.Char(compute='_compute_depends', store=True, readonly=False, required=True)
field_id = fields.Many2one('ir.model.fields', readonly=True, copy=False)
model_id = fields.Many2one("ir.model", required=True, ondelete="cascade")
model_name = fields.Char(related="model_id.model", string="Model Name")
line_ids = fields.One2many("ir.model.dynamic_message.line", "dynamic_message_id", copy=True)
code = fields.Text(compute="_compute_code")
depends = fields.Char(compute="_compute_depends", store=True, readonly=False, required=True)
field_id = fields.Many2one("ir.model.fields", readonly=True, copy=False)
view_to_inherit_id = fields.Many2one(
'ir.ui.view', compute='_compute_view_to_inherit', readonly=False, store=True, required=True)
view_id = fields.Many2one('ir.ui.view', readonly=True, copy=False)
alert_type = fields.Selection([('info', 'info'), ('warning', 'warning'), ('danger', 'danger')], required=True, default='info')
"ir.ui.view", compute="_compute_view_to_inherit", readonly=False, store=True, required=True
)
view_id = fields.Many2one("ir.ui.view", readonly=True, copy=False)
alert_type = fields.Selection(
[("info", "info"), ("warning", "warning"), ("danger", "danger")], required=True, default="info"
)

@api.depends('model_id')
@api.depends("model_id")
def _compute_view_to_inherit(self):
for rec in self:
rec.view_to_inherit_id = rec.env['ir.ui.view'].search(
[('type', '=', 'form'), ('model', '=', rec.model_id.model), ('mode', '=', 'primary')], limit=1)
rec.view_to_inherit_id = rec.env["ir.ui.view"].search(
[("type", "=", "form"), ("model", "=", rec.model_id.model), ("mode", "=", "primary")], limit=1
)

@api.depends('line_ids.code')
@api.depends("line_ids.code")
def _compute_code(self):
for rec in self:
sub_string = ''.join(rec.line_ids.filtered('code').mapped('code'))
sub_string = textwrap.indent(sub_string, prefix=' ')
field_name = 'x_dynamic_message_%i' % rec._origin.id or 0
sub_string = "".join(rec.line_ids.filtered("code").mapped("code"))
sub_string = textwrap.indent(sub_string, prefix=" ")
field_name = "x_dynamic_message_%i" % rec._origin.id or 0
rec.code = """
for rec in self:
messages = []
Expand All @@ -42,52 +47,53 @@ def _compute_code(self):
rec['%s'] = "<ul>%%s</ul>" %% "".join(["<li>%%s</li>" %% message for message in messages])
""" % (sub_string, field_name, field_name)

@api.depends('line_ids.domain')
@api.depends("line_ids.domain")
def _compute_depends(self):
for rec in self:
dep_fields = []
for line in rec.line_ids.filtered('domain'):
for line in rec.line_ids.filtered("domain"):
domain = ast.literal_eval(line.domain)
for element in domain:
if type(element) is not tuple:
continue
# TODO deberiamos chequear que el campo sea sercheable (en smart search teniamos algo de esto)
if '.' in element[0]:
dep_fields.append(element[0].split('.')[0])
elif element[0] != 'id':
if "." in element[0]:
dep_fields.append(element[0].split(".")[0])
elif element[0] != "id":
dep_fields.append(element[0])
rec.depends = ','.join(list(set(dep_fields))) if dep_fields else False
rec.depends = ",".join(list(set(dep_fields))) if dep_fields else False

def confirm(self):
for rec in self:
field_name = 'x_dynamic_message_%i' % rec.id
field_name = "x_dynamic_message_%i" % rec.id
field_vals = {
'name': field_name,
'field_description': 'Dynamic Message',
'state': 'manual',
'store': False,
'ttype': 'html',
'model_id': rec.model_id.id,
'compute': rec.code,
'depends': rec.depends,
"name": field_name,
"field_description": "Dynamic Message",
"state": "manual",
"store": False,
"ttype": "html",
"model_id": rec.model_id.id,
"compute": rec.code,
"depends": rec.depends,
}
if rec.field_id:
rec.field_id.sudo().write(field_vals)
else:
rec.field_id = rec.field_id.sudo().create(field_vals)

view_vals = {
'name': 'Dynamic Message for %s' % rec.model_id.name,
'inherit_id': rec.view_to_inherit_id.id,
'model': rec.model_id.model,
'priority': 999,
'arch_db': """
"name": "Dynamic Message for %s" % rec.model_id.name,
"inherit_id": rec.view_to_inherit_id.id,
"model": rec.model_id.model,
"priority": 999,
"arch_db": """
<sheet position="before">
<div class="alert alert-%s mb-0" role="alert" invisible="not %s">
<field name="%s" nolabel="1" readonly="1"/>
</div>
</sheet>
""" % (rec.alert_type, field_name, field_name),
"""
% (rec.alert_type, field_name, field_name),
}
if rec.view_id:
rec.view_id.sudo().write(view_vals)
Expand All @@ -96,11 +102,13 @@ def confirm(self):

@api.ondelete(at_uninstall=True)
def _delete_field_and_view(self):
self.mapped('field_id').sudo().unlink()
self.mapped('view_id').sudo().unlink()
self.mapped("field_id").sudo().unlink()
self.mapped("view_id").sudo().unlink()

_sql_constraints = [
(
'unique_level_per_model', 'UNIQUE(model_id, alert_type, view_to_inherit_id)',
'Debe haber un unico registro por modelo, vista heredada y tipo de alerta')
"unique_level_per_model",
"UNIQUE(model_id, alert_type, view_to_inherit_id)",
"Debe haber un unico registro por modelo, vista heredada y tipo de alerta",
)
]
21 changes: 12 additions & 9 deletions base_dynamic_message/models/ir_model_dynamic_message_line.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
from odoo import models, fields, api
import re

from odoo import api, fields, models


class IrModelDynamicMessageLine(models.Model):
_name = 'ir.model.dynamic_message.line'
_description = 'ir.model.dynamic_message.line'
_name = "ir.model.dynamic_message.line"
_description = "ir.model.dynamic_message.line"

dynamic_message_id = fields.Many2one('ir.model.dynamic_message', required=True, ondelete='cascade')
dynamic_message_id = fields.Many2one("ir.model.dynamic_message", required=True, ondelete="cascade")
description = fields.Text()
domain = fields.Char()
message = fields.Html(required=True,)
model_name = fields.Char(related='dynamic_message_id.model_id.model')
code = fields.Text(compute='_compute_code', store=True, readonly=False)
message = fields.Html(
required=True,
)
model_name = fields.Char(related="dynamic_message_id.model_id.model")
code = fields.Text(compute="_compute_code", store=True, readonly=False)

@api.depends('message', 'domain')
@api.depends("message", "domain")
def _compute_code(self):
for rec in self:
if rec.domain:
Expand All @@ -34,7 +37,7 @@ def _compute_code(self):
rec.code = """
if rec in rec.filtered_domain(%s):
messages.append('%s')
""" % (domain, str(rec.message).replace('<p>', '').replace('</p>', ''))
""" % (domain, str(rec.message).replace("<p>", "").replace("</p>", ""))
else:
rec.code = False
# code = self.filtered_domain(self.env['account.payment.method']._get_payment_method_domain(payment_method_code))
32 changes: 15 additions & 17 deletions base_exception_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@
#
##############################################################################
{
'name': 'Base Exception UX',
'version': "16.0.1.0.0",
'category': 'Base',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'depends': [
'base_exception',
"name": "Base Exception UX",
"version": "16.0.1.0.0",
"category": "Base",
"sequence": 14,
"summary": "",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
"depends": [
"base_exception",
],
'data': [
],
'demo': [
],
'installable': False,
'auto_install': True,
'application': False,
"data": [],
"demo": [],
"installable": False,
"auto_install": True,
"application": False,
}
10 changes: 6 additions & 4 deletions base_exception_ux/models/base_exception_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ class BaseExceptionMethod(models.AbstractModel):
_inherit = "base.exception.method"

def _exception_rule_eval_context(self, rec):
time = wrap_module(__import__('time'), ['time', 'strptime', 'strftime', 'sleep', 'gmtime'])
time = wrap_module(__import__("time"), ["time", "strptime", "strftime", "sleep", "gmtime"])
eval_context = super()._exception_rule_eval_context(rec)
eval_context.update({
'time': time,
})
eval_context.update(
{
"time": time,
}
)
return eval_context
2 changes: 1 addition & 1 deletion base_report_to_print_node/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"license": "AGPL-3",
"depends": ["base_report_to_printer"],
"data": ["wizards/res_config_settings_view.xml"],
'installable': False,
"installable": False,
}
2 changes: 0 additions & 2 deletions base_report_to_print_node/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


from odoo import models


Expand Down
Loading

0 comments on commit c919999

Please sign in to comment.