How to install modules automatically

I have doc type which needs the help of other module which is not pre-installed when i install erpnext. so installed this module using pip install now it is working in my local now i moved my current updated work to
pre production server when i open this doctype i get error module not found so installed this module
in my pre production server and now i wish is there any way to install this external modules at the time of installation or setting up of erpnext.

What type of functionality are you looking for from your custom module/Doc Type? Can you share the code or functionality, so that someone can better assess if that functionality can be met with delivered code or you can also contribute it to the ERPNext core?

@Pawan

   # this is the module i want to install automatically wherever i install this instance
   import qrcode
   
    class MyDoctype(Document):
	    def before_save(self):
                 #generates qr code automatically
                 img = qrcode.make(daa_box_number)
                 img.save(./path_to_files_directory)

please help me with this

i tried to add it in requirement.txt but it is not working

Maybe you can create a new field type for “qr code” and build something similar to Is there a way to create a new field type? - #7 by revant_one and look to contribute it back using Pull Request to ERPNext core

2 Likes

@Pawan i don’t want a new field instead i want to install a module. just like add module name in requirement.txt and when i bench update this module should be installed.

hope now i am clear to you

thanks.

@shahid_ecit It is not clear to me what you mean by module, and unfortunately it can mean more than one thing in this context.

  1. Python module? ‘qrcode’
  2. Frappe module, like ‘frappe-bench/apps/qrcode’, where module == app?
  3. Something else entirely?

For 1) you could solve it by importing your module in place and then calling a whitelisted function from other doctypes.
For 2) it sounds like you may need to bring some qrcode images with you when install it, in which case you should look at the fixtures functionality in hooks.py
For 3) we’ll need a more detailed problem statement.

1 Like

@tmatteson sorry what i meant was library

python’s qrcode library

It updates environment on bench update:

Updating Python libraries...
INFO:bench.utils:./env/bin/pip install --upgrade pip
Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
INFO:bench.utils:./env/bin/pip install -q -r /home/frappe/.bench/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/custom_app/requirements.txt
2 Likes

@revant_one i was adding this one in bench-repo/requirement.txt

but now i got that have to i to the erpnext/requirement.txt file

sorry i should have been checked this before i asking

really sorry

and thanks for the time