Creating- Document Management App

Hello, I am working on creating a document management app. I am new to web development but I have been programming for 20+ years. Mostly embedded systems.

I will describe the basic concept. I am looking for suggestion on how to approach integrating it with frappe and erpnext apps.

Intention of the app: To track changes too engineering drawings (Documents) and associate them with Items to be manufactured. To track changes to legal documents and associate them with customers and distributors. Each new Document created in ERPNext will get a title based on the type of document and a unique serial number.

When the first file is attached it will be assigned revision 000 and tab 00. During the attachment process the file is renamed to format:
GROUP-TYPE_########## = GROUP-TYPE_serialnumber_revision_tab
Example: DWG-ENG_100100_00_00

Subsequent attachments will get a new revision or possibly tab. The serial never changes.

The new Documents can then be associated with manufactured parts like laser cut acrylic parts. Or PCB’s with gerber and hole files that have to be tracked.


I have figured out how to generate the Document name and serial number using naming_series. I have figured out how to configure the custom_doctype for Document.

What I really could use are some suggestions on how to handle the attachments…

Currently I have modified frappe’s upload.js file to handle the rename if the docype is Document. i.e.

I removed the code so others are not encouraged to take this route. See below…
#End Edit

I know this is not the correct way to do this but I am not as familiar with adding custom script. Any suggestions?

I had this mostly working but had a bench update accident and am starting over with a new custom app in bench.

I will post more soon. Thanks everyone…

1 Like

@zeroxcorbin welcome to the forum sorry for the late reply.

The best way to handle this is to change the filename server side.

You can introduce a hook, for the function that sets the filename: frappe/ at develop · frappe/frappe · GitHub

You can all this as get_hook_method and then fallback on the standard way of naming (i.e the name supplied by the uploader)

Then send us a PR so we can add this in the product and your updates will be future safe.

1 Like

@rmehta Thank you for the reply. I am working to learn the correct way to do all this. Thanks to the responses I have received on this forum I believe I am heading down the correct path now.

I removed all my code changes I made to ERPNext and Frappe. I created a new app using bench, created the doctype, and am working on the code. I am not as familiar with Python and JavaScript but your video series has been very helpful.

I plan to commit anything I have to git. When I figure out how to work with git a little better.

Thank you for the guidance on hooks. I had seen them defined in a few files but did not know how to use them. Still don’t really. Alas, that is what the forums are for.

I will keep this updated as I progress.

Thank you,

1 Like

Check this out:

Thanks, simple but effective.