Client script to fetch value from another doctype

Hi,

I want to get a field value from sales_taxes_and_charges_master table and compare with a field in sales invoice for validation, how can I do that.

I am currently able to pull the field properly from the master as below:

cur_frm.add_fetch('taxes_and_charges','c_form_applicable','c_form_applicable');


Now I also want to check if the two fields one in Sales Invoice and the other in the sales_taxes_and_charges_master table are they equal  for the selected value in taxes_and_charges, how can I do that?

I can't seem to find the answer but I think this query must have been answered before.



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-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/04968c3e-bde1-4e7e-9610-d11774e957de%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Aditya,

add_fetch will fetch the value from Taxes and Charges Master and set its value in c_form_applicable. You have already lost the old value.

Can you describe what are you trying to do, in a general sense and not how you plan to apply it? Maybe there would be a simpler solution.


-Anand.


On Wed, Sep 3, 2014 at 6:20 PM, Aditya Duggal <ad…@gmail.com> wrote:

Hi,

I want to get a field value from sales_taxes_and_charges_master table and compare with a field in sales invoice for validation, how can I do that.

I am currently able to pull the field properly from the master as below:

cur_frm.add_fetch('taxes_and_charges','c_form_applicable','c_form_applicable');



Now I also want to check if the two fields one in Sales Invoice and the other in the sales_taxes_and_charges_master table are they equal for the selected value in taxes_and_charges, how can I do that?


I can't seem to find the answer but I think this query must have been answered before.



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-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/04968c3e-bde1-4e7e-9610-d11774e957de%40googlegroups.com.

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




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-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CAAQzbF2RSCkr8Qi4onudhvxE0J64xT1RkbTRkMTTnJW-xkLNTA%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Hi Anand,

I am trying to implement the C-Forms tracking in my organisation through erpnext. Now since C-forms are linked to the taxes hence I have added a custom field in Sales Taxes master as C-Form applicable, which is a select field.

Now every time a person pulls a sales tax master the c_form_applicable field in the SI would automatically become same as the one in Sales Tax master, this part is good and easily implemented.

Now I also want to do a VALIDATION in SI when someone saves a SI then the system should validate that whether the c_form_applicable field in SI and in Sales Tax master are same or not. This is the part which I am unable to implement on the client script as I think this would be easily implementable in server script by this script:


# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import frappe
from frappe import msgprint

def validate(doc,method):
c_form_tax =frappe.db.get_value("Sales Taxes and Charges Master", doc.taxes_and_charges ,"c_form_applicable")
if (doc.c_form_applicable!=c_form_tax):
frappe.msgprint("C-Form applicable selection does not match with Sales Tax", raise_exception=1)

Now I have tried to add a sales_invoice.py file in my custom app but it does not seem to be working. I would like to do this validation both on server and client end.

On Wednesday, September 3, 2014 8:26:49 PM UTC+5:30, Anand Doshi wrote:
Aditya,

add_fetch will fetch the value from Taxes and Charges Master and set its value in c_form_applicable. You have already lost the old value.

Can you describe what are you trying to do, in a general sense and not how you plan to apply it? Maybe there would be a simpler solution.


-Anand.


On Wed, Sep 3, 2014 at 6:20 PM, Aditya Duggal <ad…@gmail.com> wrote:

Hi,

I want to get a field value from sales_taxes_and_charges_master table and compare with a field in sales invoice for validation, how can I do that.

I am currently able to pull the field properly from the master as below:

cur_frm.add_fetch('taxes_and_charges','c_form_applicable','c_form_applicable');



Now I also want to check if the two fields one in Sales Invoice and the other in the sales_taxes_and_charges_master table are they equal  for the selected value in taxes_and_charges, how can I do that?


I can't seem to find the answer but I think this query must have been answered before.



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-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/04968c3e-bde1-4e7e-9610-d11774e957de%40googlegroups.com.

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




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-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/c23484f2-1fe6-41c4-8ab2-f29e513be1db%40googlegroups.com.

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

Yiu have to call this validate function through hook.

On 4 Sep 2014 09:33, "Aditya Duggal" <ad...@gmail.com> wrote:
Hi Anand,

I am trying to implement the C-Forms tracking in my organisation through erpnext. Now since C-forms are linked to the taxes hence I have added a custom field in Sales Taxes master as C-Form applicable, which is a select field.

Now every time a person pulls a sales tax master the c_form_applicable field in the SI would automatically become same as the one in Sales Tax master, this part is good and easily implemented.

Now I also want to do a VALIDATION in SI when someone saves a SI then the system should validate that whether the c_form_applicable field in SI and in Sales Tax master are same or not. This is the part which I am unable to implement on the client script as I think this would be easily implementable in server script by this script:


# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import frappe
from frappe import msgprint

def validate(doc,method):
c_form_tax =frappe.db.get_value("Sales Taxes and Charges Master", doc.taxes_and_charges ,"c_form_applicable")
if (doc.c_form_applicable!=c_form_tax):
frappe.msgprint("C-Form applicable selection does not match with Sales Tax", raise_exception=1)

Now I have tried to add a sales_invoice.py file in my custom app but it does not seem to be working. I would like to do this validation both on server and client end.

On Wednesday, September 3, 2014 8:26:49 PM UTC+5:30, Anand Doshi wrote:
Aditya,

add_fetch will fetch the value from Taxes and Charges Master and set its value in c_form_applicable. You have already lost the old value.

Can you describe what are you trying to do, in a general sense and not how you plan to apply it? Maybe there would be a simpler solution.


-Anand.


On Wed, Sep 3, 2014 at 6:20 PM, Aditya Duggal <ad…@gmail.com> wrote:

Hi,

I want to get a field value from sales_taxes_and_charges_master table and compare with a field in sales invoice for validation, how can I do that.

I am currently able to pull the field properly from the master as below:


cur_frm.add_fetch('taxes_and_charges','c_form_applicable','c_form_applicable');



Now I also want to check if the two fields one in Sales Invoice and the other in the sales_taxes_and_charges_master table are they equal for the selected value in taxes_and_charges, how can I do that?


I can't seem to find the answer but I think this query must have been answered before.



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-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/04968c3e-bde1-4e7e-9610-d11774e957de%40googlegroups.com.

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




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-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/c23484f2-1fe6-41c4-8ab2-f29e513be1db%40googlegroups.com.

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



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-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CA%2BCj7therkAPrR0J0XoJLfTVuBo9wQ73jD5YdJhchTFCZrMabw%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Thanks Nabin,

Just checked the hooks file in my system and figured out the way to do it from server end, but is there a way to do the same validation on the client script.

On Thursday, September 4, 2014 10:11:30 AM UTC+5:30, Nabin Hait wrote:

Yiu have to call this validate function through hook.

On 4 Sep 2014 09:33, "Aditya Duggal" <ad...@gmail.com> wrote:
Hi Anand,

I am trying to implement the C-Forms tracking in my organisation through erpnext. Now since C-forms are linked to the taxes hence I have added a custom field in Sales Taxes master as C-Form applicable, which is a select field.

Now every time a person pulls a sales tax master the c_form_applicable field in the SI would automatically become same as the one in Sales Tax master, this part is good and easily implemented.

Now I also want to do a VALIDATION in SI when someone saves a SI then the system should validate that whether the c_form_applicable field in SI and in Sales Tax master are same or not. This is the part which I am unable to implement on the client script as I think this would be easily implementable in server script by this script:


# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import frappe
from frappe import msgprint

def validate(doc,method):
c_form_tax =frappe.db.get_value("Sales Taxes and Charges Master", doc.taxes_and_charges ,"c_form_applicable")
if (doc.c_form_applicable!=c_form_tax):
frappe.msgprint("C-Form applicable selection does not match with Sales Tax", raise_exception=1)

Now I have tried to add a sales_invoice.py file in my custom app but it does not seem to be working. I would like to do this validation both on server and client end.

On Wednesday, September 3, 2014 8:26:49 PM UTC+5:30, Anand Doshi wrote:
Aditya,

add_fetch will fetch the value from Taxes and Charges Master and set its value in c_form_applicable. You have already lost the old value.

Can you describe what are you trying to do, in a general sense and not how you plan to apply it? Maybe there would be a simpler solution.


-Anand.


On Wed, Sep 3, 2014 at 6:20 PM, Aditya Duggal <ad…@gmail.com> wrote:

Hi,

I want to get a field value from sales_taxes_and_charges_master table and compare with a field in sales invoice for validation, how can I do that.

I am currently able to pull the field properly from the master as below:


cur_frm.add_fetch(‘taxes_and_charges’,‘c_form_applicable’,‘c_form_applicable’);



Now I also want to check if the two fields one in Sales Invoice and the other in the sales_taxes_and_charges_master table are they equal  for the selected value in taxes_and_charges, how can I do that?


I can't seem to find the answer but I think this query must have been answered before.



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-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/04968c3e-bde1-4e7e-9610-d11774e957de%40googlegroups.com.

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




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-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/c23484f2-1fe6-41c4-8ab2-f29e513be1db%40googlegroups.com.

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



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-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/95ac9a99-19ef-4540-bfdd-08e1c81d4004%40googlegroups.com.

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