added new field custom note in payment entry, also little fixes to report bug (not fixed)
This commit is contained in:
parent
e272094f74
commit
55b3b4e27b
|
|
@ -0,0 +1,30 @@
|
|||
import frappe
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
|
||||
|
||||
def create_custom_fields():
|
||||
custom_fields = {
|
||||
"Payment Entry": [
|
||||
dict(
|
||||
fieldname='custom_note',
|
||||
label='Note',
|
||||
fieldtype='Data',
|
||||
insert_after='status'
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
for doctype, fields in custom_fields.items():
|
||||
for field in fields:
|
||||
# Попытка удалить поле, если оно существует
|
||||
if frappe.db.exists("Custom Field", {"dt": doctype, "fieldname": field['fieldname']}):
|
||||
try:
|
||||
custom_field_name = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": field['fieldname']}, "name")
|
||||
frappe.delete_doc("Custom Field", custom_field_name)
|
||||
frappe.db.commit()
|
||||
print(f"Deleted field {field['fieldname']} in {doctype}")
|
||||
except Exception as e:
|
||||
print(f"Failed to delete field {field['fieldname']} in {doctype}: {e}")
|
||||
|
||||
# Создание поля
|
||||
create_custom_field(doctype, field)
|
||||
print(f"Created field {field['fieldname']} in {doctype}")
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
from frappe.core.doctype.report.report import Report
|
||||
import datetime
|
||||
import frappe
|
||||
|
||||
class CustomReport(Report):
|
||||
def execute_script_report(self, filters):
|
||||
# save the timestamp to automatically set to prepared
|
||||
threshold = 99999999
|
||||
|
||||
start_time = datetime.datetime.now()
|
||||
|
||||
# The JOB
|
||||
if self.is_standard == "Yes":
|
||||
res = self.execute_module(filters)
|
||||
else:
|
||||
res = self.execute_script(filters)
|
||||
|
||||
# automatically set as prepared
|
||||
execution_time = (datetime.datetime.now() - start_time).total_seconds()
|
||||
if execution_time > threshold and not self.prepared_report and not frappe.conf.developer_mode:
|
||||
frappe.enqueue(enable_prepared_report, report=self.name)
|
||||
|
||||
frappe.cache.hset("report_execution_time", self.name, execution_time)
|
||||
|
||||
return res
|
||||
|
|
@ -12,6 +12,17 @@ doctype_js = {
|
|||
"Payment Entry": "public/js/payment_entry_mod.js"
|
||||
}
|
||||
|
||||
override_doctype_class = {
|
||||
"Report": "jey_erp.custom_report.CustomReport"
|
||||
}
|
||||
|
||||
after_migrate = "jey_erp.hooks.after_migrate_combined"
|
||||
|
||||
def after_migrate_combined():
|
||||
|
||||
from jey_erp.custom_fields import create_custom_fields
|
||||
create_custom_fields()
|
||||
|
||||
# Includes in <head>
|
||||
# ------------------
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue