[IMP] account: compute foreign amount on bank transactions
With this commit, we improve the usability of foreign bank transactions. When capturing a new bank transaction (account.bank.statement.line) - when capturing a new transaction we compute the amount currency based on the transaction date, amount in journal/company currency, and foreign currency - when the foreign currency is removed, the amount_currency is cleared Task-3338560 Task-3338532 closes odoo/odoo#122595 X-original-commit: 737c7d26c415b5a136635ef3e4d33d086961c4da Related: odoo/enterprise#41532 Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
@@ -94,6 +94,7 @@ class AccountBankStatementLine(models.Model):
|
||||
help="The optional other currency if it is a multi-currency entry.",
|
||||
)
|
||||
amount_currency = fields.Monetary(
|
||||
compute='_compute_amount_currency', store=True, readonly=False,
|
||||
string="Amount in Currency",
|
||||
currency_field='foreign_currency_id',
|
||||
help="The amount expressed in an optional other currency if it is a multi-currency entry.",
|
||||
@@ -147,6 +148,19 @@ class AccountBankStatementLine(models.Model):
|
||||
# COMPUTE METHODS
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@api.depends('foreign_currency_id', 'date', 'amount', 'company_id')
|
||||
def _compute_amount_currency(self):
|
||||
for st_line in self:
|
||||
if not st_line.foreign_currency_id or not st_line.date:
|
||||
st_line.amount_currency = False
|
||||
else:
|
||||
st_line.amount_currency = st_line.currency_id._convert(
|
||||
from_amount=st_line.amount,
|
||||
to_currency=st_line.foreign_currency_id,
|
||||
company=st_line.company_id,
|
||||
date=st_line.date,
|
||||
)
|
||||
|
||||
@api.depends('journal_id.currency_id')
|
||||
def _compute_currency_id(self):
|
||||
for st_line in self:
|
||||
|
||||
Reference in New Issue
Block a user