Wednesday, 16 March 2016

[ERPNext] get value from another doc in javascript

Here is one example to fetch customer in Delivery Note using frappe.client.get_value method.
 Using this you can fetch values from another doc.


frappe.call({
    'method': 'frappe.client.get_value',
    'args': {
        'doctype': 'Delivery Note',
        'fieldname': 'customer',
          'filters': {
            'name': 'DN-00003'
          }
        }
        ,
       callback: function(r){
                              msgprint(r.message.customer);


       }
   
});

Thursday, 10 March 2016

How to make child table field read only?

Using below code, one can set child table field read only.


Syntax
 
    var df = frappe.meta.get_docfield("CHILD TABLE DOCTYPE","FIELD NAME", cur_frm.doc.name);
    df.read_only = 1;



example:
 Using this, we can set item_name field read-only. This will helpful if you want to make fields read-only based on some condition

  frappe.ui.form.on("Sales Order","onload", function(frm, cdt, cdn) {
    var df = frappe.meta.get_docfield("Sales Order Item","item_name", cur_frm.doc.name);
    df.read_only = 1;

});

Wednesday, 2 March 2016

How to setup naming series in ERPNext?

Hello All,
I am sharing some naming series option which will be helpful.
  • You can now use custom fields in naming series.
  • You can also use YY MM DD in naming series, where YY represent current Year, MM represent current Month and DD represent Today.
  • You can also use fields from document in naming series like supplier code/customer code
Examples:
1) QTN-.YYYY.-.customer.-.####
Resulting in QTN-2016-SBK-0001 (Asuming SBK is selected customer in Quotation)
2) PO-.YY.MM.-.{vendor_id}.-.#####
Resulting in "PO-1603-WN-00001" (where "Vendor ID" is custom field created under Document: Supplier and fetched into Purchase Order.)
3) DE/./.YY./.MM./.##### will create a series like
           DE/16/03/0001 where 16 is the year, 03 is the month and 0001 is the series
   Autoname rules:
  • The key is separated by '.'
  • '####' represents a series. The string before this part becomes the prefix:
  • ABC.#### creates a series ABC0001, ABC0002 etc
  • 'MM' represents the current month
  • 'YY' and 'YYYY' represent the current year
  • Each Series Prefix on a new line.Allowed special characters are "/" and "-"Optionally, set the number of digits in the series using dot (.) followed by hashes (#). For example, ".####" means that the series will have four digits.
    Default is five digits.
Thanks,
Sambhaji Kolate
Email: kolate.sambhaji@gmail.com