I’d like to create a custom field for Users that will store their Twilio phone number.…
- User
I’d like to create a custom field for Users that will store their Twilio phone number.
It will be used for a custom Dialog I am building to send SMS messages via Twilio from Lead/Contact forms.
The problem is that apparently ERPNext doesn’t allow “Core” Doctypes to be customized.
What’s the best way to add a custom field for users?
- Assistant
In ERPNext, while it is true that core DocTypes have limitations on direct customization, you can extend them by following a structured approach. Here's a step-by-step guide to add a custom field to store Twilio phone numbers for Users:
-
Custom App Creation:
- If you haven't already, create a custom app using the bench command. This is necessary to encapsulate your customizations and keep them separate from the core ERPNext code.
bench new-app my_customizations
- If you haven't already, create a custom app using the bench command. This is necessary to encapsulate your customizations and keep them separate from the core ERPNext code.
-
- User
This is how I did it. Add this to ur hooks.py:
fixtures = [
# Adding custom fields to User doctype { "doctype": "Custom Field", "filters": [ ["dt", "=", "User"] ] } ] I already had a fixtures directory generated, if you don’t have one you can simply create one in the same directory as your hooks.py called “fixtures”. In there I created a file called “custom_fields.json” with the following content:[ { "doctype": "Custom Field", "name": "User-signature",
"dt": "User", "fieldname": "signature", "fieldtype": "Signature", "insert_after": "username", "label": "Signature" }, { "doctype": "Custom Field", "name": "User-job_title",
"dt": "User", "fieldname": "job_title", "fieldtype": "Data", "insert_after": "mobile_no", "label": "Job Title" } ](Use “insert_after” to insert your custom field after a core doctype field.)
- Assistant
- User
اشرح لي الخطوات بالتفصيل وترتيب
- Assistant
بالطبع، سأشرح لك الخطوات بالتفصيل وبالترتيب لإضافة حقل مخصص لحفظ رقم هاتف Twilio لمستخدمي ERPNext باستخدام طريقة الـ fixtures:
الخطوة 1: إعداد التطبيق المخصص
-
إنشاء تطبيق مخصص: إذا لم يكن لديك تطبيق مخصص بعد، قم بإنشاء واحد باستخدام الأمر التالي:
-
- User
اين اقوم با إنشاء ملف custom_fields.json
- Assistant
يمكنك إنشاء ملف
custom_fields.jsonداخل الدليل المسمىfixturesالذي يجب أن يكون موجوداً داخل التطبيق المخصص الذي أنشأته. إليك خطوات بسيطة لإعداد هذا الملف:الخطوات بالتفصيل:
-
الذهاب إلى دليل التطبيق المخصص:
- أولاً، قم بالانتقال إلى مجلد التطبيق المخصص الذي أنشأته سابقًا. يمكنك القيام بذلك عبر سطر الأوامر باستخدام الأمر التالي (قم بتغيير
my_customizationsإلى اسم تطبيقك):cd frappe-bench/apps/my_customizations
- أولاً، قم بالانتقال إلى مجلد التطبيق المخصص الذي أنشأته سابقًا. يمكنك القيام بذلك عبر سطر الأوامر باستخدام الأمر التالي (قم بتغيير
-
إنشاء دليل
fixtures:- إذا لم يكن هناك بالفعل، يمكنك إنشاء مجلد جديد باسم داخل دليل التطبيق باستخدام الأمر:
-