[RFR] Don't repeat assignment within loop

This commit is contained in:
Stefan Rijnhart
2013-10-06 20:55:54 +02:00
parent 74b96a834b
commit 1eec20504c

View File

@@ -66,11 +66,6 @@ class AccountBankStatement(orm.Model):
update_move_line['tax_code_id'] = tax['base_code_id'] update_move_line['tax_code_id'] = tax['base_code_id']
update_move_line['tax_amount'] = tax['base_sign'] * ( update_move_line['tax_amount'] = tax['base_sign'] * (
computed_taxes.get('total', 0.0)) computed_taxes.get('total', 0.0))
# As the tax is inclusive, we need to correct the amount on the
# original move line
amount = computed_taxes.get('total', 0.0)
update_move_line['credit'] = ((amount < 0) and -amount) or 0.0
update_move_line['debit'] = ((amount > 0) and amount) or 0.0
move_lines.append({ move_lines.append({
'move_id': defaults['move_id'], 'move_id': defaults['move_id'],
@@ -87,6 +82,13 @@ class AccountBankStatement(orm.Model):
'account_id': tax.get('account_collected_id', defaults['account_id']), 'account_id': tax.get('account_collected_id', defaults['account_id']),
}) })
if move_lines:
# As the tax is inclusive, we need to correct the amount on the
# original move line
amount = computed_taxes.get('total', 0.0)
update_move_line['credit'] = ((amount < 0) and -amount) or 0.0
update_move_line['debit'] = ((amount > 0) and amount) or 0.0
return move_lines, update_move_line return move_lines, update_move_line
def _prepare_bank_move_line( def _prepare_bank_move_line(