How to find default company of the logged in user

604 views
Skip to first unread message

MP

unread,
Aug 22, 2014, 9:58:02 AM8/22/14
to erpnext-dev...@googlegroups.com
Hi All,

frappe.defaults.get_user_default("company") always seems to return default company for the site and not the default company of the logged in user. How do I get default company of the logged in user? I am trying to set default value for a report filter based on the logged in user's default company.

{
"fieldname":"company",
"label": "Company",
"fieldtype": "Link",
"options": "Company",
"default":frappe.defaults.get_user_default("company"
},



Kind regards,
Mayur Patel

Rushabh Mehta

unread,
Aug 23, 2014, 12:07:02 AM8/23/14
to erpnext-dev...@googlegroups.com
It should get the users default. Maybe it's not set / there are multiple defaults.

@rushabh_mehta
via mobile
--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/11e0d574-71d5-4d7e-a7f1-c01254adc394%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anand Doshi

unread,
Aug 23, 2014, 3:47:00 AM8/23/14
to erpnext-dev...@googlegroups.com
The fault lies with the new permissions system which replaced the user defaults. User permissions are based on doctype names and not field names. 

@rushabh Let's discuss this on Monday. 

Sent from my phone

Rushabh Mehta

unread,
Aug 23, 2014, 4:38:08 AM8/23/14
to erpnext-dev...@googlegroups.com
On 23-Aug-2014, at 1:16 pm, Anand Doshi <an...@iwebnotes.com> wrote:

The fault lies with the new permissions system which replaced the user defaults. User permissions are based on doctype names and not field names. 

@rushabh Let's discuss this on Monday. 

Cool - but then didn't we set the defaults based on DocTypes (?) - if not, thats an easy fix.

MP

unread,
Aug 26, 2014, 8:38:41 AM8/26/14
to erpnext-dev...@googlegroups.com
Hi Rushabh, Anand,

Is there further update on this?

Kind regards,
Mayur Patel

Anand Doshi

unread,
Sep 2, 2014, 11:52:39 AM9/2/14
to ERPNext Developer's Forum
Hi Mayur,

For now, use frappe.defaults.get_user_default("Company") with capital "C".

-Anand.


--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.

MP

unread,
Sep 2, 2014, 12:00:49 PM9/2/14
to erpnext-dev...@googlegroups.com
Thanks Anand.

Kind regards,
Mayur Patel

Anand Doshi

unread,
Sep 2, 2014, 12:21:32 PM9/2/14
to ERPNext Developer's Forum
Actually, use:
frappe.defaults.get_user_default("Company") || frappe.defaults.get_global_default("company")

so that global default company is used as fallback!

-Anand.


--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages