Help with setting up rules and permission for department administrator (HR User)

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can’t use rule based on department match. Since we only store one department value against each employee record (including HR user’s employee record), we can’t set user property of HR User’s to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     
Hi Mayur,

I didn't understand the part of why you can't set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don't see why this wouldn't work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma...@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can't use rule based on department match. Since we only store one department value against each employee record (including HR user's employee record), we can't set user property of HR User's to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of ‘Project’ (this was already there) and added another with value of ‘Operation’. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User’s employee record and change any details, the system over writes the value for both of these department property to ‘project’ (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user’s employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:

Hi Mayur,

I didn’t understand the part of why you can’t set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don’t see why this wouldn’t work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma…@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can’t use rule based on department match. Since we only store one department value against each employee record (including HR user’s employee record), we can’t set user property of HR User’s to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of 'Project' (this was already there) and added another with value of 'Operation'. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User's employee record and change any details, the system over writes the value for both of these department property to 'project' (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user's employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn't understand the part of why you can't set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don't see why this wouldn't work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma...@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can't use rule based on department match. Since we only store one department value against each employee record (including HR user's employee record), we can't set user property of HR User's to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user’s department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use’s employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:

Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of ‘Project’ (this was already there) and added another with value of ‘Operation’. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User’s employee record and change any details, the system over writes the value for both of these department property to ‘project’ (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user’s employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn’t understand the part of why you can’t set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don’t see why this wouldn’t work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma…@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can’t use rule based on department match. Since we only store one department value against each employee record (including HR user’s employee record), we can’t set user property of HR User’s to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     
Hi Mayur,

You can try using webnotes.defaults.add_user_default

See defaults.py

Thanks,
Anand.

On 05-Aug-2013, at 4:52 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default("department", self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user's department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use's employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of 'Project' (this was already there) and added another with value of 'Operation'. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User's employee record and change any details, the system over writes the value for both of these department property to 'project' (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user's employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn't understand the part of why you can't set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don't see why this wouldn't work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma...@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can't use rule based on department match. Since we only store one department value against each employee record (including HR user's employee record), we can't set user property of HR User's to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     

Hi Anand,

Sorry, not sure what you meant by using webnotes.defaults.add_user_default? Are you saying that use webnotes.defaults.add_user_default instead of   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)?if so, how will that help?

We want system to update user’s department property if the department of the employee record gets changed. As this is crucial for PO functionality.

Only for few HR users we want ability to define and maintain multiple values for department property. If it is not going to be possible then I would like to implement this requirement by creating Leave Administrator doctype as mentioned earlier. Thanks.


Kind regards,
Mayur Patel



On Monday, August 5, 2013 12:31:33 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

You can try using webnotes.defaults.add_user_default

See defaults.py

Thanks,
Anand.

On 05-Aug-2013, at 4:52 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user’s department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use’s employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of ‘Project’ (this was already there) and added another with value of ‘Operation’. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User’s employee record and change any details, the system over writes the value for both of these department property to ‘project’ (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user’s employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn’t understand the part of why you can’t set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don’t see why this wouldn’t work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma…@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can’t use rule based on department match. Since we only store one department value against each employee record (including HR user’s employee record), we can’t set user property of HR User’s to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     
Hi Mayur,

From what I understand, when you are a user with multiple user defaults for department and someone updates your employee record, your user defaults get messed up. All user defaults get set to one single department.

Instead of set default, you will need to use get_user_default_as_list for department, search if the current department exists. If not use add_user_default.

You should compare the code of webnotes.conn.set_default, webnotes.defaults.set_default and webnotes.defaults.add_default for further understanding.

Thanks,
Anand.


On 05-Aug-2013, at 5:17 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

Sorry, not sure what you meant by using webnotes.defaults.add_user_default? Are you saying that use webnotes.defaults.add_user_default instead of   webnotes.conn.set_default("department", self.doc.department, self.doc.user_id)?if so, how will that help?

We want system to update user's department property if the department of the employee record gets changed. As this is crucial for PO functionality.

Only for few HR users we want ability to define and maintain multiple values for department property. If it is not going to be possible then I would like to implement this requirement by creating Leave Administrator doctype as mentioned earlier. Thanks.

Kind regards,
Mayur Patel



On Monday, August 5, 2013 12:31:33 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

You can try using webnotes.defaults.add_user_default

See defaults.py

Thanks,
Anand.

On 05-Aug-2013, at 4:52 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default("department", self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user's department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use's employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of 'Project' (this was already there) and added another with value of 'Operation'. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User's employee record and change any details, the system over writes the value for both of these department property to 'project' (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user's employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn't understand the part of why you can't set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don't see why this wouldn't work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma...@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can't use rule based on department match. Since we only store one department value against each employee record (including HR user's employee record), we can't set user property of HR User's to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     

Thanks Anand.

I see what you are trying to say. Let me work on it and if I need any further help then I will ask for it.

Kind regards,

On Monday, August 5, 2013 1:01:40 PM UTC+1, Anand Doshi wrote:

Hi Mayur,

From what I understand, when you are a user with multiple user defaults for department and someone updates your employee record, your user defaults get messed up. All user defaults get set to one single department.

Instead of set default, you will need to use get_user_default_as_list for department, search if the current department exists. If not use add_user_default.

You should compare the code of webnotes.conn.set_default, webnotes.defaults.set_default and webnotes.defaults.add_default for further understanding.

Thanks,
Anand.


On 05-Aug-2013, at 5:17 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

Sorry, not sure what you meant by using webnotes.defaults.add_user_default? Are you saying that use webnotes.defaults.add_user_default instead of   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)?if so, how will that help?

