Developer Tutorial

515 views
Skip to first unread message

Rushabh Mehta

unread,
May 12, 2014, 6:01:02 AM5/12/14
to erpnext-dev...@googlegroups.com
Dear all,

We have finally started work on the developer documentation and here is a quick guide on how to create applications in Frappe:


Do send your feedback!

best,
Rushabh



@rushabh_mehta

MP

unread,
May 13, 2014, 11:30:47 AM5/13/14
to erpnext-dev...@googlegroups.com
Thanks Rushabh. It is very useful and easy to follow.

How do we setup a new module within ERPNext in this new version? We want to create Land Management module and want it to be available along with Buying, HR and Stock module. Should we set it up as a new module or a new application? Remember we want it to be available on same Desktop as HR, Buying and Stock module? Thanks.

Kind regards,
Mayur Patel

Rushabh Mehta

unread,
May 14, 2014, 2:19:01 AM5/14/14
to erpnext-dev...@googlegroups.com
New application. It can be installed in any database.

@rushabh_mehta
via mobile
--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/a06f826b-d35d-4f1d-b454-cb5c3681bf24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

MP

unread,
May 14, 2014, 9:52:45 AM5/14/14
to erpnext-dev...@googlegroups.com
Thanks Rushabh.

After the bench is installed, I performed below steps for installing New Application (called IT) under existing ERPNext4-dev site. But I am getting some error.

- From /var/www/frappe-bench directory I executed ./env/bin/frappe --make_app apps
     App Name: it
     App Title: IT Management
     App Description: Manage all IT equipments
     App Publisher: MP
     App Icon: icon-book
     App Color: #589494
     App Email: test@....com
     App URL: it
     App License: Free

- From /var/www/frappe-bench/apps/it# I executed python setup.py develop
    running develop
    Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
    /usr/bin/python -E -c pass
    TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
    running egg_info
    creating it.egg-info
    writing requirements to it.egg-info/requires.txt
    writing it.egg-info/PKG-INFO
    writing top-level names to it.egg-info/top_level.txt
    writing dependency_links to it.egg-info/dependency_links.txt
    writing manifest file 'it.egg-info/SOURCES.txt'
    reading manifest file 'it.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.json'
    warning: no files found matching '*.css' under directory 'it'
    warning: no files found matching '*.csv' under directory 'it'
    warning: no files found matching '*.html' under directory 'it'
    warning: no files found matching '*.ico' under directory 'it'
    warning: no files found matching '*.js' under directory 'it'
    warning: no files found matching '*.json' under directory 'it'
    warning: no files found matching '*.md' under directory 'it'
    warning: no files found matching '*.png' under directory 'it'
    warning: no files found matching '*.svg' under directory 'it'
    warning: no previously-included files matching '*.pyc' found under directory 'it'
    writing manifest file 'it.egg-info/SOURCES.txt'
    running build_ext
    Creating /usr/local/lib/python2.7/dist-packages/it.egg-link (link to .)
    Adding it 0.0.1 to easy-install.pth file

    Installed /var/www/frappe-bench/apps/it
    Processing dependencies for it==0.0.1
    Searching for frappe
    Reading http://pypi.python.org/simple/frappe/
    Couldn't find index page for 'frappe' (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading http://pypi.python.org/simple/
    No local packages or download links found for frappe
    error: Could not find suitable distribution for Requirement.parse('frappe')

- I added 'it' in /var/www/frappe-bench/sites/apps.txt

- From /var/www/frappe-bench/sites# I executed ../env/bin/frappe erpnext4-dev --install_app it
  Traceback (most recent call last):
  File "../env/bin/frappe", line 9, in <module>
    load_entry_point('frappe==4.0.0', 'console_scripts', 'frappe')()
  File "/var/www/frappe-bench/apps/frappe/frappe/cli.py", line 45, in main
    frappe.init(site, sites_path=sites_path)
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 109, in init
    setup_module_map()
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 443, in setup_module_map
    for module in get_module_list(app):
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 377, in get_module_list
    return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt"))
  File "/var/www/frappe-bench/apps/frappe/frappe/__init__.py", line 354, 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 it

Could you please let me know what I am doing wrong?

