[FIX] account: Wrong "amount_currency" in account move line after reconciliation
Use case: -enable multi currency (use UDS as company currency and EUR as secondary currency) -create account account in a different currency (EUR) -create journal for the bank account in EUR -create a new tax included tax -create a new bank statement in EUR journal and add one line -reconcile -Choose a counterpart with the included tax and click on reconcile Before the fix: After reconciliation the amount_currency for tax and expense were wrong. You could check this in the journal items linked to the bank statement. Video:https://youtu.be/678rFb4OE2Q opw:680693
This commit is contained in:
@@ -1057,13 +1057,13 @@ class AccountMoveLine(models.Model):
|
||||
if vals['debit'] != 0.0: vals['debit'] = res['total_excluded']
|
||||
if vals['credit'] != 0.0: vals['credit'] = -res['total_excluded']
|
||||
if vals.get('amount_currency'):
|
||||
vals['amount_currency'] = self.env['res.currency'].browse(vals['currency_id']).round(vals['amount_currency'] * (amount / res['total_excluded']))
|
||||
vals['amount_currency'] = self.env['res.currency'].browse(vals['currency_id']).round(vals['amount_currency'] * (res['total_excluded']/amount))
|
||||
# Create tax lines
|
||||
for tax_vals in res['taxes']:
|
||||
if tax_vals['amount']:
|
||||
account_id = (amount > 0 and tax_vals['account_id'] or tax_vals['refund_account_id'])
|
||||
if not account_id: account_id = vals['account_id']
|
||||
tax_lines_vals.append({
|
||||
temp = {
|
||||
'account_id': account_id,
|
||||
'name': vals['name'] + ' ' + tax_vals['name'],
|
||||
'tax_line_id': tax_vals['id'],
|
||||
@@ -1072,7 +1072,12 @@ class AccountMoveLine(models.Model):
|
||||
'statement_id': vals.get('statement_id'),
|
||||
'debit': tax_vals['amount'] > 0 and tax_vals['amount'] or 0.0,
|
||||
'credit': tax_vals['amount'] < 0 and -tax_vals['amount'] or 0.0,
|
||||
})
|
||||
}
|
||||
bank = self.env["account.bank.statement"].browse(vals.get('statement_id'))
|
||||
if bank.currency_id != bank.company_id.currency_id:
|
||||
temp['currency_id'] = bank.currency_id.id
|
||||
temp['amount_currency'] = bank.company_id.currency_id.compute(tax_vals['amount'], bank.currency_id, round=True)
|
||||
tax_lines_vals.append(temp)
|
||||
|
||||
new_line = super(AccountMoveLine, self).create(vals)
|
||||
for tax_line_vals in tax_lines_vals:
|
||||
|
||||
Reference in New Issue
Block a user