We want system to update user’s department property if the department of the employee record gets changed. As this is crucial for PO functionality.

Only for few HR users we want ability to define and maintain multiple values for department property. If it is not going to be possible then I would like to implement this requirement by creating Leave Administrator doctype as mentioned earlier. Thanks.

Kind regards,
Mayur Patel



On Monday, August 5, 2013 12:31:33 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

You can try using webnotes.defaults.add_user_default

See defaults.py

Thanks,
Anand.

On 05-Aug-2013, at 4:52 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user’s department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use’s employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of ‘Project’ (this was already there) and added another with value of ‘Operation’. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User’s employee record and change any details, the system over writes the value for both of these department property to ‘project’ (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user’s employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn’t understand the part of why you can’t set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don’t see why this wouldn’t work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma…@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can’t use rule based on department match. Since we only store one department value against each employee record (including HR user’s employee record), we can’t set user property of HR User’s to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     

Hi Anand,

FYI

I created a new server side script with the below code. I tested it and it seems to work fine.

 if not webnotes.defaults.get_user_default_as_list(‘department’,self.doc.user_id).count(self.doc.department):
                        webnotes.conn.add_default(‘department’,self.doc.department,self.doc.user_id)

Please let me know if above is ok.

On a side note, I noticed that once you create a server side script from the browser, it can’t be edited. I checked all the permissions but still it doesn’t allow me to edit it. The code area is not editable.  I had to delete and create the script again.Is there any reason for this behavior?

Kind regards,
Mayur

On Monday, August 5, 2013 1:08:33 PM UTC+1, MP wrote:

Thanks Anand.

I see what you are trying to say. Let me work on it and if I need any further help then I will ask for it.

Kind regards,

On Monday, August 5, 2013 1:01:40 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

From what I understand, when you are a user with multiple user defaults for department and someone updates your employee record, your user defaults get messed up. All user defaults get set to one single department.

Instead of set default, you will need to use get_user_default_as_list for department, search if the current department exists. If not use add_user_default.

You should compare the code of webnotes.conn.set_default, webnotes.defaults.set_default and webnotes.defaults.add_default for further understanding.

Thanks,
Anand.


On 05-Aug-2013, at 5:17 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

Sorry, not sure what you meant by using webnotes.defaults.add_user_default? Are you saying that use webnotes.defaults.add_user_default instead of   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)?if so, how will that help?

We want system to update user’s department property if the department of the employee record gets changed. As this is crucial for PO functionality.

Only for few HR users we want ability to define and maintain multiple values for department property. If it is not going to be possible then I would like to implement this requirement by creating Leave Administrator doctype as mentioned earlier. Thanks.

Kind regards,
Mayur Patel



On Monday, August 5, 2013 12:31:33 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

You can try using webnotes.defaults.add_user_default

See defaults.py

Thanks,
Anand.