Kind regards,
MP


Rushabh Mehta

unread,
May 14, 2014, 12:07:22 PM5/14/14
to erpnext-dev...@googlegroups.com
Should work. Is your directory structure ok (is the module discoverable?)

Can you go to python shell and import "it"?



@rushabh_mehta

--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.

Pratik Vyas

unread,
May 14, 2014, 12:13:32 PM5/14/14
to erpnext-dev...@googlegroups.com
Hi Mayur

On Wed, May 14, 2014 at 7:21 PM, MP <mayur....@gmail.com> wrote:
> Thanks Rushabh.
>
> --
> Note:
>
> If you are posting an issue,
> 1. We should be able to replicate it at our end. So please give us as much
> information as you can. Please see it from the point of view of the person
> receiving the communication.
> 2. Paste your code at http://pastebin.com or http://gist.github.com and send
> only the URL via email
> 3. For sending images, use http://imgur.com or other similar services. Do
> not send images as attachments. Links are good. Same goes for any file you
> are going to send.
>
> End of Note
> ---
> You received this message because you are subscribed to the Google Groups
> "ERPNext Developer Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to erpnext-developer...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/erpnext-developer-forum/ae544dc5-3364-4515-a4b0-dfe68a043ca6%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

The `python setup.py develop` should be run in the env

so, run `path/to/env/bin/python setup.py develop`

Also, are you running all this as root?

--
Pratik
erpnext

Pingpan Cheng

unread,
May 29, 2014, 11:51:36 AM5/29/14
to erpnext-dev...@googlegroups.com
It solved the problem perfectly!

Pingpan Cheng

unread,
May 29, 2014, 3:02:40 PM5/29/14
to erpnext-dev...@googlegroups.com
Hi Rushabh,

I followed the guide but got some problems when I tried to start the library application:

Here are the logs:

frappe --serve
 * Running on http://0.0.0.0:8000/
 * Restarting with reloader
127.0.0.1 - - [29/May/2014 14:41:42] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [29/May/2014 14:41:42] "GET /style_settings.css HTTP/1.1" 200 -
127.0.0.1 - - [29/May/2014 14:41:42] "GET /website_script.js HTTP/1.1" 200 -
127.0.0.1 - - [29/May/2014 14:41:44] "POST / HTTP/1.1" 200 -
127.0.0.1 - - [29/May/2014 14:41:44] "GET /desk HTTP/1.1" 200 -
127.0.0.1 - - [29/May/2014 14:41:44] "POST / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/middlewares.py", line 15, in __call__
    return super(StaticDataMiddleware, self).__call__(environ, start_response)
  File "/home/life/Desktop/gitHub/frappe-bench/env/lib/python2.7/site-packages/werkzeug/wsgi.py", line 579, in __call__
    return self.app(environ, start_response)
  File "/home/life/Desktop/gitHub/frappe-bench/env/lib/python2.7/site-packages/werkzeug/wsgi.py", line 579, in __call__
    return self.app(environ, start_response)
  File "/home/life/Desktop/gitHub/frappe-bench/env/lib/python2.7/site-packages/werkzeug/local.py", line 224, in application
    return ClosingIterator(app(environ, start_response), self.cleanup)
  File "/home/life/Desktop/gitHub/frappe-bench/env/lib/python2.7/site-packages/werkzeug/wrappers.py", line 285, in application
    return f(*args[:-2] + (request,))(*args[-2:])
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/app.py", line 46, in application
    response = frappe.handler.handle()
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/handler.py", line 84, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/__init__.py", line 495, in call
    return fn(*args, **newargs)
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/handler.py", line 15, in startup
    frappe.response.update(frappe.sessions.get())
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/sessions.py", line 112, in get
    bootinfo = get_bootinfo()
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/boot.py", line 37, in get_bootinfo
    bootinfo.modules.update(frappe.get_attr(app + ".config.desktop.get_data")() or {})
  File "/home/life/Desktop/gitHub/frappe-bench/apps/frappe/frappe/__init__.py", line 483, in get_attr
    return getattr(get_module(modulename), methodname)
AttributeError: 'module' object has no attribute 'get_data'


