Skip to content
Snippets Groups Projects
Commit 60e96f41 authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

Code formatting (flake8 valid)

parent 794ab1ed
No related branches found
No related tags found
No related merge requests found
...@@ -82,9 +82,11 @@ ...@@ -82,9 +82,11 @@
# Create a field that will be used for replacement in the view # Create a field that will be used for replacement in the view
if analytic: if analytic:
nmspc['analytic_dimensions'] = fields.Char( nmspc['analytic_dimensions'] = fields.Char(
string = u"Analytic Dimensions", string=u"Analytic Dimensions",
compute = api.one(lambda self : setattr(self, 'analytic_dimensions', '')), compute=api.one(lambda self: (
readonly=True setattr(self, 'analytic_dimensions', '')
)),
readonly=True,
) )
col_pattern = '{pre}{n}_{suf}' col_pattern = '{pre}{n}_{suf}'
...@@ -247,9 +249,9 @@ ...@@ -247,9 +249,9 @@
use_inherits = dimension.get('use_inherits', None) use_inherits = dimension.get('use_inherits', None)
if use_inherits is None: if use_inherits is None:
use_inherits = not ( use_inherits = not (
any(field in nmspc for field in ('name', 'nd_id')) any(field in nmspc for field in ('name', 'nd_id')) or
or nmspc.get('_inherits', False) nmspc.get('_inherits', False) or
or nmspc.get('_inherit', False) nmspc.get('_inherit', False)
) )
use_code_name_methods = dimension.get('use_code_name_methods', False) use_code_name_methods = dimension.get('use_code_name_methods', False)
...@@ -293,8 +295,8 @@ ...@@ -293,8 +295,8 @@
for string, model_col, code_col, dtype, req, default in rel_cols: for string, model_col, code_col, dtype, req, default in rel_cols:
nmspc[model_col] = getattr(fields, dtype)( nmspc[model_col] = getattr(fields, dtype)(
string = string, string=string,
related = ".".join([column, code_col]), related=".".join([column, code_col]),
relation="analytic.code", relation="analytic.code",
required=req, required=req,
store=True store=True
...@@ -309,7 +311,6 @@ ...@@ -309,7 +311,6 @@
# Set _register to False in order to prevent its instantiation. # Set _register to False in order to prevent its instantiation.
superclass = type(superclass_name, bases, {'_register': False}) superclass = type(superclass_name, bases, {'_register': False})
# We must keep the old api here !!!!!!! # We must keep the old api here !!!!!!!
# If we switch to the new, the method is call through a wrapper # If we switch to the new, the method is call through a wrapper
# then, 'self' is a !#@*ing (!) object of the same type of __cls__ # then, 'self' is a !#@*ing (!) object of the same type of __cls__
...@@ -379,7 +380,7 @@ ...@@ -379,7 +380,7 @@
# unless the 'force_code_id' context key is passed as True. # unless the 'force_code_id' context key is passed as True.
force_code_id = vals.pop(column, False) force_code_id = vals.pop(column, False)
if context and context.get('force_code_id', False) == True: if context and context.get('force_code_id', False):
self._force_code(cr, uid, force_code_id, code_vals, context) self._force_code(cr, uid, force_code_id, code_vals, context)
vals[column] = force_code_id vals[column] = force_code_id
...@@ -434,7 +435,7 @@ ...@@ -434,7 +435,7 @@
# unless the 'force_code_id' context key is passed as True. # unless the 'force_code_id' context key is passed as True.
force_code_id = vals.pop(column, False) force_code_id = vals.pop(column, False)
if context and context.get('force_code_id', False) == True: if context and context.get('force_code_id', False):
self._force_code(cr, uid, force_code_id, code_vals, context) self._force_code(cr, uid, force_code_id, code_vals, context)
vals[column] = force_code_id vals[column] = force_code_id
...@@ -481,7 +482,7 @@ ...@@ -481,7 +482,7 @@
if not force_code_id: if not force_code_id:
raise ValueError( raise ValueError(
"An analytic code ID MUST be specified if the " \ "An analytic code ID MUST be specified if the "
"force_code_id key is enabled in the context" "force_code_id key is enabled in the context"
) )
force_code_dim = code_osv.read( force_code_dim = code_osv.read(
...@@ -489,7 +490,7 @@ ...@@ -489,7 +490,7 @@
)['nd_id'][0] )['nd_id'][0]
if force_code_dim != self._bound_dimension_id: if force_code_dim != self._bound_dimension_id:
raise ValueError( raise ValueError(
"If specified, codes must belong to the bound " \ "If specified, codes must belong to the bound "
"analytic dimension {}".format(dimension_name) "analytic dimension {}".format(dimension_name)
) )
if code_vals: if code_vals:
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# flake8: noqa
############################################################################## ##############################################################################
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
......
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
for anc in self: for anc in self:
blacklist = (company.id for company in anc.blacklist_ids) blacklist = (company.id for company in anc.blacklist_ids)
to_write = None to_write = None
if anc.disabled_per_company and company_id not in blacklist: if anc.disabled_per_company and company_id not in blacklist:
to_write = [(4, company_id)] # Link. to_write = [(4, company_id)] # Link.
elif not anc.disabled_per_company and company_id in blacklist: elif not anc.disabled_per_company and company_id in blacklist:
to_write = [(3, company_id)] # Unlink. to_write = [(3, company_id)] # Unlink.
...@@ -55,9 +55,9 @@ ...@@ -55,9 +55,9 @@
to_write = None to_write = None
if anc.disabled_per_company and company_id not in blacklist: if anc.disabled_per_company and company_id not in blacklist:
to_write = [(4, company_id)] # Link. to_write = [(4, company_id)] # Link.
elif not anc.disabled_per_company and company_id in blacklist: elif not anc.disabled_per_company and company_id in blacklist:
to_write = [(3, company_id)] # Unlink. to_write = [(3, company_id)] # Unlink.
if to_write: if to_write:
anc.write({'blacklist_ids': to_write}) anc.write({'blacklist_ids': to_write})
...@@ -91,10 +91,10 @@ ...@@ -91,10 +91,10 @@
string=u"Dimension", string=u"Dimension",
ondelete='cascade', ondelete='cascade',
required=True, required=True,
) )
active = fields.Boolean( active = fields.Boolean(
u"Active", u"Active",
help=( help=(
u"Determines whether an analytic code is in the referential." u"Determines whether an analytic code is in the referential."
), ),
...@@ -95,10 +95,10 @@ ...@@ -95,10 +95,10 @@
active = fields.Boolean( active = fields.Boolean(
u"Active", u"Active",
help=( help=(
u"Determines whether an analytic code is in the referential." u"Determines whether an analytic code is in the referential."
), ),
default = lambda *a: True default=lambda *a: True
) )
view_type = fields.Boolean( view_type = fields.Boolean(
u"View type", u"View type",
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
u"Determines whether an analytic code is not selectable (but " u"Determines whether an analytic code is not selectable (but "
u"still in the referential)." u"still in the referential)."
), ),
default = lambda *a: False default=lambda *a: False
) )
blacklist_ids = fields.Many2many( blacklist_ids = fields.Many2many(
'res.company', 'res.company',
...@@ -117,11 +117,11 @@ ...@@ -117,11 +117,11 @@
help=u"Companies the code is hidden in.", help=u"Companies the code is hidden in.",
) )
disabled_per_company = fields.Boolean( disabled_per_company = fields.Boolean(
string = u"Disable in my company", string=u"Disable in my company",
compute = _read_disabled_per_company, compute=_read_disabled_per_company,
inverse = _write_disabled_per_company, inverse=_write_disabled_per_company,
search = _search_disabled_per_company, search=_search_disabled_per_company,
help=( help=(
u"Determines whether an analytic code is disabled for the " u"Determines whether an analytic code is disabled for the "
u"current company." u"current company."
), ),
...@@ -124,8 +124,8 @@ ...@@ -124,8 +124,8 @@
help=( help=(
u"Determines whether an analytic code is disabled for the " u"Determines whether an analytic code is disabled for the "
u"current company." u"current company."
), ),
default = lambda *a: False default=lambda *a: False
) )
nd_name = fields.Char( nd_name = fields.Char(
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
) )
nd_name = fields.Char( nd_name = fields.Char(
related = 'nd_id.name', related='nd_id.name',
string=u"Dimension Name", string=u"Dimension Name",
store=False store=False
) )
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# #
############################################################################## ##############################################################################
from openerp import models, fields, api from openerp import models, fields
from openerp.addons.oemetasl import OEMetaSL from openerp.addons.oemetasl import OEMetaSL
from openerp.tools import config from openerp.tools import config
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
translate=config.get_misc('analytic', 'translate', False), translate=config.get_misc('analytic', 'translate', False),
required=True, required=True,
) )
nc_ids = fields.One2many( nc_ids = fields.One2many(
comodel_name='analytic.code', comodel_name='analytic.code',
inverse_name='nd_id', inverse_name='nd_id',
string=u"Codes") string=u"Codes")
...@@ -55,8 +55,8 @@ ...@@ -55,8 +55,8 @@
nc_ids = fields.One2many( nc_ids = fields.One2many(
comodel_name='analytic.code', comodel_name='analytic.code',
inverse_name='nd_id', inverse_name='nd_id',
string=u"Codes") string=u"Codes")
ns_id = fields.One2many( ns_id = fields.One2many(
comodel_name='analytic.structure', comodel_name='analytic.structure',
inverse_name='nd_id', inverse_name='nd_id',
......
...@@ -55,7 +55,10 @@ ...@@ -55,7 +55,10 @@
] ]
count = self.search_count(domain) count = self.search_count(domain)
if count > 1: if count > 1:
raise exceptions.ValidationError(u"One dimension per Analysis slot per object when the structure is common to all companies.") raise exceptions.ValidationError(
u"One dimension per Analysis slot per object when the "
u"structure is common to all companies."
)
model_name = fields.Char( model_name = fields.Char(
u"Object", u"Object",
...@@ -78,7 +81,7 @@ ...@@ -78,7 +81,7 @@
company_id = fields.Many2one( company_id = fields.Many2one(
'res.company', 'res.company',
u"Company", u"Company",
default = lambda *a: False default=(lambda *a: False),
) )
_sql_constraints = [ _sql_constraints = [
...@@ -256,7 +259,8 @@ ...@@ -256,7 +259,8 @@
match.set('required', 'false') match.set('required', 'false')
match.set('modifiers', json.dumps(modifiers)) match.set('modifiers', json.dumps(modifiers))
# Look for any field named 'analytic_dimensions' and with the right prefix. # Look for any field named 'analytic_dimensions' and with the right
# prefix.
name_cond = '@name="analytic_dimensions"' name_cond = '@name="analytic_dimensions"'
if prefix == 'a': if prefix == 'a':
pre_cond = '(@prefix="a" or not(@prefix))' pre_cond = '(@prefix="a" or not(@prefix))'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment