mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
chore: frappe.whitelist for doc methods (#25068)
* chore: frappe.whitelist for doc methods * fix: incorrect spelling * fix: sider issue Co-authored-by: Sagar Vora <sagar@resilient.tech>
This commit is contained in:
@@ -71,6 +71,7 @@ class CropCycle(Document):
|
||||
"exp_end_date": add_days(start_date, crop_task.get("end_day") - 1)
|
||||
}).insert()
|
||||
|
||||
@frappe.whitelist()
|
||||
def reload_linked_analysis(self):
|
||||
linked_doctypes = ['Soil Texture', 'Soil Analysis', 'Plant Analysis']
|
||||
required_fields = ['location', 'name', 'collection_datetime']
|
||||
@@ -87,6 +88,7 @@ class CropCycle(Document):
|
||||
frappe.publish_realtime("List of Linked Docs",
|
||||
output, user=frappe.session.user)
|
||||
|
||||
@frappe.whitelist()
|
||||
def append_to_child(self, obj_to_append):
|
||||
for doctype in obj_to_append:
|
||||
for doc_name in set(obj_to_append[doctype]):
|
||||
|
||||
@@ -7,6 +7,7 @@ import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Fertilizer(Document):
|
||||
@frappe.whitelist()
|
||||
def load_contents(self):
|
||||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Fertilizer'})
|
||||
for doc in docs:
|
||||
|
||||
@@ -8,6 +8,7 @@ from frappe.model.naming import make_autoname
|
||||
from frappe.model.document import Document
|
||||
|
||||
class PlantAnalysis(Document):
|
||||
@frappe.whitelist()
|
||||
def load_contents(self):
|
||||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Plant Analysis'})
|
||||
for doc in docs:
|
||||
|
||||
@@ -7,6 +7,7 @@ import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class SoilAnalysis(Document):
|
||||
@frappe.whitelist()
|
||||
def load_contents(self):
|
||||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Soil Analysis'})
|
||||
for doc in docs:
|
||||
|
||||
@@ -13,6 +13,7 @@ class SoilTexture(Document):
|
||||
soil_edit_order = [2, 1, 0]
|
||||
soil_types = ['clay_composition', 'sand_composition', 'silt_composition']
|
||||
|
||||
@frappe.whitelist()
|
||||
def load_contents(self):
|
||||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Soil Texture'})
|
||||
for doc in docs:
|
||||
@@ -26,6 +27,7 @@ class SoilTexture(Document):
|
||||
if sum(self.get(soil_type) for soil_type in self.soil_types) != 100:
|
||||
frappe.throw(_('Soil compositions do not add up to 100'))
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_soil_edit(self, soil_type):
|
||||
self.soil_edit_order[self.soil_types.index(soil_type)] = max(self.soil_edit_order)+1
|
||||
self.soil_type = self.get_soil_type()
|
||||
@@ -35,8 +37,8 @@ class SoilTexture(Document):
|
||||
if sum(self.soil_edit_order) < 5: return
|
||||
last_edit_index = self.soil_edit_order.index(min(self.soil_edit_order))
|
||||
|
||||
# set composition of the last edited soil
|
||||
self.set( self.soil_types[last_edit_index],
|
||||
# set composition of the last edited soil
|
||||
self.set(self.soil_types[last_edit_index],
|
||||
100 - sum(cint(self.get(soil_type)) for soil_type in self.soil_types) + cint(self.get(self.soil_types[last_edit_index])))
|
||||
|
||||
# calculate soil type
|
||||
@@ -67,4 +69,4 @@ class SoilTexture(Document):
|
||||
elif (c >= 40 and sa <= 45 and si < 40):
|
||||
return 'Clay'
|
||||
else:
|
||||
return 'Select'
|
||||
return 'Select'
|
||||
|
||||
@@ -9,11 +9,13 @@ from frappe.model.document import Document
|
||||
from frappe import _
|
||||
|
||||
class WaterAnalysis(Document):
|
||||
@frappe.whitelist()
|
||||
def load_contents(self):
|
||||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Water Analysis'})
|
||||
for doc in docs:
|
||||
self.append('water_analysis_criteria', {'title': str(doc.name)})
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_lab_result_date(self):
|
||||
if not self.result_datetime:
|
||||
self.result_datetime = self.laboratory_testing_datetime
|
||||
|
||||
@@ -7,6 +7,7 @@ import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Weather(Document):
|
||||
@frappe.whitelist()
|
||||
def load_contents(self):
|
||||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Weather'})
|
||||
for doc in docs:
|
||||
|
||||
Reference in New Issue
Block a user