Projects automatic numbering – workaround using client custom script

Thank you @root13F, I have it done, followed exactly the steps you described. But Im still geting error mentioned above when trying to install that app.
I have erpnext installed as production and then switched to development mode by entry in site_config.json. Erpnext path is /home/frappe/frappe-bench/apps/erpnext and my custom app path is /home/frappe/frappe-bench/apps/myapp.
App is created by bench new-app and there are only exported fixtures and that autoname function. I tried it also with custom app when there were only exported fixtures, before adding autoname function, and it also didnt work, so the problem is probably not related to that function.

please post your site_config.json

I think the error arises from how you added the developer_mode

This is my site_config.json

{
“db_name”: “xxxxxx”,
“db_password”: “xxxxxx”,
“developer_mode”: 1
}

EDIT: deleted old site_config.json and rewrited it manually and now Im getting this

frappe@ubusrv16:~/frappe-bench$ bench --site site1.local install-app myapp
Could not find app “myapp”
frappe@ubusrv16:~/frappe-bench$ ll apps/
total 28
drwxr-xr-x 7 frappe frappe 4096 Dec 23 16:19 ./
drwxr-xr-x 8 frappe frappe 4096 Dec 22 19:37 …/
drwxr-xr-x 8 frappe frappe 4096 Dec 22 19:40 erpnext/
drwxr-xr-x 6 frappe frappe 4096 Dec 22 19:45 foundation/
drwxr-xr-x 9 frappe frappe 4096 Dec 22 19:35 frappe/
drwxr-xr-x 5 frappe frappe 4096 Dec 22 19:37 frappe_io/
drwxr-xr-x 4 frappe frappe 4096 Dec 23 15:54 myapp/

You are finding your way - this post I happened on may help Custom Doctype Naming Series Code Snippet

@root13F
I gave up installing it for another instance for the moment and trying to make it work locally. I have made some progress, but now I’m getting this message, what arises when I try to save project - ImportError: No module named validations.validations

This is content of my validations.py file:

import frappe
from frappe.model.naming import make_autoname
def autoname(doc, method):
doc.name = make_autoname(“PROJ”+‘-.#####’)

I get this message no matter what my autoname function contains:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/client.py”, line 143, in insert
doc = frappe.get_doc(doc).insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 215, in insert
self.set_new_name()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 375, in set_new_name
set_new_name(self)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/naming.py”, line 38, in set_new_name
doc.run_method(“autoname”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 757, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1023, in composer
hooks.append(frappe.get_attr(handler))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 919, in get_attr
return getattr(get_module(modulename), methodname)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 704, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)
ImportError: No module named validations.validations

@clarkej
Than you for a link, but if I use that snippets, I get the same error as above.

This is in v7 but there’s a weird workaround that frappe/erpnext doesn’t encourage: editing the naming series using the Property Setter doctype. :smiley:

This is exported as a fixture (via export-fixtures) .

I managed to change the Stock Ledger Entry naming series by manually adding an entry for Stock Ledger Entry-naming_series-default. It worked. :laughing:

PS:

The page specifically tells you:

Please don't update it as it can mess up your form. 
Use the Customize Form View and Custom Fields to set properties!

…which is reasonable. So please do this at your own risk and make necessary preparations (eg. do a backup) before hand.

1 Like