Skip to content

Commit

Permalink
[CLEAN] flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
isabellerichard committed Mar 5, 2021
1 parent bf4ad53 commit 41f967d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 19 deletions.
19 changes: 14 additions & 5 deletions smile_anonymization/models/ir_model_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class Base(models.AbstractModel):
_inherit = 'base'

def _valid_field_parameter(self, field, name):
return name == 'data_mask' or super()._valid_field_parameter(field, name)
return name == 'data_mask' or super()._valid_field_parameter(
field, name)


class IrModelFields(models.Model):
Expand All @@ -57,7 +58,8 @@ def _format(string):
% unsafe_keyword)

def _reflect_field_params(self, field, model_id):
vals = super(IrModelFields, self)._reflect_field_params(field, model_id)
vals = super(IrModelFields, self)._reflect_field_params(
field, model_id)
vals['data_mask'] = getattr(field, 'data_mask', None)
return vals

Expand Down Expand Up @@ -99,13 +101,20 @@ def _get_anonymization_query(self):
if field.data_mask:
if self.env[field.model]._table not in data.keys():
data[self.env[field.model]._table] = [
"UPDATE %s SET %s = %s" % (self.env[field.model]._table, field.name, field.data_mask)]
"UPDATE %s SET %s = %s" % (
self.env[field.model]._table,
field.name, field.data_mask
)]
else:
if 'where'.lower() in field.data_mask.lower():
data[self.env[field.model]._table].append(
"UPDATE %s SET %s = %s" % (self.env[field.model]._table, field.name, field.data_mask))
"UPDATE %s SET %s = %s" % (
self.env[field.model]._table,
field.name, field.data_mask
))
else:
data[self.env[field.model]._table][0] += ",%s = %s" % (field.name, field.data_mask)
data[self.env[field.model]._table][0] += ",%s = %s" % (
field.name, field.data_mask)
for val in data.values():
query += ";\n".join(val) + ";\n"
return query
2 changes: 1 addition & 1 deletion smile_base/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Base(models.AbstractModel):
def _validate_fields(self, fields_to_validate, excluded_names=()):
if not self._context.get('no_validate'):
try:
super(Base, self)._validate_fields(fields_to_validate, excluded_names)
super()._validate_fields(fields_to_validate, excluded_names)
except ValidationError as e:
name = e.name.replace(
"%s\n\n" % _("Error while validating constraint"), ""). \
Expand Down
2 changes: 1 addition & 1 deletion smile_base/models/mail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def render_template(self, template_txt, model, res_ids,

# try to load the template
try:
mako_env = jinja_safe_template_env if self.env.context.get('safe') \
mako_env = jinja_safe_template_env if self._context.get('safe') \
else jinja_template_env
template = mako_env.from_string(tools.ustr(template_txt))
except Exception:
Expand Down
10 changes: 6 additions & 4 deletions smile_confirmation/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ def get_message_informations(self, values=False):
- In create self is empty
- In write self is not empty contains current ID
:param values:
- In create dictionary contains all recording information self is False
- In create dictionary contains all recording
information self is False
- In write we find only values changed
:type values: dict
:return: return dict object popup.message (self.env['popup.message'].read())
:return: return dict object popup.message
(self.env['popup.message'].read())
"""
return False

def execute_processing(self, values=False):
"""
This function gives us the possibility to execute a specific treatment after
the confirmation of the message.
This function gives us the possibility to execute a
specific treatment after the confirmation of the message
- In create self is empty
- In write self is not empty contains current ID
:param values : a list of dictionaries:
Expand Down
12 changes: 8 additions & 4 deletions smile_confirmation/models/popup_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ class PopupMessage(models.Model):
_rec_name = 'title'
_description = 'Popup message'

model_id = fields.Many2one(comodel_name='ir.model', string='Model', required=True, ondelete='cascade')
model_id = fields.Many2one(
comodel_name='ir.model', string='Model', required=True,
ondelete='cascade')
model = fields.Char(related='model_id.model')
field_ids = fields.Many2many(comodel_name='ir.model.fields', required=True, string='Fields')
field_ids = fields.Many2many(
comodel_name='ir.model.fields', required=True, string='Fields')
field_name = fields.Char(compute='_compute_field_name')
popup_type = fields.Selection(string='Type', required=True, default='confirm',
selection=[('confirm', 'Confirmation'), ('alert', 'Alert')])
popup_type = fields.Selection(
string='Type', required=True, default='confirm',
selection=[('confirm', 'Confirmation'), ('alert', 'Alert')])
title = fields.Char(string='Title')
message = fields.Text(string='Message', required=True)
active = fields.Boolean(string='Active', default=True)
Expand Down
2 changes: 1 addition & 1 deletion smile_filtered_from_domain/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from six import string_types
import time

from odoo import api, _
from odoo import _
from odoo.exceptions import UserError
from odoo.models import BaseModel
from odoo.osv.expression import normalize_domain
Expand Down
9 changes: 6 additions & 3 deletions smile_talend_job/models/talend_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ def _get_job_version(self):
if record.archive:
with record._get_zipfile() as zf:
filename = 'jobInfo.properties'
# INFO: can't use configparser because this file has no section
# INFO: can't use configparser because this file
# has no section
with zf.open(filename) as f:
reader = csv.reader(
codecs.iterdecode(f.readlines(), 'utf-8'),
delimiter='=', escapechar='\\', quoting=csv.QUOTE_NONE)
delimiter='=', escapechar='\\',
quoting=csv.QUOTE_NONE)
for row in reader:
if row[0] == 'jobVersion':
record.version = row[1]
else:
record.version = max(
record._get_all_children().filtered('version').mapped('version'),
record._get_all_children().filtered(
'version').mapped('version'),
default='')

def _get_all_children(self):
Expand Down

0 comments on commit 41f967d

Please sign in to comment.