From 247f211b6b42eb841e18c12df1852eead12d025b Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Fri, 4 Jul 2014 18:58:25 +0200 Subject: [PATCH] Fix flake8 tests for account_default_draft_move --- account_default_draft_move/__init__.py | 2 -- account_default_draft_move/__openerp__.py | 10 ++++----- account_default_draft_move/account.py | 21 ++++++++++++------- .../account_bank_statement.py | 8 +++---- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/account_default_draft_move/__init__.py b/account_default_draft_move/__init__.py index 57bf09648..3593dc32f 100644 --- a/account_default_draft_move/__init__.py +++ b/account_default_draft_move/__init__.py @@ -17,7 +17,5 @@ # along with this program. If not, see . # ############################################################################## - from . import account from . import account_bank_statement -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/account_default_draft_move/__openerp__.py b/account_default_draft_move/__openerp__.py index 572f36aee..d919e8507 100644 --- a/account_default_draft_move/__openerp__.py +++ b/account_default_draft_move/__openerp__.py @@ -17,10 +17,10 @@ # along with this program. If not, see . ############################################################################## { - "name" : "Move in draft state by default", - "version" : "1.0", - "depends" : ["base", "account", "account_constraints"], - "author" : "Camptocamp", + "name": "Move in draft state by default", + "version": "1.0", + "depends": ["base", "account", "account_constraints"], + "author": "Camptocamp", 'license': 'AGPL-3', "description": """ Let the generated move in draft on invoice and bank statement @@ -48,7 +48,7 @@ need to make a refund). """, 'website': 'http://www.camptocamp.com', - 'data' : ['account_view.xml', + 'data': ['account_view.xml', 'invoice_view.xml'], 'installable': True, 'active': False, diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index 8a2ee98fb..8c3201224 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -17,37 +17,42 @@ # along with this program. If not, see . ############################################################################## -from openerp.osv import fields, orm, osv +from openerp.osv import orm, osv from tools.translate import _ class AccountInvoice(orm.Model): _inherit = 'account.invoice' - + def action_move_create(self, cr, uid, ids, context=None): """Set move line in draft state after creating them.""" - res = super(AccountInvoice,self).action_move_create(cr, uid, ids, context=context) + res = super(AccountInvoice, self).action_move_create(cr, uid, ids, context=context) move_obj = self.pool.get('account.move') for inv in self.browse(cr, uid, ids, context=context): if inv.move_id: move_obj.write(cr, uid, [inv.move_id.id], {'state': 'draft'}, context=context) return res + class AccountMove(orm.Model): _inherit = 'account.move' - + def button_cancel(self, cr, uid, ids, context=None): """ We rewrite function button_cancel, to allow invoice or bank statement with linked draft moved to be canceled """ for line in self.browse(cr, uid, ids, context=context): if line.state == 'draft': - continue + continue else: if not line.journal_id.update_posted: - raise osv.except_osv(_('Error!'), _('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.')) + raise osv.except_osv( + _('Error!'), + _('You cannot modify a posted entry of this journal.' + 'First you should set the journal to allow cancelling entries.') + ) if ids: - cr.execute('UPDATE account_move '\ - 'SET state=%s '\ + cr.execute('UPDATE account_move ' + 'SET state=%s ' 'WHERE id IN %s', ('draft', tuple(ids),)) return True diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py index 52aed19d5..f1b822f65 100644 --- a/account_default_draft_move/account_bank_statement.py +++ b/account_default_draft_move/account_bank_statement.py @@ -18,7 +18,6 @@ ############################################################################## from openerp.osv import orm -from openerp.tools.translate import _ class AccountBankStatement(orm.Model): @@ -26,9 +25,10 @@ class AccountBankStatement(orm.Model): def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): - move_ids = super(AccountBankStatement,self).create_move_from_st_line( - cr, uid, st_line_id, company_currency_id, - st_line_number, context) + move_ids = super(AccountBankStatement, self).create_move_from_st_line( + cr, uid, st_line_id, company_currency_id, + st_line_number, context + ) # If a bank statement line is already linked to a voucher # we received boolean instead of voucher move ids in move_ids bank_st_line_obj = self.pool.get('account.bank.statement.line')