How to change sequence of applying multiple custom apps

We are working with multiple custom apps and wanted to reorder the sequence of migrating the modules. During installation the sequence followed was myapp3, myapp1, myapp2.

Found out the following

SELECT defvalue, defkey from tabDefaultValue where defkey = ‘installed_apps’;

If you update defvalue with correct sequence e.g.
from ‘[“frappe”, “erpnext”, “myapp3”, “myapp1”, “myapp2”]’

to ‘[“frappe”, “erpnext”, “myapp1”, “myapp2”, “myapp3”]’

You will see the solution above.

The tabDefaultValue stores many defaults and one of them is installed_app.

Mitesh Choksi, [03.07.19 19:20]
Is anybody working with multiple custom apps and want to reorder the sequence of migrating the modules?

installed = json.loads(db.get_global(“installed_apps”) or “[]”)

master branch
frappe/frappe/init.py
Line 870 points to this

1 Like

I think this solution is no longer valid
We changed the order in sites/apps.txt and reloaded supervisor and it worked

1 Like

me too which i found that erpnext app overided my custom app hooks and the erpnext logo apper instaed of my cutom app logo
as the apps order chanhed in sites/apps.txt

so i reorderd it again in sites/apps.txt and all back ok

Hope it works in multi-tenant setup as well.

Ensure you reorder apps.txt after running bench setup requirements or bench update because bench will overwrite your ordering to the order specified by the code below from bench/bench.py.

You might think: so what? But the order matters because it specifies the order that modules are loaded and hence overridden.

So the order you should do things:

  1. bench setup requirements
  2. manually reorder apps.txt (and take a copy for next time)
  3. bench restart
  4. bench --site <site> clear-cache
  5. bench --site <site> clear-website-cache
	def initialize_apps(self):
		try:
			self.apps = [
				x
				for x in os.listdir(os.path.join(self.bench.name, "apps"))
				if is_frappe_app(os.path.join(self.bench.name, "apps", x))
			]
			self.apps.remove("frappe")
			self.apps.insert(0, "frappe")

True up to v14/15 at least

2 Likes