[imp] statement_cancel_line: if all lines are confirmed, confirm the statement as well

This commit is contained in:
Leonardo Pistone
2014-01-24 14:37:09 +01:00
parent 27fbae9020
commit 47e4dcb8f8
3 changed files with 50 additions and 15 deletions

View File

@@ -33,12 +33,6 @@ class Statement(orm.Model):
_inherit = "account.bank.statement"
_columns = {
}
_defaults = {
}
def button_confirm_bank(self, cr, uid, ids, context=None):
"""Change the state on the statement lines. Return super."""
st_line_obj = self.pool['account.bank.statement.line']
@@ -60,3 +54,18 @@ class Statement(orm.Model):
return super(Statement, self).button_cancel(
cr, uid, ids, context)
def confirm_statement_from_lines(self, cr, uid, ids, context=None):
"""If all lines are confirmed, so is the whole statement.
Return True if we changed anything.
"""
need_to_update_view = False
for statement in self.browse(cr, uid, ids, context=context):
if all(line.state == 'confirmed' for line in statement.line_ids):
self.write(cr, uid, [statement.id], {
'state': 'confirm'
}, context=context)
need_to_update_view = True
return need_to_update_view