How to set default currency in frappe framework without erpnext?

Hi,
I create a new site in frappe framework, then run wizard.
In wizard step I choose the USD currency as my system currency, but when I create doctype with currency field it show something else currency.

I try to find in System Setting but it does not in there.

Can anyone help where change I change default currency?

Thanks,

1 Like

Hi @Pheakdey_Tes,

Please go to the Global Defaults DocType the set the default currency your according.

Thank You!

1 Like

I try to find this but cannot find it. If I install erpnext app, I can find it.

In my case, I do not install any app to my site.
Just frappe framework and my site.

Am I missing something?

Here when I search global default in awesome search bar.

Hi try another way,

Please go to the doctype and open the global default.
Follow the step.

Otherwise
URL like this.

https://your_site.com/app/doctype/Global%20Defaults

OR

http://your_site.com/app/doctype/Global%20Defaults

Thank You!

Here is what I try

I got to doctype search for global setting, Still not see

Thank,

I clarify:

I do not install erpnext to my site.
When I install erpnext app to site, I see this option Global Setting.
So I think that Global Setting is part of erpnext not frappe.

I my case I do not need erpnext app. It just a small custom app build over frappe framework.

Thanks,

Right,

Global Defaults under the setup module and it is in the erpnext app.

I think, the default currency set for apply custom/client script.

frappe.ui.form.on('Your DocType', {
	setup: function(frm) {
        frm.set_value("your_currency_field", "USD");
	}
});

Thank You!

1 Like

Hi @NCP ,

Thank for your help. but I do not think this is solution for me, Since I have around 10 doctype that relate to currency field.

Plus, I have dashboards and reports, So I have to manually change all these thing.

I willing to hard code fix currency core code. Can you help me which file should I change?

Thanks,

Hi,

My frappe framework v14 is random pick currency for it default.

Is anyone used to have this issue?

Thanks,

hey! try Sessions Defaults:

it’s a core doctype and thus might work. Good luck!

1 Like

Hi @wojosc

I have tried this also, but it works for me only, not work for other users.
I believe session default is for personal user preference. It does not affect for whole app.

There’s should be a way to do it.
I took me about a week of fulltime working hour already for try to find this solution. but still don’t have solution yet.

Hope someone can help.

Thanks,

Hi @Pheakdey_Tes,

Why do not set default currency in all doctype?
I think If you set it then easy to use doctype.

Hi @NCP,

To be honest, I dont really understand about your suggestion.
When I add new field Currency to my Doctype and set default to USD, my currency field still show wrong current format, as well as in report.

Can you clarify detail about your suggestion?

Thanks,

Ok.

What I am saying is that you can set the default currency in the currency field in default or custom doctype. Then reload your system.

Report level we can’t directly set the default currency but if you want to set the default currency then apply it in report js.

Example.

{
	"fieldname": "currency",
	"label": __("Currency"),
	"fieldtype": "Link",
	"options": "Currency",
	"default": "USD"
}

Thank You!

Thank you very much @NCP for taking your time trying to help me out about this issue.

Finally I manage solve this by add a new doctype to my app, for example My App Setting, then add add new docfield Currency link to Currency doctype.

and here is on update event of my doctype:

from frappe.model import no_value_fields
import frappe
from frappe.model.document import Document

class MyAppSetting(Document):
	def on_update(self):
		for df in self.meta.get("fields"):
			if df.fieldtype not in no_value_fields and self.has_value_changed(df.fieldname):
				frappe.db.set_default(df.fieldname, self.get(df.fieldname))

I copy this code from system_settings.py. And yes everything work as expected.

But I still do not know what logic behind.

Thanks,

3 Likes

I solved this in a cleaner way.
Just create a Company DocType with a field default_currency of type Link and options set to Currency


Go into the document and select your default currency.

1 Like