ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Adding document on app install

customization
custom_script
erpnext

#1

There is a necesity to add a document during app install.
As I understand the code should be something like this:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from frappe import _

activity_type_in_office = frappe.get_doc({"doctype":"Activity Type", "name": "In Office"})
activity_type.insert(ignore_permissions=True)
activity_type.submit()

I’ve checked this guide and this cheatsheet but didn’t notice necessary guidance. Maybe instead of py script I can use a json file, and where in my app should I place such file?..

@surajshetty


#2

Check the after_install hook: https://github.com/frappe/erpnext/blob/develop/erpnext/hooks.py#L36

Please don’t @-mention people in your posts unless there is a specific reason. It is disrespectful of their time / attention.


#3

Ok, sorry for that, didn’t mean to be disrespectful.
Can’t express enough how in awe I’am every time I find something new about frappe, it is amazing. Sorry for troubling so much, will try to dial it down.
And thanks for suggestion.