The desktop doesn't show up after I logged in. I removed the previous installation and started again, the same error appeared. What can be wrong here?


Question 2:

$ ./scripts/install.sh single test_1 test_1
New python executable in env/bin/python2.7
Traceback (most recent call last):
  File "./scripts/virtualenv.py", line 2365, in <module>
    main()
  File "./scripts/virtualenv.py", line 827, in main
    symlink=options.symlink)
  File "./scripts/virtualenv.py", line 987, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "./scripts/virtualenv.py", line 1279, in install_python
    shutil.copyfile(executable, py_executable)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 26] Text file busy: 'env/bin/python2.7'

What's wrong here?


Thanks so much!
Pingpan

Rushabh Mehta

unread,
May 29, 2014, 3:12:08 PM5/29/14
to erpnext-dev...@googlegroups.com
Pingpan,

Library app is not fixed after some latest updates. Will fix it tomorrow.

Will let Pratik handle the install question. But from what I understand, once you have installed, you do not need to run it again. To create a new db run

frappe sitename --install dbname

best,
Rushabh



@rushabh_mehta

--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/ce49318f-1e1d-4300-b498-95c3f40d2260%40googlegroups.com.

Pratik Vyas

unread,
May 29, 2014, 3:13:00 PM5/29/14
to erpnext-dev...@googlegroups.com
Have you made your own app, if so, in that you''ll have to do the
equivalent of https://github.com/frappe/erpnext/commit/e60853930bb25bbbe10823c0351e8de793e1fec4
(only for desktop.py)


--
Pratik
erpnext

Pratik Vyas

unread,
May 29, 2014, 3:15:07 PM5/29/14
to erpnext-dev...@googlegroups.com
>
> Question 2:
>
> $ ./scripts/install.sh single test_1 test_1
> New python executable in env/bin/python2.7
> Traceback (most recent call last):
> File "./scripts/virtualenv.py", line 2365, in <module>
> main()
> File "./scripts/virtualenv.py", line 827, in main
> symlink=options.symlink)
> File "./scripts/virtualenv.py", line 987, in create_environment
> site_packages=site_packages, clear=clear, symlink=symlink))
> File "./scripts/virtualenv.py", line 1279, in install_python
> shutil.copyfile(executable, py_executable)
> File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
> with open(dst, 'wb') as fdst:
> IOError: [Errno 26] Text file busy: 'env/bin/python2.7'
>
> What's wrong here?
>

You can comment the virtualenv.py part in install.sh and try again.
>
> Thanks so much!
> Pingpan
>
>
> On Monday, May 12, 2014 6:01:02 AM UTC-4, rushabh wrote:
>>
>> Dear all,
>>
>> We have finally started work on the developer documentation and here is a
>> quick guide on how to create applications in Frappe:
>>
>> https://frappe.io/apps/frappe-framework/developers/guide
>>
>> Do send your feedback!
>>
>> best,
>> Rushabh
>>
>>
>>
>> @rushabh_mehta
>> https://erpnext.org
>>
> --
> Note:
>
> If you are posting an issue,
> 1. We should be able to replicate it at our end. So please give us as much
> information as you can. Please see it from the point of view of the person
> receiving the communication.
> 2. Paste your code at http://pastebin.com or http://gist.github.com and send
> only the URL via email
> 3. For sending images, use http://imgur.com or other similar services. Do
> not send images as attachments. Links are good. Same goes for any file you
> are going to send.
>
> End of Note
> ---
> You received this message because you are subscribed to the Google Groups
> "ERPNext Developer Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to erpnext-developer...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/erpnext-developer-forum/ce49318f-1e1d-4300-b498-95c3f40d2260%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Pratik
erpnext

Pingpan Cheng

unread,
May 29, 2014, 3:20:37 PM5/29/14
to erpnext-dev...@googlegroups.com
I don't believe I did. I just followed the guide developing the library app.

Thanks,
Pingpan

Pingpan Cheng

unread,
May 29, 2014, 3:47:13 PM5/29/14
to erpnext-dev...@googlegroups.com
Hi Pratik,

Do you have any solutions about my first question?

Thanks so much.
Pingpan
Rushabh



@rushabh_mehta

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages