ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Automatic import ? Is it possible ? If yes, how?

import
event-hooks

#1

I’m looking for a way to automatically import my sales orders from a remote csv file. If any of you know the procedure to follow, I would very much like him to send me the exact procedure, please :slight_smile:


Automatic import flow
#2

Hello! A Data Import tool/feature exists in Frappe/ERPNext but your csv file needs to follow a specific format for it to work.

More on this here: https://erpnext.org/docs/user/manual/en/setting-up/data/data-import

Cheers


#3

Thank you for your quick response, but I would like the automatic evening import every hour. I have seen a lot of post on HOOKS.PY, CRONTAB and API but there is no explicit tutorial on it.


#4

@YannCoppryDigital, do you have a python code which reads the csv file and then imports it into a sales order? If anything you’ll need to:

  1. Create a python file (in your app) which will read the csv file and import it into a sales order.
  2. Create a “Scheduled Task” OR a cronjob (pick one.). Both can be added to hooks.py. EG: If you want to add an “hourly” event, you can do something like this:
scheduler_events = {
    "hourly": [
        "the_name_of_the_custom_app.the_python_file.the_name_of_the_function",
        "example_app.folder_name.folder_name.the_python_file.function2"
    ],

…of course, for a cron job, it’ll be something different.

  1. Restart bench. Check if it runs.

#5

Thank you @littlehera for these lights, it will help me a lot :slight_smile:
Can you guide me on creating the pyhton file that should read the CSV file? I will be very grateful to you :smiley:


#7

Yes its quite available and doable, please read the docs, online help, check a youtube video, search the forum and inform yourself. Let us know when you get stuck.