Fix flake8 tests for account_default_draft_move

This commit is contained in:
Nicolas Bessi
2014-07-04 18:58:25 +02:00
parent e8dd3125bf
commit 247f211b6b
4 changed files with 22 additions and 19 deletions

View File

@@ -17,7 +17,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import account
from . import account_bank_statement
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -17,10 +17,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##############################################################################
{
"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,

View File

@@ -17,37 +17,42 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##############################################################################
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

View File

@@ -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')