Hi all
I tell you what happened to me so you may be able to replicate and work something out of it. There are several issues to comment, I’ll try to explain my best what I did (I’m newbie, so take this with a grain of salt)
So, I installed latest development branch and updated as of 03/12//2025 and it’s working. I’m also following Frappe Framework App Development Bootcamp - Day 2 (Dubai, 2024), but trying a bit of new things, this is my second time following such tutorial, doing things in Spanish, my mother language.
So I try to set up a field several times in frappe desk Build DocType, getting frustrated and deleting and doing it all over again, trying to get “autoname”: “naming_series:” the right way, after several tries, 1st try was “fieldtype”: “Link” then deleted it and again the 2nd try also “fieldtype”: “Link” and the 3rd try I configure it as “fieldtype”: “Select”, when I go to the editor I got to read the json and found the field like this:
{
“default”: “1lvtj3rpd4”,
“fieldname”: “naming_series”,
“fieldtype”: “Select”,
“hidden”: 1,
“label”: “N\u00famero de Solicitud”,
“link_filters”: “[[“Document Naming Rule”,“name”,“=”,“1lvtj3rpd4”]]”,
“options”: “1lvtj3rpd4”,
“read_only”: 1,
“reqd”: 1
}
So I can have “autoname”: “naming_series:”. This is good, the problem, I guess is that I didn’t get it right the first time, in fact, I tried to set up for 3 times this to work, creating Document Naming Rules each time and assigning them to my field, first I triead to set it up as “fieldtype”: “Link”, it didn’t work the way I expected, I got frustrated and deleted the Document Naming Rule and created new ones, thinking the problem was there. Then I tried the one it’s copied above with “fieldtype”: “Select”. But I got in the json the “link_filters”: “[[“Document Naming Rule”,“name”,“=”,“1lvtj3rpd4”]]”, and I think this doesn’t make sense for a fieldtype: “Select”.
So after reading the docs, asking serveral ai’s, etc… finally I think I got a clue:
In the mariadb console, I describe the database table of the doctype with:
MariaDB [_a27fa9b18cffdd35]> DESC tabSolicitud de reserva;
±------------------±-------------±-----±----±-----------±------+
| Field | Type | Null | Key | Default | Extra |
±------------------±-------------±-----±----±-----------±------+
| name | varchar(140) | NO | PRI | NULL | |
| creation | datetime(6) | YES | MUL | NULL | |
| modified | datetime(6) | YES | | NULL | |
| modified_by | varchar(140) | YES | | NULL | |
| owner | varchar(140) | YES | | NULL | |
| docstatus | tinyint(4) | NO | | 0 | |
| idx | int(11) | NO | | 0 | |
| _user_tags | text | YES | | NULL | |
| _comments | text | YES | | NULL | |
| _assign | text | YES | | NULL | |
| _liked_by | text | YES | | NULL | |
| nombre_cliente | varchar(140) | YES | | NULL | |
| telefono_contacto | varchar(140) | YES | | NULL | |
| fecha_salida | datetime(6) | YES | | NULL | |
| estado | varchar(140) | YES | | NULL | |
| direccion_inicio | text | YES | | NULL | |
| naming_series | varchar(140) | YES | | 73f33ve6g4 | |
| vehiculo | varchar(140) | YES | | NULL | |
| referencia | varchar(140) | YES | UNI | 73f33ve6g4 | |
±------------------±-------------±-----±----±-----------±------+
The Field referencia, was one of my tries that I deleted (I didn’t named it naming_series, but referencia, my bad!), but remained in the table, when I try to create a new “Solicitud de reserva” in the front end, the first time works as I would expect, creating the record with “ID P-2025-12-0003”, but the second time it throws an error “referencia debe ser único” (“referencia has to be unique”), I deleted this field in the front end and I couldn’t understand what was happening at first → got frustrated!, (it was still in the table with Key UNI).
Also on one of my tries I did name the field “naming_series”, didn’t work, deleted it and on the latest try I also created the Field “naming_series” since everything points that it’s the name it has to be. But the nagging point here is that I couldn’t get read of the default 73f33ve6g4 no matter how many things I tried, deleting the cache with bench --site irfan.cabs clear-cache or bench --site irfan.cabs clear-website-cache, also trying a different browser, just to make sure it was not a browser cache thing. Nothing seems to work. This code 73f33ve6g4 belonged to a previous Document Naming Rule that was also deleted, It was nowhere to be found when I searched the database with SELECT in different tables, like:
MariaDB [_a27fa9b18cffdd35]> SELECT * FROM tabDocument Naming Rule WHERE name = ‘73f33ve6g4’;
Makes sense since I’ve deleted that Document Naming Rule.
So I deleted again the field (in frappe desk Build DocType) and also made sure that those columns where dropped from the table:
MariaDB [_a27fa9b18cffdd35]> ALTER TABLE tabSolicitud de reserva DROP COLUMN naming_series;
MariaDB [_a27fa9b18cffdd35]> ALTER TABLE tabSolicitud de reserva DROP COLUMN referencia;
deleting the field while working in the browser in frappe desk Build DocType is just not enough.
Now there is no “referencia” nor “naming_series” in the json file of the doctype, neither it is in table DESC. I think it is clean now and I can create the field again with nothing there from past tries to fear.
Now in the json file I get:
…
“autoname”: “naming_series:”
…
…
{
“default”: “1lvtj3rpd4”,
“fieldname”: “naming_series”,
“fieldtype”: “Select”,
“hidden”: 1,
“label”: "C\u00f3digo ",
“options”: “1lvtj3rpd4”,
“read_only”: 1,
“reqd”: 1
}
…
But I still get in the DESC of the table this:
…
| naming_series | varchar(140) | YES | | 73f33ve6g4 | |
…
The nagging reference to the deleted Document naming rule 73f33ve6g4, while it should be the latest and new created Document naming rule 1lvtj3rpd4.
Then I executed this code in mariadb:
MariaDB [_a27fa9b18cffdd35]> ALTER TABLE tabSolicitud de reserva
→ ALTER COLUMN naming_series DROP DEFAULT;
Query OK, 0 rows affected (0.020 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [_a27fa9b18cffdd35]> UPDATE tabSolicitud de reserva SET naming_series = NULL WHERE naming_series = ‘73f33ve6g4’;
Query OK, 0 rows affected (0.001 sec)
Rows matched: 0 Changed: 0 Warnings: 0
MariaDB [_a27fa9b18cffdd35]> DESC tabSolicitud de reserva;
And finally got:
| naming_series | varchar(140) | YES | | NULL | |
went to the front end, check the naming_series field and in options and in default was the right code 1lvtj3rpd4, make a change in the label text just to notice the front end of the changes and saved it.
went back to mariadb console and there it was!
| naming_series | varchar(140) | YES | | 73f33ve6g4 | |
the 73f33ve6g4 that I can’t get rid off.
So, I just don’t know what is going on. Time for a bit of brute force I guess.
(frappe-env) ubuntu@frappe-dev:~/frappe-bench$ mysqldump -u root -p _a27fa9b18cffdd35 tabSolicitud\ de\ reserva > solicitud_reserva_backup.sql
and modified the line so it reads with the default I want to get:
naming_series varchar(140) DEFAULT ‘1lvtj3rpd4’
Here’s the full sql:
DROP TABLE IF EXISTS tabSolicitud de reserva;
/*!40101 SET @saved_cs_client = @@character_set_client /;
/!40101 SET character_set_client = utf8mb4 /;
CREATE TABLE tabSolicitud de reserva (
name varchar(140) NOT NULL,
creation datetime(6) DEFAULT NULL,
modified datetime(6) DEFAULT NULL,
modified_by varchar(140) DEFAULT NULL,
owner varchar(140) DEFAULT NULL,
docstatus tinyint(4) NOT NULL DEFAULT 0,
idx int(11) NOT NULL DEFAULT 0,
_user_tags text DEFAULT NULL,
_comments text DEFAULT NULL,
_assign text DEFAULT NULL,
_liked_by text DEFAULT NULL,
nombre_cliente varchar(140) DEFAULT NULL,
telefono_contacto varchar(140) DEFAULT NULL,
fecha_salida datetime(6) DEFAULT NULL,
estado varchar(140) DEFAULT NULL,
direccion_inicio text DEFAULT NULL,
vehiculo varchar(140) DEFAULT NULL,
naming_series varchar(140) DEFAULT ‘1lvtj3rpd4’,
PRIMARY KEY (name),
KEY creation (creation)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
/!40101 SET character_set_client = @saved_cs_client */;
and in mariadb console:
MariaDB [_a27fa9b18cffdd35]> DROP TABLE tabSolicitud de reserva;
Then I import the modified sql with:
(frappe-env) ubuntu@frappe-dev:~/frappe-bench$ mysql -u root -p _a27fa9b18cffdd35 < solicitud_reserva_backup.sql
and finally in mariadb console I can read:
MariaDB [_a27fa9b18cffdd35]> DESC tabSolicitud de reserva;
±------------------±-------------±-----±----±-----------±------+
| Field | Type | Null | Key | Default | Extra |
±------------------±-------------±-----±----±-----------±------+
…
…
| naming_series | varchar(140) | YES | | 1lvtj3rpd4 | |
±------------------±-------------±-----±----±-----------±------+
This 1lvtj3rpd4 is the reference to the Document naming rule I wanted to use.
Now is working when I add new records I get: P-2025-12-0004, P-2025-12-0005, P-2025-12-0006,…
Brute force solution seemed to have worked, or it hasn’t? I mean, not fully happy with this, because if a I change to a different Document naming rule I might get into trouble again? Also, I’m not good at python or frappe, just learning and I feel I just got this out of being stubborn rather than using skill. I don’t know if I could have solved it in a better way, I guess I could.
So… any feedback will be wellcomed. Hope you can replicate this experience and come out with a better solution or fix.
Thanxs for the hard work in creating frappe!