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

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)

  1. 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.)

  2. 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.

You can bookmark this blog-post

Thanks,
Sambhaji Kolate

31 Likes

hi, where we can find the complete list of field we can use in naming? like .customer or {vendor_id}

@synertic You can use all fields present in form.
You find complete list here or from customize form

https://frappe.github.io/erpnext/current/models/selling/sales_order.html

Can you please confirm if this feature is working for:
ERPNext: v6.27.3
Frappe Framework: v6.27.4

It is not working for me. TIA

@hanstel its available in version you specified.
What naming series your are using and what it the output you are getting?

To test same, you can create new naming series on Quotation as QTN-.YYYY.-.customer.-.####
Then try to create new quotation with updated naming series

i am getting literals YY and fields, no translation is happening.

Example:
naming series: PLAN-.YY-.####

i’m getting a name of PLAN-YY-0001

@hanstel Is this solved?

check dot(.)
use naming series PLAN-.YY.-.#### to get year.

1 Like

@kolate_sambhaji Nice one. I have created one based on the user abbr

eg

QTN-.YY.-user_abbr-.###

This produces with suppose user Ankit Fadia = QTN-16-AF-001

Another user say Umair Sayyed = QTN-16-AF-001

Now how do I updated the series with them. Because in the setup it just shows QTN-.YY.-.user_abbr.-.###

1 Like

@vivek
naming series is auto-incremented.
If you want to change current value or start naming series from 100 then you can set current value for naming series.
https://frappe.github.io/erpnext/user/manual/en/setting-up/articles/naming-series-current-value

@kolate_sambhaji I did try the above but what it doesnt change the current value. If i set value to 100, still each of those resulting series are treated differently

Meaning

Create quote 1 by user AA - > QTN-16-AA-001
Create quote 2 by user US - > QTN-16-US-001
Create quote 3 by user US - > QTN-16-US-002
Create quote 4 by user AA - > QTN-16-AA-002

even if change the current value, it is off no effect

@vivek
Need to fix this issue for current value, I will check this.

For now, you can create for quote by user AA and then rename QTN-16-AA-001 to QTN-16-AA-100, keep this quote in system and make new quote, you will get new quote with number QTN-16-AA-101.

@vivek Its working fine in my setup.
You need to add naming series QTN-.YY.-.user_abbr.-.###, Note: user_abbr should be available in quotation before creation of quotation.

Alternative option:
Write method in you custom app and call from hooks.

    "Quotation": {
        "before_insert": "custom_app.custom_py_methods.quote_autoname",
    },

custom_py_methods.py

from frappe.model.naming import make_autoname
    def quote_autoname(doc,method):
        cc=str(frappe.db.get_value("User",{"name":doc.owner},"user_abbr"))
        qo_name = "QTN-16"+cc+".####"
        substring_so = make_autoname(qo_name + '.####')
        doc.name=str(substring_so)
1 Like

I have a custom field (type: Data) under Supplier called Supplier Code → supplier_code

In naming series I tested PO-.YY.-.{supplier_code}.-.##### but that gives:
Special Characters except “-”, “#”, “.” and “/” not allowed in naming series

If I do it without the curly-brackets supplier_code doesn’t get replaced, instead gets printed as the work ‘supplier_code’.

tips?

Updated to ERPNext: v7.2.5, still same issue with curly-brackets not allowed in naming series.

If I run without, i.e. simply PO-.YY.-.supplier_code.-.#####,
creating a PO will become PO-16-supplier_code-00011

@raveslave supplier_code is present in Supplier and not present in Purchase Order
Make sure supplier_code is present in Purchase Order before you save it.

You can use PO-16-supplier_code-#### series only if supplier code is present in purchase order.

to test series is working or not try naming series PO-16-supplier-####

Thanks,
Sambhaji
http://sbkolate.com

Hi & thx Sambhaji,

I did add supplier_code to the Purchase Order Form (see img below), still don’t manage to get it replaced with the supplier_code inherited from the Supplier.

Or did you mean I need to customize and add it to the DocType for PO? Seems adding rows there is possible but not editable. Sorry being such a newbie :slight_smile:

@raveslave you can add supplier_code in PO and write custom script add fetch, to fetch supplier code from Supplier

Hi Kolate,

As you can see in my screen shot in the previous post, supplier_code is indeed part of the PO-form. Still not working.

Custom-script is fine as a workaround. Any hints on where to do this. I was under the impression in the first post in this thread that this is not needed if using .-.{vendor_id}.- or .-.vendor_id.- (as curly brackets is not allowed in naming-series)

best david

@raveslave we are using dot . to separate custom field name.
So PO-16-.supplier_code.-#### is correct syntax

thx! still no go, hmm. does it work on your side?

Am I right off making the new field in
Form: Purchase Order
Field “Supplier Code”
Type: “Data”
by erpnext, auto-gen field-name: supplier_code
and in last column: “Supplier” (not sure if this matters)