2

I want to change the company currency by opening Setting->Companies->Currency. But when I already change the currency and hit save button, I get this warning dialog

You cannot change the currency of the company since some journal items already exist

How to solve this problem?

NM Naufaldo
  • 1,032
  • 1
  • 12
  • 30

3 Answers3

3

You cannot change the currency of the company since some journal items already exist

  • Some data are already created with the same currency, if you do not need that entry then simply delete it and then change the currency.

reference code - Source Code

#forbid the change of currency_id if there are already some accounting entries existing
if 'currency_id' in values and values['currency_id'] != company.currency_id.id:
    if self.env['account.move.line'].search([('company_id', '=', company.id)]):
        raise UserError(_('You cannot change the currency of the company since some journal items already exist'))
CZoellner
  • 13,553
  • 3
  • 25
  • 38
Dipen Shah
  • 2,396
  • 2
  • 9
  • 21
  • Try to use permanent links to code, because it can change over time and always try to "copy" the important part of that code into your answer, because it could vanish. On Github you just have to press 'y' to get a permanent link :-) I've edited your answer already. – CZoellner Dec 27 '21 at 10:03
0

The error occurs because there was journal entries exist. You have at least 2 options if you must change the company currency:

  1. Delete all journal entries.
  2. Update all currency ID in all journal entries with new currency id directly via PostgreSQL.

Once option 1 or 2 done, then try again to change the company currency.

0

One dirty solution could be temporary change company_id of some registers using psql.

update account_journal set company_id = <temp_company_id> where company_id = <current_company_id>;
update account_move set company_id = <temp_company_id> where company_id = <current_company_id>;
update account_move_line set company_id = <temp_company_id> where company_id = <current_company_id>;

After that you can change the currency of the company. At the end you can return to the previous value of "company_id" of the modified registers.

Luis Carlos
  • 345
  • 3
  • 10