From 15d408c00943d380eb808d92c85f74275ec517c9 Mon Sep 17 00:00:00 2001 From: moylop260 Date: Thu, 13 Nov 2014 21:10:42 -0600 Subject: [PATCH] [REF] auto-fix conventions --- .../__init__.py | 2 +- .../account_analytic_analysis_recurring.py | 14 +++---- analytic_hours_block/__init__.py | 8 ++-- analytic_hours_block/__openerp__.py | 4 +- analytic_hours_block/hours_block.py | 37 ++++++++++--------- analytic_hours_block/project.py | 19 ++++++---- analytic_hours_block/report/__init__.py | 2 +- analytic_hours_block/report/hours_block.py | 4 +- project_sla/__init__.py | 8 ++-- project_sla/analytic_account.py | 3 +- project_sla/project_issue.py | 1 + project_sla/project_sla.py | 10 +++-- project_sla/project_sla_control.py | 8 ++-- 13 files changed, 67 insertions(+), 53 deletions(-) diff --git a/account_analytic_analysis_recurring/__init__.py b/account_analytic_analysis_recurring/__init__.py index 7088b5aa..41ecc2ad 100644 --- a/account_analytic_analysis_recurring/__init__.py +++ b/account_analytic_analysis_recurring/__init__.py @@ -19,4 +19,4 @@ # ############################################################################## -import account_analytic_analysis_recurring +from . import account_analytic_analysis_recurring diff --git a/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py b/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py index f6f0d71e..6464c7c6 100644 --- a/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py +++ b/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py @@ -93,7 +93,7 @@ class account_analytic_invoice_line(osv.osv): 'uom_id': uom_id or res.uom_id.id or False, 'price_unit': res.list_price or 0.0}) if res.description: - result['name'] += '\n'+res.description + result['name'] += '\n' + res.description res_final = {'value': result} if result['uom_id'] != res.uom_id.id: @@ -237,14 +237,14 @@ class account_analytic_account(osv.osv): contract.recurring_next_date or current_date, "%Y-%m-%d") interval = contract.recurring_interval if contract.recurring_rule_type == 'daily': - old_date = next_date-relativedelta(days=+interval) - new_date = next_date+relativedelta(days=+interval) + old_date = next_date - relativedelta(days=+interval) + new_date = next_date + relativedelta(days=+interval) elif contract.recurring_rule_type == 'weekly': - old_date = next_date-relativedelta(weeks=+interval) - new_date = next_date+relativedelta(weeks=+interval) + old_date = next_date - relativedelta(weeks=+interval) + new_date = next_date + relativedelta(weeks=+interval) else: - old_date = next_date+relativedelta(months=+interval) - new_date = next_date+relativedelta(months=+interval) + old_date = next_date + relativedelta(months=+interval) + new_date = next_date + relativedelta(months=+interval) context['old_date'] = old_date context['next_date'] = datetime.datetime.strptime( diff --git a/analytic_hours_block/__init__.py b/analytic_hours_block/__init__.py index 81ba8d05..8f227222 100644 --- a/analytic_hours_block/__init__.py +++ b/analytic_hours_block/__init__.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## -import hours_block -import report -import product -import project +from . import hours_block +from . import report +from . import product +from . import project diff --git a/analytic_hours_block/__openerp__.py b/analytic_hours_block/__openerp__.py index 6dc08a38..29a0c7cc 100644 --- a/analytic_hours_block/__openerp__.py +++ b/analytic_hours_block/__openerp__.py @@ -42,7 +42,7 @@ you can track and follow how much has been used. "hr_timesheet_invoice", "analytic", "project", - ], + ], "data": [ "report.xml", "hours_block_view.xml", @@ -53,7 +53,7 @@ you can track and follow how much has been used. "report.xml", "security/hours_block_security.xml", "security/ir.model.access.csv", - ], + ], "active": False, "installable": True } diff --git a/analytic_hours_block/hours_block.py b/analytic_hours_block/hours_block.py index e29c5a6b..c31569a9 100644 --- a/analytic_hours_block/hours_block.py +++ b/analytic_hours_block/hours_block.py @@ -94,7 +94,7 @@ class AccountHoursBlock(orm.Model): for line in block.invoice_id.invoice_line: amount_bought = 0.0 if line.product_id: - ## We will now calculate the product_quantity + # We will now calculate the product_quantity factor = line.uos_id.factor if factor == 0.0: factor = 1.0 @@ -103,7 +103,8 @@ class AccountHoursBlock(orm.Model): result[block.id]['amount_hours_block'] += amount_bought # Compute total amount - # Get ids of analytic line generated from timesheet associated to current block + # Get ids of analytic line generated from timesheet associated to + # current block cr.execute("SELECT al.id FROM account_analytic_line AS al," " account_analytic_journal AS aj" " WHERE aj.id = al.journal_id" @@ -119,12 +120,12 @@ class AccountHoursBlock(orm.Model): ctx = dict(context, uom=line.product_uom_id.id) amount = pricelist_obj.price_get( - cr, uid, - [line.account_id.pricelist_id.id], - line.product_id.id, - line.unit_amount or 1.0, - line.account_id.partner_id.id or False, - ctx)[line.account_id.pricelist_id.id] + cr, uid, + [line.account_id.pricelist_id.id], + line.product_id.id, + line.unit_amount or 1.0, + line.account_id.partner_id.id or False, + ctx)[line.account_id.pricelist_id.id] total_amount += amount * line.unit_amount * factor_invoicing result[block.id]['amount_hours_block_done'] += total_amount @@ -139,7 +140,8 @@ class AccountHoursBlock(orm.Model): for block_type in block_per_types: if block_type: func = getattr(self, "_compute_%s" % block_type) - result.update(func(cr, uid, ids, fields, args, context=context)) + result.update( + func(cr, uid, ids, fields, args, context=context)) for block in result: result[block]['amount_hours_block_delta'] = \ @@ -155,13 +157,14 @@ class AccountHoursBlock(orm.Model): if line.invoice_id: invoice_ids.append(line.invoice_id.id) return block_obj.search( - cr, uid, [('invoice_id', 'in', invoice_ids)], context=context) + cr, uid, [('invoice_id', 'in', invoice_ids)], context=context) def _get_invoice(self, cr, uid, ids, context=None): block_ids = set() inv_obj = self.pool.get('account.invoice') for invoice in inv_obj.browse(cr, uid, ids, context=context): - block_ids.update([inv.id for inv in invoice.account_hours_block_ids]) + block_ids.update( + [inv.id for inv in invoice.account_hours_block_ids]) return list(block_ids) def action_send_block(self, cr, uid, ids, context=None): @@ -206,7 +209,7 @@ class AccountHoursBlock(orm.Model): _recompute_triggers = { 'account.hours.block': (lambda self, cr, uid, ids, c=None: - ids, ['invoice_id', 'type'], 10), + ids, ['invoice_id', 'type'], 10), 'account.invoice': (_get_invoice, ['analytic_line_ids'], 10), 'account.analytic.line': ( _get_analytic_line, @@ -381,15 +384,15 @@ class AccountHoursBlock(orm.Model): readonly=True), 'department_id': fields.related( 'invoice_id', 'department_id', - type='many2one', - relation='hr.department', - string='Department', + type='many2one', + relation='hr.department', + string='Department', store={ 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, ['invoice_id'], 10), 'account.invoice': (_get_invoice, ['department_id'], 10), }, - readonly=True), + readonly=True), 'state': fields.related( 'invoice_id', 'state', @@ -413,7 +416,7 @@ class AccountHoursBlock(orm.Model): ############################################################################ -## Add hours blocks on invoice +# Add hours blocks on invoice ############################################################################ class AccountInvoice(orm.Model): _inherit = 'account.invoice' diff --git a/analytic_hours_block/project.py b/analytic_hours_block/project.py index 8c014ca5..67f2e758 100644 --- a/analytic_hours_block/project.py +++ b/analytic_hours_block/project.py @@ -9,18 +9,21 @@ class project_project(orm.Model): def hours_block_tree_view(self, cr, uid, ids, context): invoice_line_obj = self.pool.get('account.invoice.line') hours_block_obj = self.pool.get('account.hours.block') - project = self.browse(cr, uid , ids)[0] - invoice_line_ids = invoice_line_obj.search(cr, uid, [('account_analytic_id', '=', project.analytic_account_id.id)]) - invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids) + project = self.browse(cr, uid, ids)[0] + invoice_line_ids = invoice_line_obj.search( + cr, uid, [('account_analytic_id', '=', project.analytic_account_id.id)]) + invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids) invoice_ids = [x.invoice_id.id for x in invoice_lines] - res_ids = hours_block_obj.search(cr, uid, [('invoice_id','in',invoice_ids)]) - domain=False + res_ids = hours_block_obj.search( + cr, uid, [('invoice_id', 'in', invoice_ids)]) + domain = False if res_ids: domain = [('id', 'in', res_ids)] else: - raise orm.except_orm(_('Warning'), _("No Hours Block for this project")) + raise orm.except_orm( + _('Warning'), _("No Hours Block for this project")) - return { + return { 'name': _('Hours Blocks'), 'domain': domain, 'res_model': 'account.hours.block', @@ -29,5 +32,5 @@ class project_project(orm.Model): 'view_mode': 'tree,form', 'view_type': 'form', 'limit': 80, - 'res_id' : res_ids or False, + 'res_id': res_ids or False, } diff --git a/analytic_hours_block/report/__init__.py b/analytic_hours_block/report/__init__.py index 111d0eb4..91d0e5aa 100644 --- a/analytic_hours_block/report/__init__.py +++ b/analytic_hours_block/report/__init__.py @@ -18,4 +18,4 @@ # along with this program. If not, see . # ############################################################################## -import hours_block +from . import hours_block diff --git a/analytic_hours_block/report/hours_block.py b/analytic_hours_block/report/hours_block.py index 02045eea..6a5a945b 100644 --- a/analytic_hours_block/report/hours_block.py +++ b/analytic_hours_block/report/hours_block.py @@ -25,8 +25,10 @@ from openerp.tools import DEFAULT_SERVER_DATE_FORMAT class account_hours_block(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context=None): - super(account_hours_block, self).__init__(cr, uid, name, context=context) + super(account_hours_block, self).__init__( + cr, uid, name, context=context) self.localcontext.update({'time': time, 'date_format': DEFAULT_SERVER_DATE_FORMAT, 'analytic_lines': self._get_analytic_lines, diff --git a/project_sla/__init__.py b/project_sla/__init__.py index 9ea8fe78..3f5d438f 100644 --- a/project_sla/__init__.py +++ b/project_sla/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -import project_sla -import analytic_account -import project_sla_control -import project_issue +from . import project_sla +from . import analytic_account +from . import project_sla_control +from . import project_issue diff --git a/project_sla/analytic_account.py b/project_sla/analytic_account.py index fcfbb13f..44d95a4a 100644 --- a/project_sla/analytic_account.py +++ b/project_sla/analytic_account.py @@ -22,12 +22,13 @@ from openerp.osv import fields, orm class AnalyticAccount(orm.Model): + """ Add SLA to Analytic Accounts """ _inherit = 'account.analytic.account' _columns = { 'sla_ids': fields.many2many( 'project.sla', string='Service Level Agreement'), - } + } def _reapply_sla(self, cr, uid, ids, recalc_closed=False, context=None): """ diff --git a/project_sla/project_issue.py b/project_sla/project_issue.py index 9800f47a..fd657158 100644 --- a/project_sla/project_issue.py +++ b/project_sla/project_issue.py @@ -22,6 +22,7 @@ from openerp.osv import orm class ProjectIssue(orm.Model): + """ Extend Project Issues to be SLA Controlled """ diff --git a/project_sla/project_sla.py b/project_sla/project_sla.py index 78978bb3..f812986a 100644 --- a/project_sla/project_sla.py +++ b/project_sla/project_sla.py @@ -22,6 +22,7 @@ from openerp.osv import fields, orm class SLADefinition(orm.Model): + """ SLA Definition """ @@ -40,10 +41,10 @@ class SLADefinition(orm.Model): 'project.sla.line', 'sla_id', 'Definitions'), 'analytic_ids': fields.many2many( 'account.analytic.account', string='Contracts'), - } + } _defaults = { 'active': True, - } + } def _reapply_slas(self, cr, uid, ids, recalc_closed=False, context=None): """ @@ -64,6 +65,7 @@ class SLADefinition(orm.Model): class SLARules(orm.Model): + """ SLA Definition Rule Lines """ @@ -80,7 +82,7 @@ class SLARules(orm.Model): "either o, obj or object. Example: obj.priority <= '2'"), 'limit_qty': fields.integer('Hours to Limit'), 'warn_qty': fields.integer('Hours to Warn'), - } + } _defaults = { 'sequence': 10, - } + } diff --git a/project_sla/project_sla_control.py b/project_sla/project_sla_control.py index d807a36b..613978c7 100644 --- a/project_sla/project_sla_control.py +++ b/project_sla/project_sla_control.py @@ -24,7 +24,7 @@ from openerp.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT as DT_FMT from openerp import SUPERUSER_ID from datetime import timedelta from datetime import datetime as dt -import m2m +from . import m2m import logging _logger = logging.getLogger(__name__) @@ -56,6 +56,7 @@ def safe_getattr(obj, dotattr, default=False): class SLAControl(orm.Model): + """ SLA Control Registry Each controlled document (Issue, Claim, ...) will have a record here. @@ -80,7 +81,7 @@ class SLAControl(orm.Model): help="Safeguard manual changes from future automatic " "recomputations."), # Future: perfect SLA manual handling - } + } def write(self, cr, uid, ids, vals, context=None): """ @@ -285,6 +286,7 @@ class SLAControl(orm.Model): class SLAControlled(orm.AbstractModel): + """ SLA Controlled documents: AbstractModel to apply SLA control on Models """ @@ -295,7 +297,7 @@ class SLAControlled(orm.AbstractModel): 'project.sla.control', string="SLA Control", ondelete='cascade'), 'sla_state': fields.selection( SLA_STATES, string="SLA Status", readonly=True), - } + } def create(self, cr, uid, vals, context=None): res = super(SLAControlled, self).create(cr, uid, vals, context=context)