How to export users(User doctype records) of a particular role using fixtures

I want to export users of a particular role using fixtures

Please define the below code in your custom app hooks.

import frappe
fixtures = [
	{
		"doctype": "User",
		"filters": [
			["name", "in", frappe.get_all("Has Role", filters={"role": ["in", ["Sales User", "Stock User"]]}, pluck="parent")]
		]
	}
]

After then run the command:

bench --site your-site.com export-fixtures
1 Like