# HG changeset patch # User Houzefa Abbasbhay <houzefa.abba@xcg-consulting.fr> # Date 1454930944 -3600 # Mon Feb 08 12:29:04 2016 +0100 # Branch odoo8 # Node ID 60e96f419da8b2f238a3e81731c1bbb319a508d1 # Parent 794ab1ed229db904f3b76893dedf81ced4f9fe0e Code formatting (flake8 valid) diff --git a/MetaAnalytic.py b/MetaAnalytic.py --- a/MetaAnalytic.py +++ b/MetaAnalytic.py @@ -82,9 +82,11 @@ # Create a field that will be used for replacement in the view if analytic: nmspc['analytic_dimensions'] = fields.Char( - string = u"Analytic Dimensions", - compute = api.one(lambda self : setattr(self, 'analytic_dimensions', '')), - readonly=True + string=u"Analytic Dimensions", + compute=api.one(lambda self: ( + setattr(self, 'analytic_dimensions', '') + )), + readonly=True, ) col_pattern = '{pre}{n}_{suf}' @@ -247,9 +249,9 @@ use_inherits = dimension.get('use_inherits', None) if use_inherits is None: use_inherits = not ( - any(field in nmspc for field in ('name', 'nd_id')) - or nmspc.get('_inherits', False) - or nmspc.get('_inherit', False) + any(field in nmspc for field in ('name', 'nd_id')) or + nmspc.get('_inherits', False) or + nmspc.get('_inherit', False) ) use_code_name_methods = dimension.get('use_code_name_methods', False) @@ -293,8 +295,8 @@ for string, model_col, code_col, dtype, req, default in rel_cols: nmspc[model_col] = getattr(fields, dtype)( - string = string, - related = ".".join([column, code_col]), + string=string, + related=".".join([column, code_col]), relation="analytic.code", required=req, store=True @@ -309,7 +311,6 @@ # Set _register to False in order to prevent its instantiation. superclass = type(superclass_name, bases, {'_register': False}) - # We must keep the old api here !!!!!!! # 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__ @@ -379,7 +380,7 @@ # unless the 'force_code_id' context key is passed as True. 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) vals[column] = force_code_id @@ -434,7 +435,7 @@ # unless the 'force_code_id' context key is passed as True. 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) vals[column] = force_code_id @@ -481,7 +482,7 @@ if not force_code_id: 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_dim = code_osv.read( @@ -489,7 +490,7 @@ )['nd_id'][0] if force_code_dim != self._bound_dimension_id: raise ValueError( - "If specified, codes must belong to the bound " \ + "If specified, codes must belong to the bound " "analytic dimension {}".format(dimension_name) ) if code_vals: diff --git a/__init__.py b/__init__.py --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# flake8: noqa + ############################################################################## # # OpenERP, Open Source Management Solution diff --git a/analytic_code.py b/analytic_code.py --- a/analytic_code.py +++ b/analytic_code.py @@ -51,13 +51,13 @@ for anc in self: blacklist = (company.id for company in anc.blacklist_ids) - + to_write = None if anc.disabled_per_company and company_id not in blacklist: to_write = [(4, company_id)] # Link. elif not anc.disabled_per_company and company_id in blacklist: to_write = [(3, company_id)] # Unlink. - + if to_write: anc.write({'blacklist_ids': to_write}) @@ -91,14 +91,14 @@ string=u"Dimension", ondelete='cascade', required=True, - ) + ) active = fields.Boolean( u"Active", help=( u"Determines whether an analytic code is in the referential." ), - default = lambda *a: True + default=lambda *a: True ) view_type = fields.Boolean( u"View type", @@ -106,7 +106,7 @@ u"Determines whether an analytic code is not selectable (but " u"still in the referential)." ), - default = lambda *a: False + default=lambda *a: False ) blacklist_ids = fields.Many2many( 'res.company', @@ -117,19 +117,19 @@ help=u"Companies the code is hidden in.", ) disabled_per_company = fields.Boolean( - string = u"Disable in my company", - compute = _read_disabled_per_company, - inverse = _write_disabled_per_company, - search = _search_disabled_per_company, + string=u"Disable in my company", + compute=_read_disabled_per_company, + inverse=_write_disabled_per_company, + search=_search_disabled_per_company, help=( u"Determines whether an analytic code is disabled for the " u"current company." ), - default = lambda *a: False + default=lambda *a: False ) nd_name = fields.Char( - related = 'nd_id.name', + related='nd_id.name', string=u"Dimension Name", store=False ) diff --git a/analytic_dimension.py b/analytic_dimension.py --- a/analytic_dimension.py +++ b/analytic_dimension.py @@ -18,7 +18,7 @@ # ############################################################################## -from openerp import models, fields, api +from openerp import models, fields from openerp.addons.oemetasl import OEMetaSL from openerp.tools import config @@ -51,12 +51,12 @@ translate=config.get_misc('analytic', 'translate', False), required=True, ) - + nc_ids = fields.One2many( comodel_name='analytic.code', inverse_name='nd_id', string=u"Codes") - + ns_id = fields.One2many( comodel_name='analytic.structure', inverse_name='nd_id', diff --git a/analytic_structure.py b/analytic_structure.py --- a/analytic_structure.py +++ b/analytic_structure.py @@ -55,7 +55,10 @@ ] count = self.search_count(domain) 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( u"Object", @@ -78,7 +81,7 @@ company_id = fields.Many2one( 'res.company', u"Company", - default = lambda *a: False + default=(lambda *a: False), ) _sql_constraints = [ @@ -256,7 +259,8 @@ match.set('required', 'false') 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"' if prefix == 'a': pre_cond = '(@prefix="a" or not(@prefix))'