Fixture can run only intall time

Hello

I have created custom app and introduce fixture, but whenever migrate fixture can run and reenter data. I want run fixture only once at the time of install or check condition if data exist or not.

after migrate activity log also showing weird, see the attachment

Hi @Pritesh

See install hooks instead …

https://docs.frappe.io/framework/user/en/python-api/hooks#install-hooks

Hope this helps.

Hello

In hook, how can we run fixture JSON, or need to write python insert query ?

Hi @Pritesh , Instead of Json Fixtures you can use a python script which execute after_install only.

from frappe.custom.doctype.custom_field.custom_field import create_custom_fields

def add_custom_fields():
    fields ={ "Sales Invoice": [
        dict(
			fieldname="codice_iva",
			label="Codice IVA",
			fieldtype="Float",
			insert_after="tax_rate",
			print_hide=1,
			hidden=0,
			read_only=1,
		)
]}
create_custom_fields(custom_fields)