[FIX] account: bill date rather than accounting

We should always use `invoice_date` instead of the `date` of the move for currency exchange.
Re-adding some of the changes from odoo/odoo#87984

task-2807136

closes odoo/odoo#106367

X-original-commit: 76a640d05a350840bdde1c88bd052251aabd6b12
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
aliya
2022-11-23 21:56:04 +01:00
parent 4fe0ce8460
commit 97c1fbc18b
3 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -1462,7 +1462,7 @@ class AccountMove(models.Model):
to_write = []
amount_currency = abs(move.amount_total)
balance = move.currency_id._convert(amount_currency, move.company_currency_id, move.company_id, move.date)
balance = move.currency_id._convert(amount_currency, move.company_currency_id, move.company_id, move.invoice_date or move.date)
for line in move.line_ids:
if not line.currency_id.is_zero(balance - abs(line.balance)):
@@ -1788,7 +1788,7 @@ class AccountMove(models.Model):
diff_amount_currency = diff_balance = difference
else:
diff_amount_currency = difference
diff_balance = self.currency_id._convert(diff_amount_currency, self.company_id.currency_id, self.company_id, self.date)
diff_balance = self.currency_id._convert(diff_amount_currency, self.company_id.currency_id, self.company_id, self.invoice_date or self.date)
return diff_balance, diff_amount_currency
def _apply_cash_rounding(self, diff_balance, diff_amount_currency, cash_rounding_line):
+1 -1
View File
@@ -631,7 +631,7 @@ class AccountMoveLine(models.Model):
from_currency=line.company_currency_id,
to_currency=line.currency_id,
company=line.company_id,
date=line.move_id.date or fields.Date.context_today(line),
date=line.move_id.invoice_date or line.move_id.date or fields.Date.context_today(line),
)
@api.depends('currency_id', 'company_currency_id')
@@ -2327,9 +2327,9 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
{
**self.tax_line_vals_1,
'currency_id': self.currency_data['currency'].id,
'amount_currency': -180.0,
'amount_currency': -200.0,
'debit': 0.0,
'credit': 90.0,
'credit': 100.0,
},
{
**self.tax_line_vals_2,
@@ -2342,8 +2342,8 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
**self.term_line_vals_1,
'name': move.name,
'currency_id': self.currency_data['currency'].id,
'amount_currency': 1410.0,
'debit': 705.0,
'amount_currency': 1430.0,
'debit': 715.0,
'credit': 0.0,
'date_maturity': fields.Date.from_string('2017-01-15'),
},
@@ -2353,8 +2353,8 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
'currency_id': self.currency_data['currency'].id,
'date': fields.Date.from_string('2017-01-15'),
'amount_untaxed': 1200.0,
'amount_tax': 210.0,
'amount_total': 1410.0,
'amount_tax': 230.0,
'amount_total': 1430.0,
})
def test_out_invoice_switch_out_refund_1(self):