frappe.exceptions.ValidationError: Currency can not be changed after making entries using some other currency

After pulling new code manually from git into ~/frappe-bench/apps/myapp, I tried to run migrate which failed with the following error. I have not touched anything related to currency in my code or during my setup except during the first time wizard when I set it to INR.

 $ bench --site testsite migrate                                        
Migrating user-dev                                                                                                                   
Updating DocTypes for frappe        : [========================================]                                                           
Updating DocTypes for erpnext       : [========================================]                                                           
Updating DocTypes for myapp         : [========================================]                                                           
Traceback (most recent call last):                                   
  File "/usr/lib/python3.8/", line 193, in _run_module_as_main                                                                     
    return _run_code(code, main_globals, None,                                                                                                                                                                                                                                         
  File "/usr/lib/python3.8/", line 86, in _run_code                                                                                
    exec(code, run_globals)                                          
  File "/home/user/frappe-bench/apps/frappe/frappe/utils/", line 97, in <module>                                      
  File "/home/user/frappe-bench/apps/frappe/frappe/utils/", line 18, in main                                          
  File "/home/user/frappe-bench/env/lib/python3.8/site-packages/click/", line 764, in __call__                                
    return self.main(*args, **kwargs)                                                                                                      
  File "/home/user/frappe-bench/env/lib/python3.8/site-packages/click/", line 717, in main                                    
    rv = self.invoke(ctx)                                                                                                                  
  File "/home/user/frappe-bench/env/lib/python3.8/site-packages/click/", line 1137, in invoke                                 
    return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                
  File "/home/user/frappe-bench/env/lib/python3.8/site-packages/click/", line 1137, in invoke    
    return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                
  File "/home/user/frappe-bench/env/lib/python3.8/site-packages/click/", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)                                                                                         
  File "/home/user/frappe-bench/env/lib/python3.8/site-packages/click/", line 555, in invoke
    return callback(*args, **kwargs)                                 
  File "/home/user/frappe-bench/env/lib/python3.8/site-packages/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)                                                                                       
  File "/home/user/frappe-bench/apps/frappe/frappe/commands/", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)                                                                                        
  File "/home/user/frappe-bench/apps/frappe/frappe/commands/", line 239, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)                                                   
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 52, in migrate                                                  
  File "/home/user/frappe-bench/apps/frappe/frappe/utils/", line 23, in sync_fixtures
    import_doc(frappe.get_app_path(app, "fixtures", fname),                                                                                
  File "/home/user/frappe-bench/apps/frappe/frappe/core/doctype/data_import/", line 60, in import_doc
    frappe.modules.import_file.import_file_by_path(f, data_import=True, force=True, pre_process=pre_process, reset_permissions=True)
  File "/home/user/frappe-bench/apps/frappe/frappe/modules/", line 65, in import_file_by_path
    import_doc(doc, force=force, data_import=data_import, pre_process=pre_process,                                                         
  File "/home/user/frappe-bench/apps/frappe/frappe/modules/", line 141, in import_doc
  File "/home/user/frappe-bench/apps/frappe/frappe/model/", line 230, in insert
  File "/home/user/frappe-bench/apps/frappe/frappe/model/", line 893, in run_before_save_methods
  File "/home/user/frappe-bench/apps/frappe/frappe/model/", line 794, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)                                                                                         
  File "/home/user/frappe-bench/apps/frappe/frappe/model/", line 1064, in composer
    return composed(self, method, *args, **kwargs)                                                                                         
  File "/home/user/frappe-bench/apps/frappe/frappe/model/", line 1047, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))                                                                                   
  File "/home/user/frappe-bench/apps/frappe/frappe/model/", line 788, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)                                                              
  File "/home/user/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/", line 43, in validate
  File "/home/user/frappe-bench/apps/erpnext/erpnext/accounts/doctype/account/", line 161, in validate_account_currency
    frappe.throw(_("Currency can not be changed after making entries using some other currency"))
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 377, in throw                                                  
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable)
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 356, in msgprint
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 316, in _raise_exception
    raise raise_exception(msg)                                       
frappe.exceptions.ValidationError: Currency can not be changed after making entries using some other currency

Any ideas on how to debug this?

What happens if you try: bench update --reset ?

@smino, thanks for replying. It leads to an error that I reported in a separate post here.

Anybody have any suggestions on what could be going wrong here?

Why am I unable to migrate to the latest code? I’ve even tried to migrate back to the same state in git as before but it fails too.

This turned out to be a result of using fixtures to automatically create accounts.

bench migrate would try to remove existing accounts but since there were already transactions in the system, we would see this error.

The solution was to delete the fixtures folder from the system after installation.

1 Like