Create a custom naming series for Quotation

I see. I don’t that is possible without some coding… maybe someone else can take a look?

Sorry.

Never mind… I have corrected the series directly in database… “tabQuotation”, “tabQuotationItem” and “tabSales Taxes and Charges.”

I did not include the ID of customer, finally.

Regards
Jaime

Editing the database directly is not really recommended…

But if it works works for you…

It is the idea, but in this case there was no other solution.

I am a developer so I know how to manage databases. When studying table structures, I have realized that primary keys are not integers and an id as I supposed, but they are strings and called “name”, however no foreign keys are present, that is, no physical relations to other tables.

In the case of Quotation table, the “name” is the resulting quotation number. I have changed it in all logically related tables and it works. I needed to update current serial number, though.

Regards
Jaime

Cody, foolproof rigorous method to get: QTN-2019-1-0001

  1. Write a py function to pull the “missing” customer id & return custom naming_series.
  2. Call this function using js in file: \erpnext\erpnext\selling\doctype\quotation\quotation.js when the customer name field is updated “on customer” and set the naming_series field to have the returned value. Js method to set field: cur_frm.set_value(qtn_field, series)
    Py code below… Have Fun :smile:

DONE. bonus: each customer will have a unique sequential numbering that changes annually.

from datetime import date

def generate(customer):
id = frappe.get_doc('Customer', customer).customer_id
yyyy = date.today().year
series = 'QTN-{0}-{1}-'.format(yyyy, id)
return series

p.s. since we edited the core erpnext file, changes will be erased every update. 2. I do not recommend doing on production server. a simple syntax error in quotation.js will stop the quotation form from opening.