On 05-Aug-2013, at 4:52 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user’s department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use’s employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of ‘Project’ (this was already there) and added another with value of ‘Operation’. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User’s employee record and change any details, the system over writes the value for both of these department property to ‘project’ (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user’s employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn’t understand the part of why you can’t set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don’t see why this wouldn’t work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma…@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can’t use rule based on department match. Since we only store one department value against each employee record (including HR user’s employee record), we can’t set user property of HR User’s to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     
Hi Mayur,

The code looks okay.
Though, you can also use "not in" operator, since you are not making any use of the count:

if self.doc.department not in webnotes.defaults.get_user_default_as_list("department", self.doc.user_id):
 webnotes.conn.add_default('department', self.doc.department, self.doc.user_id)

Can you raise custom server-script issue on github? We will look into it and you'll get the notification once it is fixed.

Thanks,
Anand.

On 06-Aug-2013, at 10:04 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

FYI

I created a new server side script with the below code. I tested it and it seems to work fine.

 if not webnotes.defaults.get_user_default_as_list('department',self.doc.user_id).count(self.doc.department):
                        webnotes.conn.add_default('department',self.doc.department,self.doc.user_id)

Please let me know if above is ok.

On a side note, I noticed that once you create a server side script from the browser, it can't be edited. I checked all the permissions but still it doesn't allow me to edit it. The code area is not editable.  I had to delete and create the script again.Is there any reason for this behavior?

Kind regards,
Mayur

On Monday, August 5, 2013 1:08:33 PM UTC+1, MP wrote:
Thanks Anand.

I see what you are trying to say. Let me work on it and if I need any further help then I will ask for it.

Kind regards,

On Monday, August 5, 2013 1:01:40 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

From what I understand, when you are a user with multiple user defaults for department and someone updates your employee record, your user defaults get messed up. All user defaults get set to one single department.

Instead of set default, you will need to use get_user_default_as_list for department, search if the current department exists. If not use add_user_default.

You should compare the code of webnotes.conn.set_default, webnotes.defaults.set_default and webnotes.defaults.add_default for further understanding.

Thanks,
Anand.


On 05-Aug-2013, at 5:17 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

Sorry, not sure what you meant by using webnotes.defaults.add_user_default? Are you saying that use webnotes.defaults.add_user_default instead of   webnotes.conn.set_default("department", self.doc.department, self.doc.user_id)?if so, how will that help?

We want system to update user's department property if the department of the employee record gets changed. As this is crucial for PO functionality.

Only for few HR users we want ability to define and maintain multiple values for department property. If it is not going to be possible then I would like to implement this requirement by creating Leave Administrator doctype as mentioned earlier. Thanks.

Kind regards,
Mayur Patel



On Monday, August 5, 2013 12:31:33 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

You can try using webnotes.defaults.add_user_default

See defaults.py

Thanks,
Anand.

On 05-Aug-2013, at 4:52 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default("department", self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user's department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use's employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma...@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of 'Project' (this was already there) and added another with value of 'Operation'. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User's employee record and change any details, the system over writes the value for both of these department property to 'project' (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user's employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn't understand the part of why you can't set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don't see why this wouldn't work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma...@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can't use rule based on department match. Since we only store one department value against each employee record (including HR user's employee record), we can't set user property of HR User's to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     

Thanks Anand for suggesting a better approach. Much appreciated.

I will raise custom server-script issue on github.

Kind regards,
Mayur Patel

On Wednesday, August 7, 2013 7:04:50 AM UTC+1, Anand Doshi wrote:

Hi Mayur,

The code looks okay.
Though, you can also use “not in” operator, since you are not making any use of the count:

if self.doc.department not in webnotes.defaults.get_user_default_as_list(“department”, self.doc.user_id):
 webnotes.conn.add_default(‘department’, self.doc.department, self.doc.user_id)

Can you raise custom server-script issue on github? We will look into it and you’ll get the notification once it is fixed.

Thanks,
Anand.

On 06-Aug-2013, at 10:04 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

FYI

I created a new server side script with the below code. I tested it and it seems to work fine.

 if not webnotes.defaults.get_user_default_as_list(‘department’,self.doc.user_id).count(self.doc.department):
                        webnotes.conn.add_default(‘department’,self.doc.department,self.doc.user_id)

Please let me know if above is ok.

On a side note, I noticed that once you create a server side script from the browser, it can’t be edited. I checked all the permissions but still it doesn’t allow me to edit it. The code area is not editable.  I had to delete and create the script again.Is there any reason for this behavior?

Kind regards,
Mayur

On Monday, August 5, 2013 1:08:33 PM UTC+1, MP wrote:
Thanks Anand.

I see what you are trying to say. Let me work on it and if I need any further help then I will ask for it.

Kind regards,

On Monday, August 5, 2013 1:01:40 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

From what I understand, when you are a user with multiple user defaults for department and someone updates your employee record, your user defaults get messed up. All user defaults get set to one single department.

Instead of set default, you will need to use get_user_default_as_list for department, search if the current department exists. If not use add_user_default.

You should compare the code of webnotes.conn.set_default, webnotes.defaults.set_default and webnotes.defaults.add_default for further understanding.

Thanks,
Anand.


On 05-Aug-2013, at 5:17 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

Sorry, not sure what you meant by using webnotes.defaults.add_user_default? Are you saying that use webnotes.defaults.add_user_default instead of   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)?if so, how will that help?

