You can use custom field in naming series along with YY MM DD option

Hi @kolate_sambhaji,

This functionality is great. I wonder though which is should only be applied to naming series. I think with a small change it can also be used to build composite name fields for doctypes. So for example, if I have a doctype with fields X, Y and Z, in addition to the possibility of an auto name .X.-.Y.-.#### I should also be able to have just .X.-.Y.

What do you think?

Regards,
cksgb

@raveslave can you check PO-16-.supplier.-####? if this is working, then check whether you get data in supplier code.

Anyways, you can Skype me at kolate.sambhaji and we can have a look at this problem.

Frappe team developed option to add YY MM DD and I have added option to add custom field in naming series and this is working for us.

@Chude_Osiegbu currently you can use fields present in same doctype only. Its great suggestion to use fields from another doctype.
Can you post issue on github?
I will check this if I can develop this.

Hi @kolate_sambhaji ,

Thanks but I meant whether itā€™s possible to remove the requirement for #### in the auto name rule. Sometimes you want to concatenate fields into the name without appending an auto-incrementing number

Regards,
cksgb

@Chude_Osiegbu yes you can remove .####

Hmmā€¦ Will try again. Didnā€™t seem to work when I tried earlier. Thanks.

1 Like

Hi @kolate_sambhaji

I tested with .supplier. and that works. So not sure whatā€™s going wrong here.
pls help confirm that itā€™s correctly setup (see the screenshot in my post from Dec 16 above)

best david

1 Like

Correct syntax is PO-16-.supplier_code.-#### where supplier_code is custom field in Purchase Order.
Make sure supplier code is present before you save PO.

OR

To test feature, you can take supplier code custom field in PO and add supplier code manually in PO.

Hi all,

If we use e.g. JV/.YY./.MM./.### and make back-dated entry (posting date is backdated entry) then MM takes always current month

How to make naming series follow posting_date. not server current date

This feature is not available right now, you need to create hardcoded naming series as JV/16/03/.###

I have the same problem.
In the quotation I want to use the number QN.YYYY.MM.-.####, Where YYYYMM was taken from the ā€˜Dateā€™
I have tried it in the quotation and the results are quite satisfactory, when I create a new quote and fill in the ā€˜Dateā€™ for example, January 1st, 2017, the naming series that is produced is QN201701-0001, but the date on the server is already in March.

  1. In the ā€˜customize formā€™ Quotation, add ā€˜Fieldā€™ with the name ā€˜date_for_seriesā€™
  2. Create a custom script for a quote, as follows:

var date_for_series = function(frm){
var ymd = frm.doc.transaction_date;
var yy = ymd.substring(0,4);
var mm = ymd.substring(5,7);
var ym = yy+ā€œā€+mm;
frm.set_value(ā€œdate_for_seriesā€, ym);
}
frappe.ui.form.on(ā€œQuotationā€, ā€œvalidateā€, function(frm) {
date_for_series(frm);
})

3.Create naming_series by name: QN.date_for_series.-.####
Of course there are still some weaknesses.

1 Like

@hendrik_zeta sorry for the trouble.

Can you reproduce same in demo account?
https://demo.erpnext.com

You can see YYYY MM is taken from todays date instead on quotation or transaction date.

@kolate_sambhaji I canā€™t access Setup > Custom Script and Setup > Customize Form in https://demo.erpnext.com

[quote=ā€œhendrik_zeta, post:31, topic:10865ā€]
n the quotation I want to use the number QN.YYYY.MM.-.####, Where YYYYMM was taken from the ā€˜Dateā€™
[/quote] :+1:

@hendrik_zeta I am making same thing for one client,
So in Quote I will take it from quotation_date and in sales invoice I will take YYMM from transaction_date.

Can you suggest generic design to add it in customise form and doctype naming series, if this will help, I would like to add it in default erpnext feature

1 Like

Very useful thread, thanks, @kolate_sambhaji.

We want to use naming scheme, which will assign predefined abbreviations instead of full words. E.g. ITEM-2017-03-05-R instead of ITEM-2017-03-Apple-Red, where value Apple is predefined as 05 and value Red is predefined as R.
Is this possible to achieve by custom script, not touching source code?

@strixaluco yes this is possible using custom script and custom fields, you need to add custom field for abbr. Then using custom script you can set values in abbr.
It will auto pickup in naming series.

Thanks,
Sam

1 Like

Thanks, @kolate_sambhaji and sorry for late reply.

Itā€™s a pity, but seems like my understanding of scripting is not enough.

I added two custom fields to Item doctype:


#    label    type      options    

1    Fruit    Select    Apple    
                        Pear     
                        Banana 

2    Color    Select    Yellow  
                        Green   
                        Red     

Letā€™s imagine Iā€™m creating new item selecting Apple as Fruit and Green as Color. Chosen naming scheme is ITEM-YYYY-MM-FRUIT-COLOR, which gives us ITEM-2017-03-Apple-Green in the example.
But what we want is to assign abbreviations as following:


#    label    type      options    abbreviation

1    Fruit    Select    Apple      AP
                        Pear       PR
                        Banana     BN

2    Color    Select    Yellow     01
                        Green      02
                        Red        03

so that the system generates ITEM-2017-03-AP-02 instead.

Can somebody please help us with such script?

I think u should write a custom script and check selected value, kind of

var fruit_abbreviation

switch(fruit) {
   case "Apple":
      fruit_abbreviation = "AP";
      break;
   case "Pear":
      fruit_abbreviation = "PR";
      break;
   case "Banana":
      fruit_abbreviation = "BN";
      break;
}

then use ITEM-YYYY-MM-FRUIT_ABBREVIATION-COLOR_ABBREVIATION

2 Likes

Thanks a lot, @JoEz. I will try, assuming that you meant something like this for our case:

var fruit_abbreviation

switch(fruit) {
   case "Apple":
      fruit_abbreviation = "AP";
      break;
   case "Pear":
      fruit_abbreviation = "PR";
      break;
   case "Banana":
      fruit_abbreviation = "BN";
      break;
}

var color_abbreviation

switch(color) {
   case "Yellow":
      color_abbreviation = "01";
      break;
   case "Green":
      color_abbreviation = "02";
      break;
   case "Red":
      color_abbreviation = "03";
      break;
}