[FIX] account: change move currency
Before this commit, we could not change the currency on invoice if related journal has a default currency set. opw-3226228 closes odoo/odoo#116420 X-original-commit: 7f7743470ac1309d5e047563d06362e54edb552a Signed-off-by: John Laterre (jol) <jol@odoo.com> Signed-off-by: Guillaume Vanleynseele (guva) <guva@odoo.com>
This commit is contained in:
@@ -837,7 +837,8 @@ class AccountMove(models.Model):
|
||||
def _compute_currency_id(self):
|
||||
for invoice in self:
|
||||
currency = (
|
||||
invoice.statement_line_id.foreign_currency_id
|
||||
invoice.currency_id
|
||||
or invoice.statement_line_id.foreign_currency_id
|
||||
or invoice.journal_id.currency_id
|
||||
or invoice.journal_id.company_id.currency_id
|
||||
)
|
||||
|
||||
@@ -3347,3 +3347,38 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
|
||||
self.product_a.property_account_income_id.deprecated = True
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
move.action_post()
|
||||
|
||||
def test_change_currency_id(self):
|
||||
"""
|
||||
Test that we are able to change currency on invoice,
|
||||
even when a default currency is set on journal
|
||||
"""
|
||||
self.company_data['default_journal_sale'].currency_id = self.company_data['currency']
|
||||
move = self.env['account.move'].create({
|
||||
'move_type': 'out_invoice',
|
||||
'partner_id': self.partner_a.id,
|
||||
'journal_id': self.company_data['default_journal_sale'].id,
|
||||
'invoice_line_ids': [
|
||||
Command.create({
|
||||
'name': 'My super product.',
|
||||
'quantity': 1.0,
|
||||
'price_unit': 750.0,
|
||||
'account_id': self.product_a.property_account_income_id.id,
|
||||
'tax_ids': False,
|
||||
})
|
||||
],
|
||||
})
|
||||
|
||||
self.assertEqual(move.currency_id, self.company_data['currency'])
|
||||
move.currency_id = self.currency_data['currency']
|
||||
self.assertEqual(move.currency_id, self.currency_data['currency'])
|
||||
self.assertRecordValues(move.line_ids, [
|
||||
{
|
||||
'debit': 0.0,
|
||||
'credit': self.currency_data['currency']._convert(750.0, self.company_data['currency'], self.env.company, fields.Date.today()),
|
||||
},
|
||||
{
|
||||
'debit': self.currency_data['currency']._convert(750.0, self.company_data['currency'], self.env.company, fields.Date.today()),
|
||||
'credit': 0.0,
|
||||
},
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user