We want system to update user’s department property if the department of the employee record gets changed. As this is crucial for PO functionality.

Only for few HR users we want ability to define and maintain multiple values for department property. If it is not going to be possible then I would like to implement this requirement by creating Leave Administrator doctype as mentioned earlier. Thanks.

Kind regards,
Mayur Patel



On Monday, August 5, 2013 12:31:33 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

You can try using webnotes.defaults.add_user_default

See defaults.py

Thanks,
Anand.

On 05-Aug-2013, at 4:52 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

Yes, my apologies, I forgot to mention that we have setup Server script that does below.

   webnotes.conn.set_default(“department”, self.doc.department, self.doc.user_id)

I need above for Buying module where we want to restrict PO access to within user’s department by saving department (automatically) as part of the Purchase Order record.
Also employee move around departments so we need this to be updated when we update use’s employee record.

Is there anyway to assign multiple departments for an employee?

Kind regards,
Mayur Patel



On Monday, August 5, 2013 11:59:20 AM UTC+1, Anand Doshi wrote:
Hi Mayur,

You should investigate why the department user property is being overwritten. Check employee.py and see if you have customised any code to set this user property.

Thanks,
Anand.

On 05-Aug-2013, at 4:06 PM, MP <ma…@gmail.com> wrote:

Hi Anand,

I did give it a go. Using User Properties menu from Setup module, for this HR User, I setup two user properties for Department. One with value of ‘Project’ (this was already there) and added another with value of ‘Operation’. I can see these both entries under User Properties for this user. And permissions works too. The problem is that, when I update this HR User’s employee record and change any details, the system over writes the value for both of these department property to ‘project’ (as this is what is selected for Department field on Employee page).

So my question is, is there anyway we can store multiple departments for this HR user’s employee record? If so, how do I enable the Link field to have multi-select option? I hope it makes sense?

Kind regards,
Mayur Patel


On Friday, August 2, 2013 6:13:28 PM UTC+1, Anand Doshi wrote:
Hi Mayur,

I didn’t understand the part of why you can’t set multiple user properties of department for HR User. 

Have you given it a try?

Many users set multiple user properties for company and match condition on company to access data of multiple companies. I don’t see why this wouldn’t work on department match condition. 

Sent from my phone

On 02-Aug-2013, at 10:11 PM, MP <ma…@gmail.com> wrote:

Hi There,

We have a requirement where we need to allow HR users to see details of employees (employee record, leave allocation and leave application details) from selected departments. Since a HR user can be in-charge of multiple departments, we can’t use rule based on department match. Since we only store one department value against each employee record (including HR user’s employee record), we can’t set user property of HR User’s to have multiple values for department property. I hope it makes sense. I am thinking of setting up a doctype called Leave Administrator and store the names of HR user in it. Then assign a Leave administrator to each employee (also setup a user property too). Then define a rule based on Leave Administrator property. I will need to also setup a custom field for both leave application and leave application. I think this should work.

Is there any better approach? Thanks in advance.

Kind regards,
Mayur Patel



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     




Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un…@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.

     

     



Note:

 

If you are posting an issue,

  1. 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.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. 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-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.