Browse Source
* created Soil Analysis, Water Analysis, Weather and Fertilizer doctype * soil doctype edited and crop doctype added * minor stuff * Land Unit + Leaflet * crop cycle added * Land Unit changes + Crop cycle * autoname for plant_analysis * created Agriculture Task * minor stuff * - deleted agriculture_task - current state after the call * [Agriculture] modified fertilizer doctype to have a link to Item This was done so that the `Fertilizer` doctype could track the contents exclusive to the fertilizer, whereas the `Fertilizer Item` could be a seperate entity, so as to leverage the existing ERPNext doctypes * Added fields to `Water Analysis` doctype - Collection Datetime - Laboratory Testing Datetime - Results Datetime (default to Laboratory Testing Datetime) * Edited the doctypes `Agrivulture Task`, `Pest` and `Soil Texture` - Created `agriculture task` doctype - added fields `Common Name`, `Scientific Name`, `Treatment` and `Treatment Options` to `Pest` doctype - edited `Soil Texture` doctype to contain a soil texture ternary plot diagram made using SnapSVG. The code was put in public folder so as to be accessible by the entire agriculture module * Recursively reflect child land unit feature changes on parents * fixed feature repition bug * added legeneds to ternary plot * added stuff * changes * fix Task * reverted the Task Doctype to have naming in the form TASK.##### * fixed modifications made to TASK doctype * [dirty commit] added auto create Task from Crop on creation of Crop Cycle * Changed the Crop Cycle Doctype - Deleted the "Crop Cycly Task" doctype and its link from "Crop Cycle" - Creation of a new Project with the same name as the Crop Cycle on creation of a new Crop Cycle - Creation of all the tasks imported from Agriculture Task doctype of the Crop in the Crop Cycle * [Agriculture Module] Modifications - Created childtable doctype "Pest Detected" - Added childtable "Pest Detected" to Pest - Modified "Agriculture Task" to include "Start Day" and "End Day" of task - Modified the code in "Crop Cycle" to create a parent task with same name as Crop Cycle * [Agriculture Module] fixed Pest doctype not saving issue * [Agrcilture Module] Changes in Crop Cycle - removed the creation of a master task on creation of a new crop cycle - temporary fix to add the pest tasks from the pests added in crop cycle * land_unit_tree.js fields modified to have field objects instead of just field names * Revert "land_unit_tree.js modified" * land_unit_tree.js fields modified to have field objects instead of just field names * [Agriculture Domain] Converted Agriculture Module to a Domain - Converted into a Domain field from Select to Link field in Company doctype, linked to Domain doctype - Agriculture (alpha) is now a Domain * land_unit area aggregation enabled * land_unit.py checks feature diff for every ancestor and not just the parent * Removed unnecessary print messages * agriculture.py modified to include fixtures * fixtures added to setup.py inside agriculture module * [Agriculture Domain] UI tests added - 'materials' table renamed to 'materials_required' in 'Crop' - wrote UI test for Crop, Fertilizer, Crop Cycle, Pest, Water Analysis, Soil Texture - moved creation of tasks from client side to server side in Crop Cycle - Plant Analysis, Water Analysis, Soil Analysis, Soil Texture docs are now autonamed in the format PAnalysis.#####, WAnalysis.#####, SAnalysis.#####, STexture.##### respectively - company_name changed in domains.py from 'Schrute Farms.' to 'Schrute Farms' * [Agriculture Domain] Mostly written server side tests and moved client side code to server side - moved client side code to server side for Crop, Water Analysis, Pest, Soil Texture, - wrote server side tests for Crop, Crop Cycle, Fertilizer, Soil Texture, Pest - NOTE: none of the server side codes were tested * [Agriculture Domain] All server side tests working locally * [Agriculture Domain] Testing - added sample test for Land Unit, which needs to be modified to test multiple things - modified tests to be independant of each other * Land Units tests added and area aggregation code migrated to server side * added land_unit server side tests and on_trash added to land_unit * Changing field location for start date * [Agriculture Domain] deleted unnecessary comments * [Agriculture Domain] reverted changes * [Agriculture Domain] Modified the code to replace Pest doctype with Land Unit doctype - Deleted the Pest doctype and replaced it with the more generic Disease doctype - Deleted the Detected Pest doctype and replaced it with Detected Disease doctype * [Agriculture Domain] resolves #11654, resolves #11653 * [Agriculture] Added links to soil analysis, soil texture, plant analysis in crop cycle and land unit - not working perfectly yet - docs are fetched but not appended * [Agricuture] Crop Cycle modifed to link with relevent analysis docs, not fully functional * [Agriculture] added seperate stage for client side agriculture tests * [Agriculture] minor modification to crop_cycle.js test * [Agriculture] fixed tests * upgrade chromedriver in .travis.yml from 2.32 to 2.33 * [Agriculture] added land unit ui test * [Agriculture] added Agriculture server side test as a seperate stage in travis * tesing travis.yml * [Agriculture] Crop Cycle is able to fetch linked analysis docs * Modified travis.yml for modular server side testing * [minor fix][Agriculture] in soil_texture - fixed multiple soil_texture ternary plot creation on refresh - fixed error on soil composition change * Update .travis.yml * removed location field from linked doctypes * minor fixes and cleanup of agri * minor fix in agriculture and domain patches * permissions added to agriculture - Agriculture Manager and Agriculture User roles were added to all Agriculture doctypes * [Agriculture] - Created Agiculture Analysis Criteria and added sample records to it - All the analysis doctypes now fetch their fields inside a child table, form Agriculture Analysis Criteria - Also Fertilizer does the same This was introduced so that, new parameters could be added on demand * minor changes requested in Agriculture * minor changes * minor fix * Update desktop.py * Update .travis.ymldevelop
Ameya Shenoy
7 years ago
committed by
Nabin Hait
147 changed files with 11596 additions and 24 deletions
@ -0,0 +1,8 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Agriculture Analysis Criteria', { |
|||
refresh: function(frm) { |
|||
|
|||
} |
|||
}); |
@ -0,0 +1,155 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "field:title", |
|||
"beta": 0, |
|||
"creation": "2017-12-05 16:37:46.599982", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "title", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Title", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "standard", |
|||
"fieldtype": "Check", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Standard", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "linked_doctype", |
|||
"fieldtype": "Select", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Linked Doctype", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "\nWater Analysis\nSoil Analysis\nPlant Analysis\nFertilizer\nSoil Texture\nWeather", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 18:54:26.250707", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Agriculture Analysis Criteria", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "System Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"title_field": "", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class AgricultureAnalysisCriteria(Document): |
|||
pass |
@ -0,0 +1,23 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Agriculture Analysis Criteria", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Agriculture Analysis Criteria
|
|||
() => frappe.tests.make('Agriculture Analysis Criteria', [ |
|||
// values to be set
|
|||
{key: 'value'} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.key, 'value'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestAgricultureAnalysisCriteria(unittest.TestCase): |
|||
pass |
@ -0,0 +1,8 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Agriculture Task', { |
|||
refresh: function(frm) { |
|||
|
|||
} |
|||
}); |
@ -0,0 +1,199 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "ATask.########", |
|||
"beta": 0, |
|||
"creation": "2017-10-26 15:51:19.602452", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "task_name", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Task Name", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "", |
|||
"fieldname": "start_day", |
|||
"fieldtype": "Int", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Start Day", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "", |
|||
"fieldname": "end_day", |
|||
"fieldtype": "Int", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "End Day", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "Ignore holidays", |
|||
"fieldname": "holiday_management", |
|||
"fieldtype": "Select", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Holiday Management", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Ignore holidays\nPrevious Business Day\nNext Business Day", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "Low", |
|||
"fieldname": "priority", |
|||
"fieldtype": "Select", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Priority", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Low\nMedium\nHigh\nUrgent", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-06 01:13:14.512609", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Agriculture Task", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class AgricultureTask(Document): |
|||
pass |
@ -0,0 +1,23 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Agriculture Task", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Agriculture Task
|
|||
() => frappe.tests.make('Agriculture Task', [ |
|||
// values to be set
|
|||
{key: 'value'} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.key, 'value'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestAgricultureTask(unittest.TestCase): |
|||
pass |
@ -0,0 +1,7 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Crop', { |
|||
validate: (frm) => { |
|||
} |
|||
}); |
File diff suppressed because it is too large
@ -0,0 +1,18 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class Crop(Document): |
|||
def validate(self): |
|||
max_period = 0 |
|||
for task in self.agriculture_task: |
|||
# validate start_day is not > end_day |
|||
if task.start_day > task.end_day: |
|||
frappe.throw("Start day is greater than end day in task '{0}'".format(task.subject)) |
|||
# to calculate the period of the Crop Cycle |
|||
if task.end_day > max_period: max_period = task.end_day |
|||
if max_period > self.period: self.period = max_period |
@ -0,0 +1,11 @@ |
|||
from frappe import _ |
|||
|
|||
def get_data(): |
|||
return { |
|||
'transactions': [ |
|||
{ |
|||
'label': _('Crop Cycle'), |
|||
'items': ['Crop Cycle'] |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,116 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Crop", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(2); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Item
|
|||
() => frappe.tests.make('Item', [ |
|||
// values to be set
|
|||
{item_code: 'Basil Seeds'}, |
|||
{item_name: 'Basil Seeds'}, |
|||
{item_group: 'Seed'} |
|||
]), |
|||
// insert a new Item
|
|||
() => frappe.tests.make('Item', [ |
|||
// values to be set
|
|||
{item_code: 'Twigs'}, |
|||
{item_name: 'Twigs'}, |
|||
{item_group: 'By-product'} |
|||
]), |
|||
// insert a new Item
|
|||
() => frappe.tests.make('Item', [ |
|||
// values to be set
|
|||
{item_code: 'Basil Leaves'}, |
|||
{item_name: 'Basil Leaves'}, |
|||
{item_group: 'Produce'} |
|||
]), |
|||
// insert a new Crop
|
|||
() => frappe.tests.make('Crop', [ |
|||
// values to be set
|
|||
{title: 'Basil from seed'}, |
|||
{crop_name: 'Basil'}, |
|||
{scientific_name: 'Ocimum basilicum'}, |
|||
{materials_required: [ |
|||
[ |
|||
{item_code: 'Basil Seeds'}, |
|||
{qty: '25'}, |
|||
{uom: 'Nos'}, |
|||
{rate: '1'} |
|||
], |
|||
[ |
|||
{item_code: 'Urea'}, |
|||
{qty: '5'}, |
|||
{uom: 'Kg'}, |
|||
{rate: '10'} |
|||
] |
|||
]}, |
|||
{byproducts: [ |
|||
[ |
|||
{item_code: 'Twigs'}, |
|||
{qty: '25'}, |
|||
{uom: 'Nos'}, |
|||
{rate: '1'} |
|||
] |
|||
]}, |
|||
{produce: [ |
|||
[ |
|||
{item_code: 'Basil Leaves'}, |
|||
{qty: '100'}, |
|||
{uom: 'Nos'}, |
|||
{rate: '1'} |
|||
] |
|||
]}, |
|||
{agriculture_task: [ |
|||
[ |
|||
{task_name: "Plough the field"}, |
|||
{start_day: 1}, |
|||
{end_day: 1}, |
|||
{holiday_management: "Ignore holidays"} |
|||
], |
|||
[ |
|||
{task_name: "Plant the seeds"}, |
|||
{start_day: 2}, |
|||
{end_day: 3}, |
|||
{holiday_management: "Ignore holidays"} |
|||
], |
|||
[ |
|||
{task_name: "Water the field"}, |
|||
{start_day: 4}, |
|||
{end_day: 4}, |
|||
{holiday_management: "Ignore holidays"} |
|||
], |
|||
[ |
|||
{task_name: "First harvest"}, |
|||
{start_day: 8}, |
|||
{end_day: 8}, |
|||
{holiday_management: "Ignore holidays"} |
|||
], |
|||
[ |
|||
{task_name: "Add the fertilizer"}, |
|||
{start_day: 10}, |
|||
{end_day: 12}, |
|||
{holiday_management: "Ignore holidays"} |
|||
], |
|||
[ |
|||
{task_name: "Final cut"}, |
|||
{start_day: 15}, |
|||
{end_day: 15}, |
|||
{holiday_management: "Ignore holidays"} |
|||
] |
|||
]} |
|||
]), |
|||
// agriculture task list
|
|||
() => { |
|||
assert.equal(cur_frm.doc.name, 'Basil from seed'); |
|||
assert.equal(cur_frm.doc.period, 15); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
@ -0,0 +1,14 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
test_dependencies = ["Fertilizer"] |
|||
|
|||
class TestCrop(unittest.TestCase): |
|||
def test_crop_period(self): |
|||
basil = frappe.get_doc('Crop', 'Basil from seed') |
|||
self.assertEquals(basil.period, 15) |
@ -0,0 +1,80 @@ |
|||
[ |
|||
{ |
|||
"doctype": "Item", |
|||
"item_code": "Basil Seeds", |
|||
"item_name": "Basil Seeds", |
|||
"item_group": "Seed" |
|||
}, |
|||
{ |
|||
"doctype": "Item", |
|||
"item_code": "Twigs", |
|||
"item_name": "Twigs", |
|||
"item_group": "By-product" |
|||
}, |
|||
{ |
|||
"doctype": "Item", |
|||
"item_code": "Basil Leaves", |
|||
"item_name": "Basil Leaves", |
|||
"item_group": "Produce" |
|||
}, |
|||
{ |
|||
"doctype": "Crop", |
|||
"title": "Basil from seed", |
|||
"crop_name": "Basil", |
|||
"scientific_name": "Ocimum basilicum", |
|||
"materials_required": [{ |
|||
"item_code": "Basil Seeds", |
|||
"qty": "25", |
|||
"uom": "Nos", |
|||
"rate": "1" |
|||
}, { |
|||
"item_code": "Urea", |
|||
"qty": "5", |
|||
"uom": "Kg", |
|||
"rate": "10" |
|||
}], |
|||
"byproducts": [{ |
|||
"item_code": "Twigs", |
|||
"qty": "25", |
|||
"uom": "Nos", |
|||
"rate": "1" |
|||
}], |
|||
"produce": [{ |
|||
"item_code": "Basil Leaves", |
|||
"qty": "100", |
|||
"uom": "Nos", |
|||
"rate": "1" |
|||
}], |
|||
"agriculture_task": [{ |
|||
"task_name": "Plough the field", |
|||
"start_day": 1, |
|||
"end_day": 1, |
|||
"holiday_management": "Ignore holidays" |
|||
}, { |
|||
"task_name": "Plant the seeds", |
|||
"start_day": 2, |
|||
"end_day": 3, |
|||
"holiday_management": "Ignore holidays" |
|||
}, { |
|||
"task_name": "Water the field", |
|||
"start_day": 4, |
|||
"end_day": 4, |
|||
"holiday_management": "Ignore holidays" |
|||
}, { |
|||
"task_name": "First harvest", |
|||
"start_day": 8, |
|||
"end_day": 8, |
|||
"holiday_management": "Ignore holidays" |
|||
}, { |
|||
"task_name": "Add the fertilizer", |
|||
"start_day": 10, |
|||
"end_day": 12, |
|||
"holiday_management": "Ignore holidays" |
|||
}, { |
|||
"task_name": "Final cut", |
|||
"start_day": 15, |
|||
"end_day": 15, |
|||
"holiday_management": "Ignore holidays" |
|||
}] |
|||
} |
|||
] |
@ -0,0 +1,48 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Crop Cycle', { |
|||
refresh: (frm) => { |
|||
if (!frm.doc.__islocal) |
|||
frm.add_custom_button(__('Reload Linked Analysis'), () => frm.call("reload_linked_analysis")); |
|||
|
|||
frappe.realtime.on("List of Linked Docs", (output) => { |
|||
let analysis_doctypes = ['Soil Texture', 'Plant Analysis', 'Soil Analysis']; |
|||
let analysis_doctypes_docs = ['soil_texture', 'plant_analysis', 'soil_analysis']; |
|||
let obj_to_append = {soil_analysis: [], soil_texture: [], plant_analysis: []}; |
|||
output['Land Unit'].forEach( (land_doc) => { |
|||
analysis_doctypes.forEach( (doctype) => { |
|||
output[doctype].forEach( (analysis_doc) => { |
|||
let point_to_be_tested = JSON.parse(analysis_doc.location).features[0].geometry.coordinates; |
|||
let poly_of_land = JSON.parse(land_doc.location).features[0].geometry.coordinates[0]; |
|||
if (test_analysis_position(point_to_be_tested, poly_of_land)){ |
|||
obj_to_append[analysis_doctypes_docs[analysis_doctypes.indexOf(doctype)]].push(analysis_doc.name); |
|||
} |
|||
}); |
|||
}); |
|||
}); |
|||
frm.call('append_to_child', { |
|||
obj_to_append: obj_to_append |
|||
}); |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
function test_analysis_position(point, vs) { |
|||
// ray-casting algorithm based on
|
|||
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
|||
|
|||
var x = point[0], y = point[1]; |
|||
|
|||
var inside = false; |
|||
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) { |
|||
var xi = vs[i][0], yi = vs[i][1]; |
|||
var xj = vs[j][0], yj = vs[j][1]; |
|||
|
|||
var intersect = ((yi > y) != (yj > y)) |
|||
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi); |
|||
if (intersect) inside = !inside; |
|||
} |
|||
|
|||
return inside; |
|||
}; |
@ -0,0 +1,849 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "field:title", |
|||
"beta": 0, |
|||
"creation": "2017-11-02 03:09:35.449880", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "title", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Title", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "crop", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Crop", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Crop", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "", |
|||
"fieldname": "column_break_3", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Linked Land Unit", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "A link to all the Land Units in which the Crop is growing", |
|||
"fieldname": "linked_land_unit", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Linked Land Unit", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Linked Land Unit", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_3", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"depends_on": "eval:!doc.__islocal", |
|||
"fieldname": "project", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 1, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Project", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Project", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_12", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "This will be day 1 of the crop cycle", |
|||
"fieldname": "start_date", |
|||
"fieldtype": "Date", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Start Date", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "end_date", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "End Date", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "project.expected_end_date", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 1, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_7", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "iso_8016_standard", |
|||
"fieldtype": "Check", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "ISO 8016 standard", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_5", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "cycle_type", |
|||
"fieldtype": "Select", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Cycle Type", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Yearly\nLess than a year", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_12", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "The minimum length between each plant in the field for optimum growth", |
|||
"fieldname": "crop_spacing", |
|||
"fieldtype": "Float", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Crop Spacing", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "crop.crop_spacing", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "crop_spacing_uom", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Crop Spacing UOM", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "UOM", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_11", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "The minimum distance between rows of plants for optimum growth", |
|||
"fieldname": "row_spacing", |
|||
"fieldtype": "Float", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Row Spacing", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "crop.row_spacing", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "row_spacing_uom", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Row Spacing UOM", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "UOM", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "List of diseases detected on the field. When selected it'll automatically add a list of tasks to deal with the disease ", |
|||
"fieldname": "section_break_14", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Detected Diseases", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "detected_disease", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Detected Disease", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Detected Disease", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 1, |
|||
"collapsible_depends_on": "eval:false", |
|||
"columns": 0, |
|||
"fieldname": "section_break_22", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "LInked Analysis", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_texture", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Soil Texture", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Linked Soil Texture", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_analysis", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Soil Analysis", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Linked Soil Analysis", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "plant_analysis", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Plant Analysis", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Linked Plant Analysis", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-06 01:47:26.656870", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Crop Cycle", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 0, |
|||
"delete": 0, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture User", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,62 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
import ast |
|||
|
|||
class CropCycle(Document): |
|||
def validate(self): |
|||
if self.is_new(): |
|||
crop = frappe.get_doc('Crop', self.crop) |
|||
self.create_project(crop.period, crop.agriculture_task) |
|||
if not self.project: |
|||
self.project = self.name |
|||
for detected_disease in self.detected_disease: |
|||
disease = frappe.get_doc('Disease', detected_disease.disease) |
|||
self.create_task(disease.treatment_task, self.name, detected_disease.start_date) |
|||
|
|||
def create_project(self, period, crop_tasks): |
|||
project = frappe.new_doc("Project") |
|||
project.project_name = self.title |
|||
project.expected_start_date = self.start_date |
|||
project.expected_end_date = frappe.utils.data.add_days(self.start_date, period-1) |
|||
project.insert() |
|||
self.create_task(crop_tasks, project.as_dict.im_self.name, self.start_date) |
|||
return project.as_dict.im_self.name |
|||
|
|||
def create_task(self, crop_tasks, project_name, start_date): |
|||
for crop_task in crop_tasks: |
|||
task = frappe.new_doc("Task") |
|||
task.subject = crop_task.get("task_name") |
|||
task.priority = crop_task.get("priority") |
|||
task.project = project_name |
|||
task.exp_start_date = frappe.utils.data.add_days(start_date, crop_task.get("start_day")-1) |
|||
task.exp_end_date = frappe.utils.data.add_days(start_date, crop_task.get("end_day")-1) |
|||
task.insert() |
|||
|
|||
def reload_linked_analysis(self): |
|||
linked_doctypes = ['Soil Texture', 'Soil Analysis', 'Plant Analysis'] |
|||
required_fields = ['location', 'name', 'collection_datetime'] |
|||
output = {} |
|||
for doctype in linked_doctypes: |
|||
output[doctype] = frappe.get_all(doctype, fields=required_fields) |
|||
output['Land Unit'] = [] |
|||
for land in self.linked_land_unit: |
|||
output['Land Unit'].append(frappe.get_doc('Land Unit', land.land_unit)) |
|||
|
|||
frappe.publish_realtime("List of Linked Docs", output, user=frappe.session.user) |
|||
|
|||
def append_to_child(self, obj_to_append): |
|||
for doctype in obj_to_append: |
|||
for doc_name in set(obj_to_append[doctype]): |
|||
self.append(doctype, {doctype: doc_name}) |
|||
self.save() |
|||
|
|||
def get_coordinates(self, doc): |
|||
return ast.literal_eval(doc.location).get('features')[0].get('geometry').get('coordinates') |
|||
|
|||
def get_geometry_type(self, doc): |
|||
return ast.literal_eval(doc.location).get('features')[0].get('geometry').get('type') |
@ -0,0 +1,34 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Crop Cycle", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Crop Cycle
|
|||
() => frappe.tests.make('Crop Cycle', [ |
|||
// values to be set
|
|||
{title: 'Basil from seed 2017'}, |
|||
{detected_disease: [ |
|||
[ |
|||
{start_date: '2017-11-21'}, |
|||
{disease: 'Aphids'} |
|||
] |
|||
]}, |
|||
{linked_land_unit: [ |
|||
[ |
|||
{land_unit: 'Basil Farm'} |
|||
] |
|||
]}, |
|||
{crop: 'Basil from seed'}, |
|||
{start_date: '2017-11-11'}, |
|||
{cycle_type: 'Less than a year'} |
|||
]), |
|||
() => assert.equal(cur_frm.doc.name, 'Basil from seed 2017'), |
|||
() => done() |
|||
]); |
|||
}); |
@ -0,0 +1,68 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
test_dependencies = ["Crop", "Fertilizer", "Land Unit", "Disease"] |
|||
|
|||
class TestCropCycle(unittest.TestCase): |
|||
def test_crop_cycle_creation(self): |
|||
cycle = frappe.get_doc('Crop Cycle', 'Basil from seed 2017') |
|||
self.assertEquals(frappe.db.exists('Crop Cycle', 'Basil from seed 2017'), 'Basil from seed 2017') |
|||
|
|||
# check if the tasks were created |
|||
self.assertEquals(check_task_creation(), True) |
|||
self.assertEquals(check_project_creation(), True) |
|||
|
|||
def check_task_creation(): |
|||
all_task_dict = { |
|||
"Survey and find the aphid locations": { |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,21), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,22) |
|||
}, |
|||
"Apply Pesticides": { |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,23), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,23) |
|||
}, |
|||
"Plough the field": { |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,11), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,11) |
|||
}, |
|||
"Plant the seeds": { |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,12), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,13) |
|||
}, |
|||
"Water the field": { |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,14), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,14) |
|||
}, |
|||
"First harvest": { |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,18), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,18) |
|||
}, |
|||
"Add the fertilizer": { |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,20), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,22) |
|||
}, |
|||
"Final cut":{ |
|||
"exp_start_date": frappe.utils.datetime.date(2017,11,25), |
|||
"exp_end_date": frappe.utils.datetime.date(2017,11,25) |
|||
} |
|||
} |
|||
all_tasks = frappe.get_all('Task') |
|||
for task in all_tasks: |
|||
sample_task = frappe.get_doc('Task', task.name) |
|||
if sample_task.subject in all_task_dict.keys(): |
|||
if sample_task.exp_start_date != all_task_dict[sample_task.subject]['exp_start_date'] or sample_task.exp_end_date != all_task_dict[sample_task.subject]['exp_end_date']: |
|||
return False |
|||
all_task_dict.pop(sample_task.subject) |
|||
if all_task_dict != {}: |
|||
return False |
|||
return True |
|||
|
|||
def check_project_creation(): |
|||
if frappe.db.exists('Project', 'Basil from seed 2017'): return True |
|||
else: return False |
@ -0,0 +1,15 @@ |
|||
[ |
|||
{ |
|||
"doctype": "Crop Cycle", |
|||
"title": "Basil from seed 2017", |
|||
"linked_land_unit": [{ |
|||
"land_unit": "Basil Farm" |
|||
}], |
|||
"crop": "Basil from seed", |
|||
"start_date": "2017-11-11", |
|||
"detected_disease": [{ |
|||
"disease": "Aphids", |
|||
"start_date": "2017-11-21" |
|||
}] |
|||
} |
|||
] |
@ -0,0 +1,102 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-11-20 17:31:30.772779", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "disease", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Disease", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Disease", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "start_date", |
|||
"fieldtype": "Date", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Start Date", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-11-26 21:10:14.753511", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Detected Disease", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class DetectedDisease(Document): |
|||
pass |
@ -0,0 +1,8 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Disease', { |
|||
refresh: function(frm) { |
|||
|
|||
} |
|||
}); |
@ -0,0 +1,293 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "field:common_name", |
|||
"beta": 0, |
|||
"creation": "2017-11-20 17:16:54.496355", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "common_name", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Common Name", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "scientific_name", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Scientific Name", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_3", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "description", |
|||
"fieldtype": "Long Text", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Description", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_2", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Treatment Task", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "treatment_task", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Treatment Task", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Agriculture Task", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "treatment_period", |
|||
"fieldtype": "Int", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Treatment Period", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-04 19:20:19.352479", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Disease", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 0, |
|||
"delete": 0, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture User", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,18 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class Disease(Document): |
|||
def validate(self): |
|||
max_period = 0 |
|||
for task in self.treatment_task: |
|||
# validate start_day is not > end_day |
|||
if task.start_day > task.end_day: |
|||
frappe.throw("Start day is greater than end day in task '{0}'".format(task.task_name)) |
|||
# to calculate the period of the Crop Cycle |
|||
if task.end_day > max_period: max_period = task.end_day |
|||
self.treatment_period = max_period |
@ -0,0 +1,39 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Disease", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Disease
|
|||
() => frappe.tests.make('Disease', [ |
|||
// values to be set
|
|||
{common_name: 'Aphids'}, |
|||
{scientific_name: 'Aphidoidea'}, |
|||
{treatment_task: [ |
|||
[ |
|||
{task_name: "Survey and find the aphid locations"}, |
|||
{start_day: 1}, |
|||
{end_day: 2}, |
|||
{holiday_management: "Ignore holidays"} |
|||
], |
|||
[ |
|||
{task_name: "Apply Pesticides"}, |
|||
{start_day: 3}, |
|||
{end_day: 3}, |
|||
{holiday_management: "Ignore holidays"} |
|||
] |
|||
]} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.treatment_period, 3); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
|||
|
@ -0,0 +1,12 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestDisease(unittest.TestCase): |
|||
def test_treatment_period(self): |
|||
disease = frappe.get_doc('Disease', 'Aphids') |
|||
self.assertEquals(disease.treatment_period, 3) |
@ -0,0 +1,18 @@ |
|||
[ |
|||
{ |
|||
"doctype": "Disease", |
|||
"common_name": "Aphids", |
|||
"scientific_name": "Aphidoidea", |
|||
"treatment_task": [{ |
|||
"task_name": "Survey and find the aphid locations", |
|||
"start_day": 1, |
|||
"end_day": 2, |
|||
"holiday_management": "Ignore holidays" |
|||
}, { |
|||
"task_name": "Apply Pesticides", |
|||
"start_day": 3, |
|||
"end_day": 3, |
|||
"holiday_management": "Ignore holidays" |
|||
}] |
|||
} |
|||
] |
@ -0,0 +1,8 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Fertilizer', { |
|||
onload: (frm) => { |
|||
if (frm.doc.fertilizer_contents == undefined) frm.call('load_contents'); |
|||
} |
|||
}); |
@ -0,0 +1,292 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "field:fertilizer_name", |
|||
"beta": 0, |
|||
"creation": "2017-10-17 18:17:06.175062", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "fertilizer_name", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Fertilizer Name", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "item", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Item", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Item", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_2", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "density", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Density (if liquid)", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_4", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_28", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Fertilizer Contents", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "fertilizer_contents", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Fertilizer Content", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 19:13:42.471667", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Fertilizer", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 0, |
|||
"delete": 0, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture User", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,13 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class Fertilizer(Document): |
|||
def load_contents(self): |
|||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Fertilizer'}) |
|||
for doc in docs: |
|||
self.append('fertilizer_contents', {'title': str(doc.name)}) |
@ -0,0 +1,31 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Fertilizer", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Item
|
|||
() => frappe.tests.make('Item', [ |
|||
// values to be set
|
|||
{item_code: 'Urea'}, |
|||
{item_name: 'Urea'}, |
|||
{item_group: 'Fertilizer'} |
|||
]), |
|||
// insert a new Fertilizer
|
|||
() => frappe.tests.make('Fertilizer', [ |
|||
// values to be set
|
|||
{fertilizer_name: 'Urea'}, |
|||
{item: 'Urea'} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.name, 'Urea'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
@ -0,0 +1,11 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestFertilizer(unittest.TestCase): |
|||
def test_fertilizer_creation(self): |
|||
self.assertEquals(frappe.db.exists('Fertilizer', 'Urea'), 'Urea') |
@ -0,0 +1,13 @@ |
|||
[ |
|||
{ |
|||
"doctype": "Item", |
|||
"item_code": "Urea", |
|||
"item_name": "Urea", |
|||
"item_group": "Fertilizer" |
|||
}, |
|||
{ |
|||
"doctype": "Fertilizer", |
|||
"fertilizer_name": "Urea", |
|||
"item": "Urea" |
|||
} |
|||
] |
@ -0,0 +1,103 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-12-05 16:54:17.071914", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "title", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Title", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Agriculture Analysis Criteria", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 19:20:38.892231", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Fertilizer Content", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"restrict_to_domain": "Agriculture", |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class FertilizerContent(Document): |
|||
pass |
@ -0,0 +1,31 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
// Code for finding the area of editable features drawn on the geolocation control
|
|||
|
|||
|
|||
|
|||
frappe.ui.form.on('Land Unit', { |
|||
setup: function(frm) { |
|||
frm.add_fetch("parent_land_unit", "latitude", "latitude"); |
|||
frm.add_fetch("parent_land_unit", "longitude", "longitude"); |
|||
}, |
|||
|
|||
onload_post_render(frm){ |
|||
if(!frm.doc.location && frm.doc.latitude && frm.doc.longitude) { |
|||
frm.fields_dict.location.map.setView([frm.doc.latitude, frm.doc.longitude],13); |
|||
} |
|||
else { |
|||
frm.doc.latitude = frm.fields_dict.location.map.getCenter()['lat']; |
|||
frm.doc.longitude = frm.fields_dict.location.map.getCenter()['lng']; |
|||
} |
|||
}, |
|||
refresh: function(frm) { |
|||
if(!frm.doc.parent_land_unit) { |
|||
frm.set_read_only(); |
|||
frm.set_intro(__("This is a root land unit and cannot be edited.")); |
|||
} else { |
|||
frm.set_intro(null); |
|||
} |
|||
}, |
|||
}); |
@ -0,0 +1,690 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 1, |
|||
"allow_rename": 1, |
|||
"autoname": "field:land_unit_name", |
|||
"beta": 0, |
|||
"creation": "2017-10-21 05:35:34.508529", |
|||
"custom": 0, |
|||
"description": "Land Unit describing various land assets", |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "land_unit_name", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Land Unit Name", |
|||
"length": 0, |
|||
"no_copy": 1, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 1, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "parent_land_unit", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 1, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Parent Land Unit", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Land Unit", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_2", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "Check if it is a hydroponic unit", |
|||
"fieldname": "is_container", |
|||
"fieldtype": "Check", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Is Container", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 1, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "", |
|||
"fieldname": "is_group", |
|||
"fieldtype": "Check", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Is Group", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "tree_details", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Tree Details", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "lft", |
|||
"fieldtype": "Int", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "lft", |
|||
"length": 0, |
|||
"no_copy": 1, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 1, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 1, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "rgt", |
|||
"fieldtype": "Int", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "rgt", |
|||
"length": 0, |
|||
"no_copy": 1, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 1, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 1, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "old_parent", |
|||
"fieldtype": "Link", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 1, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "old_parent", |
|||
"length": 0, |
|||
"no_copy": 1, |
|||
"options": "Land Unit", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 1, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 1, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "land_unit_details", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Land Unit Details", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "latitude", |
|||
"fieldtype": "Float", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Latitude", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "longitude", |
|||
"fieldtype": "Float", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Longitude", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "latlong", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "area", |
|||
"fieldtype": "Float", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Area", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_13", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "location", |
|||
"fieldtype": "Geolocation", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Location", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_17", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "linked_soil_texture", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Linked Soil Texture", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Linked Soil Texture", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "linked_soil_analysis", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Linked Soil Analysis", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Linked Soil Analysis", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "linked_plant_analysis", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Linked Plant Analysis", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Linked Plant Analysis", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 10:57:33.108504", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Land Unit", |
|||
"name_case": "Title Case", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 0, |
|||
"delete": 0, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture User", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 1, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 0, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,165 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
import json |
|||
import math |
|||
|
|||
from frappe import _ |
|||
|
|||
from frappe.utils.nestedset import NestedSet |
|||
# from frappe.model.document import Document |
|||
|
|||
RADIUS = 6378137 |
|||
FLATTENING_DENOM = 298.257223563 |
|||
FLATTENING = 1/FLATTENING_DENOM |
|||
POLAR_RADIUS = RADIUS*(1-FLATTENING) |
|||
|
|||
class LandUnit(NestedSet): |
|||
# pass |
|||
nsm_parent_field = 'parent_land_unit' |
|||
|
|||
def on_trash(self): |
|||
ancestors = self.get_ancestors() |
|||
for ancestor in ancestors: |
|||
ancestor_doc = frappe.get_doc('Land Unit', ancestor) |
|||
ancestor_child_features, ancestor_non_child_features = ancestor_doc.feature_seperator(child_feature = self.get('land_unit_name')) |
|||
ancestor_features = ancestor_non_child_features |
|||
for index,feature in enumerate(ancestor_features): |
|||
ancestor_features[index] = json.loads(feature) |
|||
ancestor_doc.set_location_value(features = ancestor_features) |
|||
ancestor_doc.db_set(fieldname='area', value=ancestor_doc.get('area')-self.get('area'),commit=True) |
|||
|
|||
def validate(self): |
|||
if not self.is_new(): |
|||
if not self.get('location'): |
|||
features = '' |
|||
else: |
|||
features = json.loads(self.get('location')).get('features') |
|||
new_area = compute_area(features) |
|||
self.area_difference = new_area - self.area |
|||
self.area = new_area |
|||
|
|||
if self.get('parent'): |
|||
ancestors = self.get_ancestors() |
|||
self_features = self.add_child_property() |
|||
self_features = set(self_features) |
|||
|
|||
for ancestor in ancestors: |
|||
ancestor_doc = frappe.get_doc('Land Unit', ancestor) |
|||
ancestor_child_features, ancestor_non_child_features = ancestor_doc.feature_seperator(child_feature = self.get('land_unit_name')) |
|||
ancestor_features = list(set(ancestor_non_child_features)) |
|||
child_features = set(ancestor_child_features) |
|||
|
|||
if not (self_features.issubset(child_features) and child_features.issubset(self_features)): |
|||
features_to_be_appended = self_features - child_features |
|||
features_to_be_discarded = child_features - self_features |
|||
for feature in features_to_be_discarded: |
|||
child_features.discard(feature) |
|||
for feature in features_to_be_appended: |
|||
child_features.add(feature) |
|||
child_features = list(child_features) |
|||
|
|||
ancestor_features.extend(child_features) |
|||
for index,feature in enumerate(ancestor_features): |
|||
ancestor_features[index] = json.loads(feature) |
|||
ancestor_doc.set_location_value(features = ancestor_features) |
|||
ancestor_doc.db_set(fieldname='area', value=ancestor_doc.get('area')+\ |
|||
self.get('area_difference'),commit=True) |
|||
|
|||
def set_location_value(self, features): |
|||
if not self.get('location'): |
|||
self.location = '{"type":"FeatureCollection","features":[]}' |
|||
location = json.loads(self.location) |
|||
location['features'] = features |
|||
self.db_set(fieldname='location', value=json.dumps(location), commit=True) |
|||
|
|||
def on_update(self): |
|||
super(LandUnit, self).on_update() |
|||
self.validate_one_root() |
|||
|
|||
def add_child_property(self): |
|||
location = self.get('location') |
|||
if location: |
|||
features = json.loads(location).get('features') |
|||
if type(features) != list: |
|||
features = json.loads(features) |
|||
filter_features = [feature for feature in features if feature.get('properties').get('child_feature') != True] |
|||
for index,feature in enumerate(filter_features): |
|||
feature['properties'].update({'child_feature': True, 'feature_of': self.land_unit_name}) |
|||
filter_features[index] = json.dumps(filter_features[index]) |
|||
return filter_features |
|||
return [] |
|||
|
|||
def feature_seperator(self, child_feature=None): |
|||
doc = self |
|||
child_features = [] |
|||
non_child_features = [] |
|||
location = doc.get('location') |
|||
if location: |
|||
features = json.loads(location).get('features') |
|||
if type(features) != list: |
|||
features = json.loads(features) |
|||
for feature in features: |
|||
if feature.get('properties').get('feature_of') == child_feature: |
|||
child_features.extend([json.dumps(feature)]) |
|||
else: |
|||
non_child_features.extend([json.dumps(feature)]) |
|||
|
|||
return child_features, non_child_features |
|||
|
|||
|
|||
def compute_area(features): |
|||
layer_area = 0 |
|||
for feature in features: |
|||
if feature.get('geometry').get('type') == 'Polygon': |
|||
layer_area += polygon_area(coords = feature.get('geometry').get('coordinates')) |
|||
elif feature.get('geometry').get('type') == 'Point' and feature.get('properties').get('point_type') == 'circle': |
|||
layer_area += math.pi * math.pow(feature.get('properties').get('radius'), 2) |
|||
return layer_area |
|||
|
|||
def rad(angle_in_degrees): |
|||
return angle_in_degrees*math.pi/180 |
|||
|
|||
def polygon_area(coords): |
|||
area = 0 |
|||
if coords and len(coords) > 0: |
|||
area += math.fabs(ring_area(coords[0])); |
|||
for i in range(1, len(coords)): |
|||
area -= math.fabs(ring_area(coords[i])); |
|||
return area; |
|||
|
|||
def ring_area(coords): |
|||
p1 = 0 |
|||
p2 = 0 |
|||
p3 = 0 |
|||
lower_index = 0 |
|||
middle_index = 0 |
|||
upper_index = 0 |
|||
i = 0 |
|||
area = 0 |
|||
coords_length = len(coords) |
|||
if coords_length > 2: |
|||
for i in range(0, coords_length): |
|||
if i == coords_length - 2: # i = N-2 |
|||
lower_index = coords_length - 2; |
|||
middle_index = coords_length -1; |
|||
upper_index = 0; |
|||
elif i == coords_length - 1: # i = N-1 |
|||
lower_index = coords_length - 1; |
|||
middle_index = 0; |
|||
upper_index = 1; |
|||
else: # i = 0 to N-3 |
|||
lower_index = i; |
|||
middle_index = i+1; |
|||
upper_index = i+2; |
|||
p1 = coords[lower_index]; |
|||
p2 = coords[middle_index]; |
|||
p3 = coords[upper_index]; |
|||
area += ( rad(p3[0]) - rad(p1[0]) ) * math.sin( rad(p2[1])); |
|||
|
|||
area = area * RADIUS * RADIUS / 2 |
|||
return area |
|||
|
@ -0,0 +1,15 @@ |
|||
frappe.treeview_settings["Land Unit"] = { |
|||
ignore_fields:["parent_land_unit"], |
|||
disable_add_node: true, |
|||
toolbar: [ |
|||
{ toggle_btn: true }, |
|||
{ |
|||
label:__("Add Child"), |
|||
click: function(node) { |
|||
var lu = frappe.new_doc("Land Unit", { |
|||
"parent_land_unit": node.label |
|||
}) |
|||
} |
|||
} |
|||
], |
|||
} |
@ -0,0 +1,24 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Land Unit", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Land Unit
|
|||
() => frappe.tests.make('Land Unit', [ |
|||
// values to be set
|
|||
{parent_land_unit: 'All Land Units'}, |
|||
{land_unit_name: 'Basil Farm'} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.name, 'Basil Farm'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
@ -0,0 +1,26 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
import json |
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestLandUnit(unittest.TestCase): |
|||
|
|||
def runTest(self): |
|||
land_units = ['Basil Farm', 'Division 1', 'Field 1', 'Block 1'] |
|||
area = 0 |
|||
formatted_land_units = [] |
|||
for land_unit in land_units: |
|||
doc = frappe.get_doc('Land Unit', land_unit) |
|||
doc.save() |
|||
area += doc.area |
|||
temp = json.loads(doc.location) |
|||
temp['features'][0]['properties']['child_feature'] = True |
|||
temp['features'][0]['properties']['feature_of'] = land_unit |
|||
formatted_land_units.extend(temp['features']) |
|||
formatted_land_unit_string = str(formatted_land_units) |
|||
all_land_units = frappe.get_doc('Land Unit', 'All Land Units') |
|||
self.assertEquals(formatted_land_unit_string, str(json.loads(all_land_units.get('location'))['features'])) |
|||
self.assertEquals(area, all_land_units.get('area')) |
@ -0,0 +1,38 @@ |
|||
[ |
|||
{ |
|||
"doctype": "Land Unit", |
|||
"land_unit_name": "Basil Farm", |
|||
"location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"point_type\":\"circle\",\"radius\":884.5625420736483},\"geometry\":{\"type\":\"Point\",\"coordinates\":[72.875834,19.100566]}}]}", |
|||
"parent_land_unit": "All Land Units", |
|||
"parent": "All Land Units", |
|||
"is_group": 1, |
|||
"is_container": 1 |
|||
}, |
|||
{ |
|||
"doctype": "Land Unit", |
|||
"land_unit_name": "Division 1", |
|||
"location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"point_type\":\"circle\",\"radius\":542.3424997060739},\"geometry\":{\"type\":\"Point\",\"coordinates\":[72.852359,19.11557]}}]}", |
|||
"parent_land_unit": "Basil Farm", |
|||
"parent": "Basil Farm", |
|||
"is_group": 1, |
|||
"is_container": 1 |
|||
}, |
|||
{ |
|||
"doctype": "Land Unit", |
|||
"land_unit_name": "Field 1", |
|||
"location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[72.846758,19.118287],[72.846758,19.121206],[72.850535,19.121206],[72.850535,19.118287],[72.846758,19.118287]]]}}]}", |
|||
"parent_land_unit": "Division 1", |
|||
"parent": "Division 1", |
|||
"is_group": 1, |
|||
"is_container": 1 |
|||
}, |
|||
{ |
|||
"doctype": "Land Unit", |
|||
"land_unit_name": "Block 1", |
|||
"location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[72.921495,19.073313],[72.924929,19.068121],[72.934713,19.06585],[72.929392,19.05579],[72.94158,19.056926],[72.951365,19.095213],[72.921495,19.073313]]]}}]}", |
|||
"parent_land_unit": "Field 1", |
|||
"parent": "Field 1", |
|||
"is_group": 0, |
|||
"is_container": 1 |
|||
} |
|||
] |
@ -0,0 +1,72 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-11-22 14:34:59.461273", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "land_unit", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Land Unit", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Land Unit", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-04 13:25:50.856991", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Linked Land Unit", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class LinkedLandUnit(Document): |
|||
pass |
@ -0,0 +1,72 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-11-22 15:04:25.180446", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "plant_analysis", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Plant Analysis", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Plant Analysis", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-04 13:25:30.437597", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Linked Plant Analysis", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class LinkedPlantAnalysis(Document): |
|||
pass |
@ -0,0 +1,72 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-11-22 15:00:37.259063", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_analysis", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Soil Analysis", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Soil Analysis", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-04 13:26:18.682109", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Linked Soil Analysis", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class LinkedSoilAnalysis(Document): |
|||
pass |
@ -0,0 +1,72 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-11-22 14:58:52.818040", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_texture", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Soil Texture", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Soil Texture", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-04 13:26:07.773314", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Linked Soil Texture", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class LinkedSoilTexture(Document): |
|||
pass |
@ -0,0 +1,17 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Plant Analysis', { |
|||
onload: (frm) => { |
|||
if (frm.doc.plant_analysis_criteria == undefined) frm.call('load_contents'); |
|||
}, |
|||
refresh: (frm) => { |
|||
let map_tools = ["a.leaflet-draw-draw-polyline", |
|||
"a.leaflet-draw-draw-polygon", |
|||
"a.leaflet-draw-draw-rectangle", |
|||
"a.leaflet-draw-draw-circle", |
|||
"a.leaflet-draw-draw-circlemarker"]; |
|||
|
|||
map_tools.forEach((element) => $(element).hide()); |
|||
} |
|||
}); |
@ -0,0 +1,353 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "PANA.#####", |
|||
"beta": 0, |
|||
"creation": "2017-10-18 12:45:13.575986", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "crop", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Crop", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Crop", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_1", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "location", |
|||
"fieldtype": "Geolocation", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Location", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_2", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "collection_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Collection Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "laboratory_testing_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Laboratory Testing Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "result_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Result Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_2", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Plant Analysis Criterias", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "plant_analysis_criteria", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Plant Analysis Criteria", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 19:29:58.612659", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Plant Analysis", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 0, |
|||
"delete": 0, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture User", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,14 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.naming import make_autoname |
|||
from frappe.model.document import Document |
|||
|
|||
class PlantAnalysis(Document): |
|||
def load_contents(self): |
|||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Plant Analysis'}) |
|||
for doc in docs: |
|||
self.append('plant_analysis_criteria', {'title': str(doc.name)}) |
@ -0,0 +1,23 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Plant Analysis", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Plant Analysis
|
|||
() => frappe.tests.make('Plant Analysis', [ |
|||
// values to be set
|
|||
{key: 'value'} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.key, 'value'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestPlantAnalysis(unittest.TestCase): |
|||
pass |
@ -0,0 +1,162 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-12-05 19:23:52.481348", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "title", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Title", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Agriculture Analysis Criteria", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "minimum_permissible_value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Minimum Permissible Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "maximum_permissible_value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Maximum Permissible Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 19:37:02.289320", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Plant Analysis Criteria", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class PlantAnalysisCriteria(Document): |
|||
pass |
@ -0,0 +1,17 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Soil Analysis', { |
|||
onload: (frm) => { |
|||
if (frm.doc.soil_analysis_criteria == undefined) frm.call('load_contents'); |
|||
}, |
|||
refresh: (frm) => { |
|||
let map_tools = ["a.leaflet-draw-draw-polyline", |
|||
"a.leaflet-draw-draw-polygon", |
|||
"a.leaflet-draw-draw-rectangle", |
|||
"a.leaflet-draw-draw-circle", |
|||
"a.leaflet-draw-draw-circlemarker"]; |
|||
|
|||
map_tools.forEach((element) => $(element).hide()); |
|||
} |
|||
}); |
@ -0,0 +1,560 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "SANA.#####", |
|||
"beta": 0, |
|||
"creation": "2017-10-17 19:12:16.728395", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "location", |
|||
"fieldtype": "Geolocation", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Location", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_2", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "collection_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Collection Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "laboratory_testing_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Laboratory Testing Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "result_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Result Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_3", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "ca_per_k", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Ca/K", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 1, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "ca_per_mg", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Ca/Mg", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 1, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "mg_per_k", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Mg/K", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 1, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_31", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "ca_mg_per_k", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "(Ca+Mg)/K", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 1, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "ca_per_k_ca_mg", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Ca/(K+Ca+Mg)", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 1, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_28", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "invoice_number", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Invoice Number", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_analysis_criterias", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Soil Analysis Criterias", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_analysis_criteria", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Soil Analysis Criteria", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 19:43:05.543080", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Soil Analysis", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 0, |
|||
"delete": 0, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture User", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,13 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class SoilAnalysis(Document): |
|||
def load_contents(self): |
|||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Soil Analysis'}) |
|||
for doc in docs: |
|||
self.append('soil_analysis_criteria', {'title': str(doc.name)}) |
@ -0,0 +1,23 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Soil Analysis", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Soil Analysis
|
|||
() => frappe.tests.make('Soil Analysis', [ |
|||
// values to be set
|
|||
{key: 'value'} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.key, 'value'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestSoilAnalysis(unittest.TestCase): |
|||
pass |
@ -0,0 +1,162 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-12-05 19:36:05.300770", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "title", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Title", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Agriculture Analysis Criteria", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "minimum_permissible_value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Minimum Permissible Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "maximum_permissible_value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Maximum Permissible Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 23:35:34.569482", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Soil Analysis Criteria", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class SoilAnalysisCriteria(Document): |
|||
pass |
@ -0,0 +1,59 @@ |
|||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.provide('agriculture'); |
|||
|
|||
frappe.ui.form.on('Soil Texture', { |
|||
refresh: (frm) => { |
|||
let map_tools = ["a.leaflet-draw-draw-polyline", |
|||
"a.leaflet-draw-draw-polygon", |
|||
"a.leaflet-draw-draw-rectangle", |
|||
"a.leaflet-draw-draw-circle", |
|||
"a.leaflet-draw-draw-circlemarker"]; |
|||
|
|||
map_tools.forEach((element) => $(element).hide()); |
|||
}, |
|||
onload: function(frm) { |
|||
if (frm.doc.soil_texture_criteria == undefined) frm.call('load_contents'); |
|||
if (this.ternary_plot) return; |
|||
this.ternary_plot = new agriculture.TernaryPlot({ |
|||
parent: frm.get_field("ternary_plot").$wrapper, |
|||
clay: frm.doc.clay_composition, |
|||
sand: frm.doc.sand_composition, |
|||
silt: frm.doc.silt_composition, |
|||
}); |
|||
}, |
|||
soil_type: (frm) => { |
|||
let composition_types = ['clay_composition', 'sand_composition', 'silt_composition']; |
|||
composition_types.forEach((composition_type) => { |
|||
frm.doc[composition_type] = 0; |
|||
frm.refresh_field(composition_type); |
|||
}); |
|||
}, |
|||
clay_composition: function(frm) { |
|||
frm.call("update_soil_edit", { |
|||
soil_type: 'clay_composition' |
|||
}, () => { |
|||
refresh_ternary_plot(frm, this); |
|||
}); |
|||
}, |
|||
sand_composition: function(frm) { |
|||
frm.call("update_soil_edit", { |
|||
soil_type: 'sand_composition' |
|||
}, () => { |
|||
refresh_ternary_plot(frm, this); |
|||
}); |
|||
}, |
|||
silt_composition: function(frm) { |
|||
frm.call("update_soil_edit", { |
|||
soil_type: 'silt_composition' |
|||
}, () => { |
|||
refresh_ternary_plot(frm, this); |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
let refresh_ternary_plot = (frm, me) => { |
|||
me.ternary_plot.remove_blip(); |
|||
me.ternary_plot.mark_blip({clay: frm.doc.clay_composition, sand: frm.doc.sand_composition, silt: frm.doc.silt_composition}); |
|||
}; |
@ -0,0 +1,504 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"autoname": "STEXT.#####", |
|||
"beta": 0, |
|||
"creation": "2017-10-18 13:06:47.506762", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "location", |
|||
"fieldtype": "Geolocation", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Location", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_2", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "collection_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Collection Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "laboratory_testing_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Laboratory Testing Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "result_datetime", |
|||
"fieldtype": "Datetime", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Result Datetime", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_4", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_type", |
|||
"fieldtype": "Select", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Soil Type", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Select\nSand\nLoamy Sand\nSandy Loam\nLoam\nSilt Loam\nSilt\nSandy Clay Loam\nClay Loam\nSilty Clay Loam\nSandy Clay\nSilty Clay\nClay", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "0", |
|||
"fieldname": "clay_composition", |
|||
"fieldtype": "Percent", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Clay Composition (%)", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "0", |
|||
"fieldname": "sand_composition", |
|||
"fieldtype": "Percent", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Sand Composition (%)", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "0", |
|||
"fieldname": "silt_composition", |
|||
"fieldtype": "Percent", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Silt Composition (%)", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_6", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "ternary_plot", |
|||
"fieldtype": "HTML", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Ternary Plot", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "section_break_15", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Soil Texture Criteria", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "soil_texture_criteria", |
|||
"fieldtype": "Table", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Soil Texture Criteria", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 0, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 23:57:10.725578", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Soil Texture", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture Manager", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 0, |
|||
"apply_user_permissions": 0, |
|||
"cancel": 0, |
|||
"create": 0, |
|||
"delete": 0, |
|||
"email": 1, |
|||
"export": 1, |
|||
"if_owner": 0, |
|||
"import": 0, |
|||
"permlevel": 0, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "Agriculture User", |
|||
"set_user_permissions": 0, |
|||
"share": 1, |
|||
"submit": 0, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,68 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
from frappe.utils import flt, cint |
|||
|
|||
class SoilTexture(Document): |
|||
soil_edit_order = [2, 1, 0] |
|||
soil_types = ['clay_composition', 'sand_composition', 'silt_composition'] |
|||
|
|||
def load_contents(self): |
|||
docs = frappe.get_all("Agriculture Analysis Criteria", filters={'linked_doctype':'Soil Texture'}) |
|||
for doc in docs: |
|||
self.append('soil_texture_criteria', {'title': str(doc.name)}) |
|||
|
|||
def validate(self): |
|||
self.update_soil_edit('sand_composition') |
|||
for soil_type in self.soil_types: |
|||
if self.get(soil_type) > 100 or self.get(soil_type) < 0: |
|||
frappe.throw("{0} should be a value between 0 and 100".format(soil_type)) |
|||
if sum(self.get(soil_type) for soil_type in self.soil_types) != 100: |
|||
frappe.throw('Soil compositions do not add up to 100') |
|||
|
|||
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() |
|||
|
|||
def get_soil_type(self): |
|||
# update the last edited soil type |
|||
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], |
|||
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 |
|||
c, sa, si = flt(self.clay_composition), flt(self.sand_composition), flt(self.silt_composition) |
|||
|
|||
if si + (1.5 * c) < 15: |
|||
return 'Sand' |
|||
elif si + 1.5 * c >= 15 and si + 2 * c < 30: |
|||
return 'Loamy Sand' |
|||
elif ((c >= 7 and c < 20) or (sa > 52) and ((si + 2*c) >= 30) or (c < 7 and si < 50 and (si+2*c) >= 30)): |
|||
return 'Sandy Loam' |
|||
elif ((c >= 7 and c < 27) and (si >= 28 and si < 50) and (sa <= 52)): |
|||
return 'Loam' |
|||
elif ((si >= 50 and (c >= 12 and c < 27)) or ((si >= 50 and si < 80) and c < 12)): |
|||
return 'Silt Loam' |
|||
elif (si >= 80 and c < 12): |
|||
return 'Silt' |
|||
elif ((c >= 20 and c < 35) and (si < 28) and (sa > 45)): |
|||
return 'Sandy Clay Loam' |
|||
elif ((c >= 27 and c < 40) and (sa > 20 and sa <= 45)): |
|||
return 'Clay Loam' |
|||
elif ((c >= 27 and c < 40) and (sa <= 20)): |
|||
return 'Silty Clay Loam' |
|||
elif (c >= 35 and sa > 45): |
|||
return 'Sandy Clay' |
|||
elif (c >= 40 and si >= 40): |
|||
return 'Silty Clay' |
|||
elif (c >= 40 and sa <= 45 and si < 40): |
|||
return 'Clay' |
|||
else: |
|||
return 'Select' |
@ -0,0 +1,9 @@ |
|||
[ |
|||
{ |
|||
"doctype": "Soil Texture", |
|||
"location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[72.861242,19.079153]}}]}", |
|||
"collection_datetime": "2017-11-08", |
|||
"clay_composition": 20, |
|||
"sand_composition": 30 |
|||
} |
|||
] |
@ -0,0 +1,26 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Soil Texture", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(2); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Soil Texture
|
|||
() => frappe.tests.make('Soil Texture', [ |
|||
// values to be set
|
|||
{location: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[72.882185,19.076395]}}]}'}, |
|||
{collection_datetime: '2017-11-08'}, |
|||
{clay_composition: 20}, |
|||
{sand_composition: 30} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.silt_composition, 50); |
|||
assert.equal(cur_frm.doc.soil_type, 'Silt Loam'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
}); |
@ -0,0 +1,14 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
import unittest |
|||
|
|||
class TestSoilTexture(unittest.TestCase): |
|||
def test_texture_selection(self): |
|||
soil_tex = frappe.get_all('Soil Texture', fields=['name'], filters={'collection_datetime': '2017-11-08'}) |
|||
doc = frappe.get_doc('Soil Texture', soil_tex[0].name) |
|||
self.assertEquals(doc.silt_composition, 50) |
|||
self.assertEquals(doc.soil_type, 'Silt Loam') |
@ -0,0 +1,162 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"creation": "2017-12-05 23:45:17.419610", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"document_type": "", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "title", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Title", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "Agriculture Analysis Criteria", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 1, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "minimum_permissible_value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Minimum Permissible Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "maximum_permissible_value", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Maximum Permissible Value", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"unique": 0 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 0, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2017-12-05 23:45:17.419610", |
|||
"modified_by": "Administrator", |
|||
"module": "Agriculture", |
|||
"name": "Soil Texture Criteria", |
|||
"name_case": "", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 1, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1, |
|||
"track_seen": 0 |
|||
} |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class SoilTextureCriteria(Document): |
|||
pass |
@ -0,0 +1,25 @@ |
|||
/* eslint-disable */ |
|||
// rename this file from _test_[name] to test_[name] to activate
|
|||
// and remove above this line
|
|||
|
|||
QUnit.test("test: Water Analysis", function (assert) { |
|||
let done = assert.async(); |
|||
|
|||
// number of asserts
|
|||
assert.expect(1); |
|||
|
|||
frappe.run_serially([ |
|||
// insert a new Water Analysis
|
|||
() => frappe.tests.make('Water Analysis', [ |
|||
// values to be set
|
|||
{location: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[72.882185,19.076395]}}]}'}, |
|||
{collection_datetime: '2017-11-08 18:43:57'}, |
|||
{laboratory_testing_datetime: '2017-11-10 18:43:57'} |
|||
]), |
|||
() => { |
|||
assert.equal(cur_frm.doc.result_datetime, '2017-11-10 18:43:57'); |
|||
}, |
|||
() => done() |
|||
]); |
|||
|
|||
}); |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue