[FIX] account, purchase: stacktrace when no currency is selected
The tax totals computation requires a currency to be provided. When a user removes the currency deliberately and tries to add a line, an uncaught error is thrown. The currency_id is required, and the user will not be able to save the move anyway. To reproduce: New Invoice or Purchase Clear the currency field Add a line Stack Trace After this PR: tax totals are computed based on the journal currency or company currency when not available No task, discovered thanks to #110920 closes odoo/odoo#111021 X-original-commit: f74f9bc04ed8f18746eb509f3c8dc598b1618230 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -1133,7 +1133,7 @@ class AccountMove(models.Model):
|
||||
|
||||
kwargs = {
|
||||
'base_lines': base_line_values_list,
|
||||
'currency': move.currency_id,
|
||||
'currency': move.currency_id or move.journal_id.currency_id or move.journal_id.company_id.currency_id,
|
||||
}
|
||||
|
||||
if move.id:
|
||||
|
||||
@@ -194,7 +194,7 @@ class PurchaseOrder(models.Model):
|
||||
order_lines = order.order_line.filtered(lambda x: not x.display_type)
|
||||
order.tax_totals = self.env['account.tax']._prepare_tax_totals(
|
||||
[x._convert_to_tax_base_line_dict() for x in order_lines],
|
||||
order.currency_id,
|
||||
order.currency_id or order.company_id.currency_id,
|
||||
)
|
||||
|
||||
@api.depends('company_id.account_fiscal_country_id', 'fiscal_position_id.country_id', 'fiscal_position_id.foreign_vat')
|
||||
|
||||
Reference in New Issue
Block a user