diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.json b/erpnext/accounts/doctype/gl_entry/gl_entry.json
index a232a953f31..e64bc9e0c78 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.json
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.json
@@ -1,971 +1,286 @@
{
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
"autoname": "ACC-GLE-.YYYY.-.#####",
- "beta": 0,
"creation": "2013-01-10 16:34:06",
- "custom": 0,
- "docstatus": 0,
"doctype": "DocType",
"document_type": "Document",
- "editable_grid": 0,
+ "engine": "InnoDB",
+ "field_order": [
+ "posting_date",
+ "transaction_date",
+ "account",
+ "party_type",
+ "party",
+ "cost_center",
+ "debit",
+ "credit",
+ "account_currency",
+ "debit_in_account_currency",
+ "credit_in_account_currency",
+ "against",
+ "against_voucher_type",
+ "against_voucher",
+ "voucher_type",
+ "voucher_no",
+ "voucher_detail_no",
+ "project",
+ "remarks",
+ "is_opening",
+ "is_advance",
+ "fiscal_year",
+ "company",
+ "finance_book",
+ "to_rename",
+ "due_date"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "posting_date",
"fieldtype": "Date",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
"in_list_view": 1,
- "in_standard_filter": 0,
"label": "Posting Date",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "posting_date",
"oldfieldtype": "Date",
- "permlevel": 0,
- "print_hide": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "transaction_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": "Transaction Date",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "transaction_date",
- "oldfieldtype": "Date",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "oldfieldtype": "Date"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "account",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Account",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "account",
"oldfieldtype": "Link",
"options": "Account",
- "permlevel": 0,
- "print_hide": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "party_type",
"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": "Party Type",
- "length": 0,
- "no_copy": 0,
"options": "DocType",
- "permlevel": 0,
- "print_hide": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "party",
"fieldtype": "Dynamic 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": 1,
"label": "Party",
- "length": 0,
- "no_copy": 0,
"options": "party_type",
- "permlevel": 0,
- "print_hide": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "cost_center",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
"in_list_view": 1,
- "in_standard_filter": 0,
"label": "Cost Center",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "cost_center",
"oldfieldtype": "Link",
- "options": "Cost Center",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "Cost Center"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "debit",
"fieldtype": "Currency",
- "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": "Debit Amount",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "debit",
"oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "Company:company:default_currency"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "credit",
"fieldtype": "Currency",
- "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": "Credit Amount",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "credit",
"oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "Company:company:default_currency"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "account_currency",
"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": "Account Currency",
- "length": 0,
- "no_copy": 0,
- "options": "Currency",
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "Currency"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "debit_in_account_currency",
"fieldtype": "Currency",
- "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": "Debit Amount in Account Currency",
- "length": 0,
- "no_copy": 0,
- "options": "currency",
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "currency"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "credit_in_account_currency",
"fieldtype": "Currency",
- "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": "Credit Amount in Account Currency",
- "length": 0,
- "no_copy": 0,
- "options": "currency",
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "currency"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "against",
"fieldtype": "Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Against",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "against",
- "oldfieldtype": "Text",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "oldfieldtype": "Text"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "against_voucher_type",
"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": "Against Voucher Type",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "against_voucher_type",
"oldfieldtype": "Data",
"options": "DocType",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "against_voucher",
"fieldtype": "Dynamic Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Against Voucher",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "against_voucher",
"oldfieldtype": "Data",
"options": "against_voucher_type",
- "permlevel": 0,
- "print_hide": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "voucher_type",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Voucher Type",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "voucher_type",
"oldfieldtype": "Select",
"options": "DocType",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "voucher_no",
"fieldtype": "Dynamic Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
"in_standard_filter": 1,
"label": "Voucher No",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "voucher_no",
"oldfieldtype": "Data",
"options": "voucher_type",
- "permlevel": 0,
- "print_hide": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "voucher_detail_no",
"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": "Voucher Detail No",
- "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,
- "translatable": 0,
- "unique": 0
+ "read_only": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "project",
"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": "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,
- "translatable": 0,
- "unique": 0
+ "options": "Project"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "remarks",
"fieldtype": "Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Remarks",
- "length": 0,
"no_copy": 1,
"oldfieldname": "remarks",
- "oldfieldtype": "Text",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "oldfieldtype": "Text"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "is_opening",
"fieldtype": "Select",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Is Opening",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "is_opening",
"oldfieldtype": "Select",
- "options": "No\nYes",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "No\nYes"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "is_advance",
"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": "Is Advance",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "is_advance",
"oldfieldtype": "Select",
- "options": "No\nYes",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "No\nYes"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "fiscal_year",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Fiscal Year",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "fiscal_year",
"oldfieldtype": "Select",
- "options": "Fiscal Year",
- "permlevel": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "Fiscal Year"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "company",
"fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
"label": "Company",
- "length": 0,
- "no_copy": 0,
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
- "permlevel": 0,
- "print_hide": 0,
- "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,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "finance_book",
"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": "Finance Book",
- "length": 0,
- "no_copy": 0,
- "options": "Finance Book",
- "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,
- "translatable": 0,
- "unique": 0
+ "options": "Finance Book"
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"default": "1",
"fieldname": "to_rename",
"fieldtype": "Check",
"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": "To Rename",
- "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": 1,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "search_index": 1
},
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_if_empty": 0,
"fieldname": "due_date",
"fieldtype": "Date",
- "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": "Due 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": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "label": "Due Date"
}
],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
"icon": "fa fa-list",
"idx": 1,
- "image_view": 0,
"in_create": 1,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2019-05-01 07:05:00.366399",
+ "modified": "2020-02-10 04:54:57.777905",
"modified_by": "Administrator",
"module": "Accounts",
"name": "GL Entry",
"owner": "Administrator",
"permissions": [
{
- "amend": 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": "Accounts User",
- "set_user_permissions": 0,
- "share": 0,
- "submit": 0,
- "write": 0
+ "role": "Accounts User"
},
{
- "amend": 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": "Accounts Manager",
- "set_user_permissions": 0,
- "share": 0,
- "submit": 0,
- "write": 0
+ "role": "Accounts Manager"
},
{
- "amend": 0,
- "cancel": 0,
- "create": 0,
- "delete": 0,
- "email": 0,
"export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 0,
"read": 1,
"report": 1,
- "role": "Auditor",
- "set_user_permissions": 0,
- "share": 0,
- "submit": 0,
- "write": 0
+ "role": "Auditor"
}
],
"quick_entry": 1,
- "read_only": 0,
- "read_only_onload": 0,
"search_fields": "voucher_no,account,posting_date,against_voucher",
- "show_name_in_global_search": 0,
"sort_field": "modified",
- "sort_order": "DESC",
- "track_changes": 0,
- "track_seen": 0,
- "track_views": 0
+ "sort_order": "DESC"
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
index 332a9007915..9c1fef69fac 100644
--- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
@@ -9,6 +9,8 @@ from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_orde
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.stock.get_item_details import get_item_details
from frappe import MandatoryError
+from erpnext.stock.doctype.item.test_item import make_item
+from erpnext.healthcare.doctype.lab_test_template.lab_test_template import make_item_price
class TestPricingRule(unittest.TestCase):
def setUp(self):
@@ -145,6 +147,52 @@ class TestPricingRule(unittest.TestCase):
self.assertEquals(details.get("margin_type"), "Percentage")
self.assertEquals(details.get("margin_rate_or_amount"), 10)
+ def test_mixed_conditions_for_item_group(self):
+ for item in ["Mixed Cond Item 1", "Mixed Cond Item 2"]:
+ make_item(item, {"item_group": "Products"})
+ make_item_price(item, "_Test Price List", 100)
+
+ test_record = {
+ "doctype": "Pricing Rule",
+ "title": "_Test Pricing Rule for Item Group",
+ "apply_on": "Item Group",
+ "item_groups": [
+ {
+ "item_group": "Products",
+ },
+ {
+ "item_group": "Seed",
+ },
+ ],
+ "selling": 1,
+ "mixed_conditions": 1,
+ "currency": "USD",
+ "rate_or_discount": "Discount Percentage",
+ "discount_percentage": 10,
+ "applicable_for": "Customer Group",
+ "customer_group": "All Customer Groups",
+ "company": "_Test Company"
+ }
+ frappe.get_doc(test_record.copy()).insert()
+
+ args = frappe._dict({
+ "item_code": "Mixed Cond Item 1",
+ "item_group": "Products",
+ "company": "_Test Company",
+ "price_list": "_Test Price List",
+ "currency": "_Test Currency",
+ "doctype": "Sales Order",
+ "conversion_rate": 1,
+ "price_list_currency": "_Test Currency",
+ "plc_conversion_rate": 1,
+ "order_type": "Sales",
+ "customer": "_Test Customer",
+ "customer_group": "_Test Customer Group",
+ "name": None
+ })
+ details = get_item_details(args)
+ self.assertEquals(details.get("discount_percentage"), 10)
+
def test_pricing_rule_for_variants(self):
from erpnext.stock.get_item_details import get_item_details
from frappe import MandatoryError
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index fe68fdb6c0f..e475563c77c 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -489,7 +489,7 @@ def get_pricing_rule_items(pr_doc):
for d in pr_doc.get(pricing_rule_apply_on):
if apply_on == 'item_group':
- get_child_item_groups(d.get(apply_on))
+ apply_on_data.extend(get_child_item_groups(d.get(apply_on)))
else:
apply_on_data.append(d.get(apply_on))
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 33ee7a2974e..52a0f4e081d 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -1,5 +1,4 @@
{
- "actions": [],
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2013-05-24 19:29:05",
@@ -373,7 +372,8 @@
"no_copy": 1,
"options": "Sales Invoice",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "search_index": 1
},
{
"fieldname": "column_break_21",
@@ -1568,8 +1568,7 @@
"icon": "fa fa-file-text",
"idx": 181,
"is_submittable": 1,
- "links": [],
- "modified": "2019-12-30 19:15:59.580414",
+ "modified": "2020-02-10 04:57:11.221180",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js
index e936a173734..f88906a0f1f 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.js
@@ -34,6 +34,20 @@ frappe.query_reports["Item-wise Purchase Register"] = {
"label": __("Mode of Payment"),
"fieldtype": "Link",
"options": "Mode of Payment"
+ },
+ {
+ "label": __("Group By"),
+ "fieldname": "group_by",
+ "fieldtype": "Select",
+ "options": ["Supplier", "Item Group", "Item", "Invoice"]
}
- ]
+ ],
+ "formatter": function(value, row, column, data, default_formatter) {
+ value = default_formatter(value, row, column, data);
+ if (data && data.bold) {
+ value = value.bold();
+
+ }
+ return value;
+ }
}
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index 380b208548c..8b6359c134d 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -5,7 +5,9 @@ from __future__ import unicode_literals
import frappe, erpnext
from frappe import _
from frappe.utils import flt
-from erpnext.accounts.report.item_wise_sales_register.item_wise_sales_register import get_tax_accounts
+from erpnext.accounts.report.item_wise_sales_register.item_wise_sales_register import (get_tax_accounts,
+ get_grand_total, add_total_row, get_display_value, get_group_by_and_display_fields, add_sub_total_row,
+ get_group_by_conditions)
def execute(filters=None):
return _execute(filters)
@@ -13,7 +15,7 @@ def execute(filters=None):
def _execute(filters=None, additional_table_columns=None, additional_query_columns=None):
if not filters: filters = {}
filters.update({"from_date": filters.get("date_range")[0], "to_date": filters.get("date_range")[1]})
- columns = get_columns(additional_table_columns)
+ columns = get_columns(additional_table_columns, filters)
company_currency = erpnext.get_company_currency(filters.company)
@@ -23,16 +25,16 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
itemised_tax, tax_columns = get_tax_accounts(item_list, columns, company_currency,
doctype="Purchase Invoice", tax_doctype="Purchase Taxes and Charges")
- columns.append({
- "fieldname": "currency",
- "label": _("Currency"),
- "fieldtype": "Data",
- "width": 80
- })
-
po_pr_map = get_purchase_receipts_against_purchase_order(item_list)
data = []
+ total_row_map = {}
+ skip_total_row = 0
+ prev_group_by_value = ''
+
+ if filters.get('group_by'):
+ grand_total = get_grand_total(filters, 'Purchase Invoice')
+
for d in item_list:
if not d.stock_qty:
continue
@@ -44,51 +46,243 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
purchase_receipt = ", ".join(po_pr_map.get(d.po_detail, []))
expense_account = d.expense_account or aii_account_map.get(d.company)
- row = [d.item_code, d.item_name, d.item_group, d.description, d.parent, d.posting_date, d.supplier,
- d.supplier_name]
+
+ row = {
+ 'item_code': d.item_code,
+ 'item_name': d.item_name,
+ 'item_group': d.item_group,
+ 'description': d.description,
+ 'invoice': d.parent,
+ 'posting_date': d.posting_date,
+ 'customer': d.supplier,
+ 'customer_name': d.supplier_name
+ }
if additional_query_columns:
for col in additional_query_columns:
- row.append(d.get(col))
+ row.update({
+ col: d.get(col)
+ })
- row += [
- d.credit_to, d.mode_of_payment, d.project, d.company, d.purchase_order,
- purchase_receipt, expense_account, d.stock_qty, d.stock_uom, d.base_net_amount / d.stock_qty, d.base_net_amount
- ]
+ row.update({
+ 'credit_to': d.credit_to,
+ 'mode_of_payment': d.mode_of_payment,
+ 'project': d.project,
+ 'company': d.company,
+ 'purchase_order': d.purchase_order,
+ 'purchase_receipt': d.purchase_receipt,
+ 'expense_account': expense_account,
+ 'stock_qty': d.stock_qty,
+ 'stock_uom': d.stock_uom,
+ 'rate': d.base_net_amount / d.stock_qty,
+ 'amount': d.base_net_amount
+ })
total_tax = 0
for tax in tax_columns:
item_tax = itemised_tax.get(d.name, {}).get(tax, {})
- row += [item_tax.get("tax_rate", 0), item_tax.get("tax_amount", 0)]
+ row.update({
+ frappe.scrub(tax + ' Rate'): item_tax.get("tax_rate", 0),
+ frappe.scrub(tax + ' Amount'): item_tax.get("tax_amount", 0),
+ })
total_tax += flt(item_tax.get("tax_amount"))
- row += [total_tax, d.base_net_amount + total_tax, company_currency]
+ row.update({
+ 'total_tax': total_tax,
+ 'total': d.base_net_amount + total_tax,
+ 'currency': company_currency
+ })
+
+ if filters.get('group_by'):
+ row.update({'percent_gt': flt(row['total']/grand_total) * 100})
+ group_by_field, subtotal_display_field = get_group_by_and_display_fields(filters)
+ data, prev_group_by_value = add_total_row(data, filters, prev_group_by_value, d, total_row_map,
+ group_by_field, subtotal_display_field, grand_total, tax_columns)
+ add_sub_total_row(row, total_row_map, d.get(group_by_field, ''), tax_columns)
data.append(row)
- return columns, data
+ if filters.get('group_by'):
+ total_row = total_row_map.get(prev_group_by_value or d.get('item_name'))
+ total_row['percent_gt'] = flt(total_row['total']/grand_total * 100)
+ data.append(total_row)
+ data.append({})
+ add_sub_total_row(total_row, total_row_map, 'total_row', tax_columns)
+ data.append(total_row_map.get('total_row'))
+ skip_total_row = 1
+
+ return columns, data, None, None, None, skip_total_row
-def get_columns(additional_table_columns):
- columns = [
- _("Item Code") + ":Link/Item:120", _("Item Name") + "::120",
- _("Item Group") + ":Link/Item Group:100", "Description::150", _("Invoice") + ":Link/Purchase Invoice:120",
- _("Posting Date") + ":Date:80", _("Supplier") + ":Link/Supplier:120",
- "Supplier Name::120"
- ]
+def get_columns(additional_table_columns, filters):
+
+ columns = []
+
+ if filters.get('group_by') != ('Item'):
+ columns.extend(
+ [
+ {
+ 'label': _('Item Code'),
+ 'fieldname': 'item_code',
+ 'fieldtype': 'Link',
+ 'options': 'Item',
+ 'width': 120
+ },
+ {
+ 'label': _('Item Name'),
+ 'fieldname': 'item_name',
+ 'fieldtype': 'Data',
+ 'width': 120
+ }
+ ]
+ )
+
+ if filters.get('group_by') not in ('Item', 'Item Group'):
+ columns.extend([
+ {
+ 'label': _('Item Group'),
+ 'fieldname': 'item_group',
+ 'fieldtype': 'Link',
+ 'options': 'Item Group',
+ 'width': 120
+ }
+ ])
+
+ columns.extend([
+ {
+ 'label': _('Description'),
+ 'fieldname': 'description',
+ 'fieldtype': 'Data',
+ 'width': 150
+ },
+ {
+ 'label': _('Invoice'),
+ 'fieldname': 'invoice',
+ 'fieldtype': 'Link',
+ 'options': 'Purchase Invoice',
+ 'width': 120
+ },
+ {
+ 'label': _('Posting Date'),
+ 'fieldname': 'posting_date',
+ 'fieldtype': 'Date',
+ 'width': 120
+ }
+ ])
+
+ if filters.get('group_by') != 'Supplier':
+ columns.extend([
+ {
+ 'label': _('Supplier'),
+ 'fieldname': 'supplier',
+ 'fieldtype': 'Link',
+ 'options': 'Supplier',
+ 'width': 120
+ },
+ {
+ 'label': _('Supplier Name'),
+ 'fieldname': 'supplier_name',
+ 'fieldtype': 'Data',
+ 'width': 120
+ }
+ ])
if additional_table_columns:
columns += additional_table_columns
columns += [
- "Payable Account:Link/Account:120",
- _("Mode of Payment") + ":Link/Mode of Payment:80", _("Project") + ":Link/Project:80",
- _("Company") + ":Link/Company:100", _("Purchase Order") + ":Link/Purchase Order:100",
- _("Purchase Receipt") + ":Link/Purchase Receipt:100", _("Expense Account") + ":Link/Account:140",
- _("Stock Qty") + ":Float:120", _("Stock UOM") + "::100",
- _("Rate") + ":Currency/currency:120", _("Amount") + ":Currency/currency:120"
+ {
+ 'label': _('Payable Account'),
+ 'fieldname': 'credit_to',
+ 'fieldtype': 'Link',
+ 'options': 'Account',
+ 'width': 80
+ },
+ {
+ 'label': _('Mode Of Payment'),
+ 'fieldname': 'mode_of_payment',
+ 'fieldtype': 'Data',
+ 'width': 120
+ },
+ {
+ 'label': _('Project'),
+ 'fieldname': 'project',
+ 'fieldtype': 'Link',
+ 'options': 'Project',
+ 'width': 80
+ },
+ {
+ 'label': _('Company'),
+ 'fieldname': 'company',
+ 'fieldtype': 'Link',
+ 'options': 'Company',
+ 'width': 80
+ },
+ {
+ 'label': _('Purchase Order'),
+ 'fieldname': 'purchase_order',
+ 'fieldtype': 'Link',
+ 'options': 'Purchase Order',
+ 'width': 100
+ },
+ {
+ 'label': _("Purchase Receipt"),
+ 'fieldname': 'Purchase Receipt',
+ 'fieldtype': 'Link',
+ 'options': 'Purchase Receipt',
+ 'width': 100
+ },
+ {
+ 'label': _('Expense Account'),
+ 'fieldname': 'expense_account',
+ 'fieldtype': 'Link',
+ 'options': 'Account',
+ 'width': 100
+ },
+ {
+ 'label': _('Stock Qty'),
+ 'fieldname': 'stock_qty',
+ 'fieldtype': 'Float',
+ 'width': 100
+ },
+ {
+ 'label': _('Stock UOM'),
+ 'fieldname': 'stock_uom',
+ 'fieldtype': 'Link',
+ 'options': 'UOM',
+ 'width': 100
+ },
+ {
+ 'label': _('Rate'),
+ 'fieldname': 'rate',
+ 'fieldtype': 'Float',
+ 'options': 'currency',
+ 'width': 100
+ },
+ {
+ 'label': _('Amount'),
+ 'fieldname': 'amount',
+ 'fieldtype': 'Currency',
+ 'options': 'currency',
+ 'width': 100
+ },
+ {
+ 'fieldname': 'currency',
+ 'label': _('Currency'),
+ 'fieldtype': 'Currency',
+ 'width': 80,
+ 'hidden': 1
+ }
]
+ if filters.get('group_by'):
+ columns.append({
+ 'label': _('% Of Grand Total'),
+ 'fieldname': 'percent_gt',
+ 'fieldtype': 'Float',
+ 'width': 80
+ })
+
return columns
def get_conditions(filters):
@@ -103,6 +297,11 @@ def get_conditions(filters):
if filters.get(opts[0]):
conditions += opts[1]
+ if not filters.get("group_by"):
+ conditions += "ORDER BY `tabPurchase Invoice`.posting_date desc, `tabPurchase Invoice Item`.item_code desc"
+ else:
+ conditions += get_group_by_conditions(filters, 'Purchase Invoice')
+
return conditions
def get_items(filters, additional_query_columns):
@@ -129,7 +328,6 @@ def get_items(filters, additional_query_columns):
from `tabPurchase Invoice`, `tabPurchase Invoice Item`
where `tabPurchase Invoice`.name = `tabPurchase Invoice Item`.`parent` and
`tabPurchase Invoice`.docstatus = 1 %s %s
- order by `tabPurchase Invoice`.posting_date desc, `tabPurchase Invoice Item`.item_code desc
""".format(additional_query_columns) % (conditions, match_conditions), filters, as_dict=1)
def get_aii_accounts():
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js
index 9dd9b3fad48..8a9c76f26f8 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.js
@@ -4,48 +4,62 @@
frappe.query_reports["Item-wise Sales Register"] = {
"filters": [
{
- "fieldname":"date_range",
+ "fieldname": "date_range",
"label": __("Date Range"),
"fieldtype": "DateRange",
"default": [frappe.datetime.add_months(frappe.datetime.get_today(),-1), frappe.datetime.get_today()],
"reqd": 1
},
{
- "fieldname":"customer",
+ "fieldname": "customer",
"label": __("Customer"),
"fieldtype": "Link",
"options": "Customer"
},
{
- "fieldname":"company",
+ "fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
},
{
- "fieldname":"mode_of_payment",
+ "fieldname": "mode_of_payment",
"label": __("Mode of Payment"),
"fieldtype": "Link",
"options": "Mode of Payment"
},
{
- "fieldname":"warehouse",
+ "fieldname": "warehouse",
"label": __("Warehouse"),
"fieldtype": "Link",
"options": "Warehouse"
},
{
- "fieldname":"brand",
+ "fieldname": "brand",
"label": __("Brand"),
"fieldtype": "Link",
"options": "Brand"
},
{
- "fieldname":"item_group",
+ "fieldname": "item_group",
"label": __("Item Group"),
"fieldtype": "Link",
"options": "Item Group"
+ },
+ {
+ "label": __("Group By"),
+ "fieldname": "group_by",
+ "fieldtype": "Select",
+ "options": ["Customer Group", "Customer", "Item Group", "Item", "Territory", "Invoice"]
}
- ]
+ ],
+ "formatter": function(value, row, column, data, default_formatter) {
+ value = default_formatter(value, row, column, data);
+ if (data && data.bold) {
+ value = value.bold();
+
+ }
+ return value;
+ }
}
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index 9da89ff2c9f..2cc2db6ca59 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe, erpnext
from frappe import _
-from frappe.utils import flt
+from frappe.utils import flt, cstr
from frappe.model.meta import get_field_precision
from frappe.utils.xlsxutils import handle_html
from erpnext.accounts.report.sales_register.sales_register import get_mode_of_payments
@@ -15,23 +15,25 @@ def execute(filters=None):
def _execute(filters=None, additional_table_columns=None, additional_query_columns=None):
if not filters: filters = {}
filters.update({"from_date": filters.get("date_range") and filters.get("date_range")[0], "to_date": filters.get("date_range") and filters.get("date_range")[1]})
- columns = get_columns(additional_table_columns)
+ columns = get_columns(additional_table_columns, filters)
company_currency = frappe.get_cached_value('Company', filters.get("company"), "default_currency")
item_list = get_items(filters, additional_query_columns)
if item_list:
itemised_tax, tax_columns = get_tax_accounts(item_list, columns, company_currency)
- columns.append({
- "fieldname": "currency",
- "label": _("Currency"),
- "fieldtype": "Data",
- "width": 80
- })
+
mode_of_payments = get_mode_of_payments(set([d.parent for d in item_list]))
so_dn_map = get_delivery_notes_against_sales_order(item_list)
data = []
+ total_row_map = {}
+ skip_total_row = 0
+ prev_group_by_value = ''
+
+ if filters.get('group_by'):
+ grand_total = get_grand_total(filters, 'Sales Invoice')
+
for d in item_list:
delivery_note = None
if d.delivery_note:
@@ -42,57 +44,285 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
if not delivery_note and d.update_stock:
delivery_note = d.parent
- row = [d.item_code, d.item_name, d.item_group, d.description, d.parent, d.posting_date, d.customer, d.customer_name]
+ row = {
+ 'item_code': d.item_code,
+ 'item_name': d.item_name,
+ 'item_group': d.item_group,
+ 'description': d.description,
+ 'invoice': d.parent,
+ 'posting_date': d.posting_date,
+ 'customer': d.customer,
+ 'customer_name': d.customer_name,
+ 'customer_group': d.customer_group,
+ }
if additional_query_columns:
for col in additional_query_columns:
- row.append(d.get(col))
+ row.update({
+ col: d.get(col)
+ })
- row += [
- d.customer_group, d.debit_to, ", ".join(mode_of_payments.get(d.parent, [])),
- d.territory, d.project, d.company, d.sales_order,
- delivery_note, d.income_account, d.cost_center, d.stock_qty, d.stock_uom
- ]
+ row.update({
+ 'debit_to': d.debit_to,
+ 'mode_of_payment': ", ".join(mode_of_payments.get(d.parent, [])),
+ 'territory': d.territory,
+ 'project': d.project,
+ 'company': d.company,
+ 'sales_order': d.sales_order,
+ 'delivery_note': d.delivery_note,
+ 'income_account': d.income_account,
+ 'cost_center': d.cost_center,
+ 'stock_qty': d.stock_qty,
+ 'stock_uom': d.stock_uom
+ })
if d.stock_uom != d.uom and d.stock_qty:
- row += [(d.base_net_rate * d.qty)/d.stock_qty, d.base_net_amount]
+ row.update({
+ 'rate': (d.base_net_rate * d.qty)/d.stock_qty,
+ 'amount': d.base_net_amount
+ })
else:
- row += [d.base_net_rate, d.base_net_amount]
+ row.update({
+ 'rate': d.base_net_rate,
+ 'amount': d.base_net_amount
+ })
total_tax = 0
for tax in tax_columns:
item_tax = itemised_tax.get(d.name, {}).get(tax, {})
- row += [item_tax.get("tax_rate", 0), item_tax.get("tax_amount", 0)]
+ row.update({
+ frappe.scrub(tax + ' Rate'): item_tax.get("tax_rate", 0),
+ frappe.scrub(tax + ' Amount'): item_tax.get("tax_amount", 0),
+ })
total_tax += flt(item_tax.get("tax_amount"))
- row += [total_tax, d.base_net_amount + total_tax, company_currency]
+ row.update({
+ 'total_tax': total_tax,
+ 'total': d.base_net_amount + total_tax,
+ 'currency': company_currency
+ })
+
+ if filters.get('group_by'):
+ row.update({'percent_gt': flt(row['total']/grand_total) * 100})
+ group_by_field, subtotal_display_field = get_group_by_and_display_fields(filters)
+ data, prev_group_by_value = add_total_row(data, filters, prev_group_by_value, d, total_row_map,
+ group_by_field, subtotal_display_field, grand_total, tax_columns)
+ add_sub_total_row(row, total_row_map, d.get(group_by_field, ''), tax_columns)
data.append(row)
- return columns, data
+ if filters.get('group_by'):
+ total_row = total_row_map.get(prev_group_by_value or d.get('item_name'))
+ total_row['percent_gt'] = flt(total_row['total']/grand_total * 100)
+ data.append(total_row)
+ data.append({})
+ add_sub_total_row(total_row, total_row_map, 'total_row', tax_columns)
+ data.append(total_row_map.get('total_row'))
+ skip_total_row = 1
+
+ return columns, data, None, None, None, skip_total_row
-def get_columns(additional_table_columns):
- columns = [
- _("Item Code") + ":Link/Item:120", _("Item Name") + "::120",
- _("Item Group") + ":Link/Item Group:100", "Description::150", _("Invoice") + ":Link/Sales Invoice:120",
- _("Posting Date") + ":Date:80", _("Customer") + ":Link/Customer:120",
- _("Customer Name") + "::120"]
+def get_columns(additional_table_columns, filters):
+ columns = []
+
+ if filters.get('group_by') != ('Item'):
+ columns.extend(
+ [
+ {
+ 'label': _('Item Code'),
+ 'fieldname': 'item_code',
+ 'fieldtype': 'Link',
+ 'options': 'Item',
+ 'width': 120
+ },
+ {
+ 'label': _('Item Name'),
+ 'fieldname': 'item_name',
+ 'fieldtype': 'Data',
+ 'width': 120
+ }
+ ]
+ )
+
+ if filters.get('group_by') not in ('Item', 'Item Group'):
+ columns.extend([
+ {
+ 'label': _('Item Group'),
+ 'fieldname': 'item_group',
+ 'fieldtype': 'Link',
+ 'options': 'Item Group',
+ 'width': 120
+ }
+ ])
+
+ columns.extend([
+ {
+ 'label': _('Description'),
+ 'fieldname': 'description',
+ 'fieldtype': 'Data',
+ 'width': 150
+ },
+ {
+ 'label': _('Invoice'),
+ 'fieldname': 'invoice',
+ 'fieldtype': 'Link',
+ 'options': 'Sales Invoice',
+ 'width': 120
+ },
+ {
+ 'label': _('Posting Date'),
+ 'fieldname': 'posting_date',
+ 'fieldtype': 'Date',
+ 'width': 120
+ }
+ ])
+
+ if filters.get('group_by') != 'Customer':
+ columns.extend([
+ {
+ 'label': _('Customer Group'),
+ 'fieldname': 'customer_group',
+ 'fieldtype': 'Link',
+ 'options': 'Customer Group',
+ 'width': 120
+ }
+ ])
+
+ if filters.get('group_by') not in ('Customer', 'Customer Group'):
+ columns.extend([
+ {
+ 'label': _('Customer'),
+ 'fieldname': 'customer',
+ 'fieldtype': 'Link',
+ 'options': 'Customer',
+ 'width': 120
+ },
+ {
+ 'label': _('Customer Name'),
+ 'fieldname': 'customer_name',
+ 'fieldtype': 'Data',
+ 'width': 120
+ }
+ ])
if additional_table_columns:
columns += additional_table_columns
columns += [
- _("Customer Group") + ":Link/Customer Group:120",
- _("Receivable Account") + ":Link/Account:120",
- _("Mode of Payment") + "::120", _("Territory") + ":Link/Territory:80",
- _("Project") + ":Link/Project:80", _("Company") + ":Link/Company:100",
- _("Sales Order") + ":Link/Sales Order:100", _("Delivery Note") + ":Link/Delivery Note:100",
- _("Income Account") + ":Link/Account:140", _("Cost Center") + ":Link/Cost Center:140",
- _("Stock Qty") + ":Float:120", _("Stock UOM") + "::100",
- _("Rate") + ":Currency/currency:120",
- _("Amount") + ":Currency/currency:120"
+ {
+ 'label': _('Receivable Account'),
+ 'fieldname': 'debit_to',
+ 'fieldtype': 'Link',
+ 'options': 'Account',
+ 'width': 80
+ },
+ {
+ 'label': _('Mode Of Payment'),
+ 'fieldname': 'mode_of_payment',
+ 'fieldtype': 'Data',
+ 'width': 120
+ }
]
+ if filters.get('group_by') != 'Terriotory':
+ columns.extend([
+ {
+ 'label': _("Territory"),
+ 'fieldname': 'territory',
+ 'fieldtype': 'Link',
+ 'options': 'Territory',
+ 'width': 80
+ }
+ ])
+
+
+ columns += [
+ {
+ 'label': _('Project'),
+ 'fieldname': 'project',
+ 'fieldtype': 'Link',
+ 'options': 'Project',
+ 'width': 80
+ },
+ {
+ 'label': _('Company'),
+ 'fieldname': 'company',
+ 'fieldtype': 'Link',
+ 'options': 'Company',
+ 'width': 80
+ },
+ {
+ 'label': _('Sales Order'),
+ 'fieldname': 'sales_order',
+ 'fieldtype': 'Link',
+ 'options': 'Sales Order',
+ 'width': 100
+ },
+ {
+ 'label': _("Delivery Note"),
+ 'fieldname': 'delivery_note',
+ 'fieldtype': 'Link',
+ 'options': 'Delivery Note',
+ 'width': 100
+ },
+ {
+ 'label': _('Income Account'),
+ 'fieldname': 'income_account',
+ 'fieldtype': 'Link',
+ 'options': 'Account',
+ 'width': 100
+ },
+ {
+ 'label': _("Cost Center"),
+ 'fieldname': 'cost_center',
+ 'fieldtype': 'Link',
+ 'options': 'Cost Center',
+ 'width': 100
+ },
+ {
+ 'label': _('Stock Qty'),
+ 'fieldname': 'stock_qty',
+ 'fieldtype': 'Float',
+ 'width': 100
+ },
+ {
+ 'label': _('Stock UOM'),
+ 'fieldname': 'stock_uom',
+ 'fieldtype': 'Link',
+ 'options': 'UOM',
+ 'width': 100
+ },
+ {
+ 'label': _('Rate'),
+ 'fieldname': 'rate',
+ 'fieldtype': 'Float',
+ 'options': 'currency',
+ 'width': 100
+ },
+ {
+ 'label': _('Amount'),
+ 'fieldname': 'amount',
+ 'fieldtype': 'Currency',
+ 'options': 'currency',
+ 'width': 100
+ },
+ {
+ 'fieldname': 'currency',
+ 'label': _('Currency'),
+ 'fieldtype': 'Currency',
+ 'width': 80,
+ 'hidden': 1
+ }
+ ]
+
+ if filters.get('group_by'):
+ columns.append({
+ 'label': _('% Of Grand Total'),
+ 'fieldname': 'percent_gt',
+ 'fieldtype': 'Float',
+ 'width': 80
+ })
+
return columns
def get_conditions(filters):
@@ -112,24 +342,32 @@ def get_conditions(filters):
and ifnull(`tabSales Invoice Payment`.mode_of_payment, '') = %(mode_of_payment)s)"""
if filters.get("warehouse"):
- conditions += """ and exists(select name from `tabSales Invoice Item`
- where parent=`tabSales Invoice`.name
- and ifnull(`tabSales Invoice Item`.warehouse, '') = %(warehouse)s)"""
+ conditions += """and ifnull(`tabSales Invoice Item`.warehouse, '') = %(warehouse)s"""
if filters.get("brand"):
- conditions += """ and exists(select name from `tabSales Invoice Item`
- where parent=`tabSales Invoice`.name
- and ifnull(`tabSales Invoice Item`.brand, '') = %(brand)s)"""
+ conditions += """and ifnull(`tabSales Invoice Item`.brand, '') = %(brand)s"""
if filters.get("item_group"):
- conditions += """ and exists(select name from `tabSales Invoice Item`
- where parent=`tabSales Invoice`.name
- and ifnull(`tabSales Invoice Item`.item_group, '') = %(item_group)s)"""
+ conditions += """and ifnull(`tabSales Invoice Item`.item_group, '') = %(item_group)s"""
+ if not filters.get("group_by"):
+ conditions += "ORDER BY `tabSales Invoice`.posting_date desc, `tabSales Invoice Item`.item_group desc"
+ else:
+ conditions += get_group_by_conditions(filters, 'Sales Invoice')
return conditions
+def get_group_by_conditions(filters, doctype):
+ if filters.get("group_by") == 'Invoice':
+ return "ORDER BY `tab{0} Item`.parent desc".format(doctype)
+ elif filters.get("group_by") == 'Item':
+ return "ORDER BY `tab{0} Item`.`item_code`".format(doctype)
+ elif filters.get("group_by") == 'Item Group':
+ return "ORDER BY `tab{0} Item`.{1}".format(doctype, frappe.scrub(filters.get('group_by')))
+ elif filters.get("group_by") in ('Customer', 'Customer Group', 'Territory', 'Supplier'):
+ return "ORDER BY `tab{0}`.{1}".format(doctype, frappe.scrub(filters.get('group_by')))
+
def get_items(filters, additional_query_columns):
conditions = get_conditions(filters)
match_conditions = frappe.build_match_conditions("Sales Invoice")
@@ -156,9 +394,8 @@ def get_items(filters, additional_query_columns):
`tabSales Invoice`.update_stock, `tabSales Invoice Item`.uom, `tabSales Invoice Item`.qty {0}
from `tabSales Invoice`, `tabSales Invoice Item`
where `tabSales Invoice`.name = `tabSales Invoice Item`.parent
- and `tabSales Invoice`.docstatus = 1 %s %s
- order by `tabSales Invoice`.posting_date desc, `tabSales Invoice Item`.item_code desc
- """.format(additional_query_columns or '') % (conditions, match_conditions), filters, as_dict=1)
+ and `tabSales Invoice`.docstatus = 1 {1} {2}
+ """.format(additional_query_columns or '', conditions, match_conditions), filters, as_dict=1) #nosec
def get_delivery_notes_against_sales_order(item_list):
so_dn_map = frappe._dict()
@@ -177,6 +414,15 @@ def get_delivery_notes_against_sales_order(item_list):
return so_dn_map
+def get_grand_total(filters, doctype):
+
+ return frappe.db.sql(""" SELECT
+ SUM(`tab{0}`.base_grand_total)
+ FROM `tab{0}`
+ WHERE `tab{0}`.docstatus = 1
+ and posting_date between %s and %s
+ """.format(doctype), (filters.get('from_date'), filters.get('to_date')))[0][0] #nosec
+
def get_deducted_taxes():
return frappe.db.sql_list("select name from `tabPurchase Taxes and Charges` where add_deduct_tax = 'Deduct'")
@@ -264,9 +510,117 @@ def get_tax_accounts(item_list, columns, company_currency,
tax_columns.sort()
for desc in tax_columns:
- columns.append(desc + " Rate:Data:80")
- columns.append(desc + " Amount:Currency/currency:100")
+ columns.append({
+ 'label': _(desc + ' Rate'),
+ 'fieldname': frappe.scrub(desc + ' Rate'),
+ 'fieldtype': 'Float',
+ 'width': 100
+ })
- columns += ["Total Tax:Currency/currency:80", "Total:Currency/currency:100"]
+ columns.append({
+ 'label': _(desc + ' Amount'),
+ 'fieldname': frappe.scrub(desc + ' Amount'),
+ 'fieldtype': 'Currency',
+ 'options': 'currency',
+ 'width': 100
+ })
+
+ columns += [
+ {
+ 'label': _('Total Tax'),
+ 'fieldname': 'total_tax',
+ 'fieldtype': 'Currency',
+ 'options': 'currency',
+ 'width': 100
+ },
+ {
+ 'label': _('Total'),
+ 'fieldname': 'total',
+ 'fieldtype': 'Currency',
+ 'options': 'currency',
+ 'width': 100
+ }
+ ]
return itemised_tax, tax_columns
+
+def add_total_row(data, filters, prev_group_by_value, item, total_row_map,
+ group_by_field, subtotal_display_field, grand_total, tax_columns):
+ if prev_group_by_value != item.get(group_by_field, ''):
+ if prev_group_by_value:
+ total_row = total_row_map.get(prev_group_by_value)
+ data.append(total_row)
+ data.append({})
+ add_sub_total_row(total_row, total_row_map, 'total_row', tax_columns)
+
+ prev_group_by_value = item.get(group_by_field, '')
+
+ total_row_map.setdefault(item.get(group_by_field, ''), {
+ subtotal_display_field: get_display_value(filters, group_by_field, item),
+ 'stock_qty': 0.0,
+ 'amount': 0.0,
+ 'bold': 1,
+ 'total_tax': 0.0,
+ 'total': 0.0,
+ 'percent_gt': 0.0
+ })
+
+ total_row_map.setdefault('total_row', {
+ subtotal_display_field: "Total",
+ 'stock_qty': 0.0,
+ 'amount': 0.0,
+ 'bold': 1,
+ 'total_tax': 0.0,
+ 'total': 0.0,
+ 'percent_gt': 0.0
+ })
+
+ return data, prev_group_by_value
+
+def get_display_value(filters, group_by_field, item):
+ if filters.get('group_by') == 'Item':
+ if item.get('item_code') != item.get('item_name'):
+ value = cstr(item.get('item_code')) + "
" + \
+ "" + cstr(item.get('item_name')) + ""
+ else:
+ value = item.get('item_code', '')
+ elif filters.get('group_by') in ('Customer', 'Supplier'):
+ party = frappe.scrub(filters.get('group_by'))
+ if item.get(party) != item.get(party+'_name'):
+ value = item.get(party) + "
" + \
+ "" + item.get(party+'_name') + ""
+ else:
+ value = item.get(party)
+ else:
+ value = item.get(group_by_field)
+
+ return value
+
+def get_group_by_and_display_fields(filters):
+ if filters.get('group_by') == 'Item':
+ group_by_field = 'item_code'
+ subtotal_display_field = 'invoice'
+ elif filters.get('group_by') == 'Invoice':
+ group_by_field = 'parent'
+ subtotal_display_field = 'item_code'
+ else:
+ group_by_field = frappe.scrub(filters.get('group_by'))
+ subtotal_display_field = 'item_code'
+
+ return group_by_field, subtotal_display_field
+
+def add_sub_total_row(item, total_row_map, group_by_value, tax_columns):
+ total_row = total_row_map.get(group_by_value)
+ total_row['stock_qty'] += item['stock_qty']
+ total_row['amount'] += item['amount']
+ total_row['total_tax'] += item['total_tax']
+ total_row['total'] += item['total']
+ total_row['percent_gt'] += item['percent_gt']
+
+ for tax in tax_columns:
+ total_row.setdefault(frappe.scrub(tax + ' Amount'), 0.0)
+ total_row[frappe.scrub(tax + ' Amount')] += flt(item[frappe.scrub(tax + ' Amount')])
+
+
+
+
diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py
index afdd31df16d..2be90bc5264 100644
--- a/erpnext/accounts/report/sales_register/sales_register.py
+++ b/erpnext/accounts/report/sales_register/sales_register.py
@@ -139,7 +139,7 @@ def get_columns(invoice_list, additional_table_columns):
columns +=[
{
- 'label': _("Custmer Group"),
+ 'label': _("Customer Group"),
'fieldname': 'customer_group',
'fieldtype': 'Link',
'options': 'Customer Group',
@@ -175,7 +175,7 @@ def get_columns(invoice_list, additional_table_columns):
'label': _("Project"),
'fieldname': 'project',
'fieldtype': 'Link',
- 'options': 'project',
+ 'options': 'Project',
'width': 80
},
{
diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.py b/erpnext/buying/report/procurement_tracker/procurement_tracker.py
index 48295bee26a..866bf0c7332 100644
--- a/erpnext/buying/report/procurement_tracker/procurement_tracker.py
+++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.py
@@ -141,13 +141,13 @@ def get_conditions(filters):
conditions = ""
if filters.get("company"):
- conditions += " AND company='%s'"% filters.get('company')
+ conditions += " AND company=%s"% frappe.db.escape(filters.get('company'))
if filters.get("cost_center") or filters.get("project"):
conditions += """
- AND (cost_center='%s'
- OR project='%s')
- """% (filters.get('cost_center'), filters.get('project'))
+ AND (cost_center=%s
+ OR project=%s)
+ """% (frappe.db.escape(filters.get('cost_center')), frappe.db.escape(filters.get('project')))
if filters.get("from_date"):
conditions += " AND transaction_date>=%s"% filters.get('from_date')
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 7faf792d203..001da5b5ea8 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -1135,6 +1135,7 @@ def set_sales_order_defaults(parent_doctype, parent_doctype_name, child_docname,
child_item.reqd_by_date = p_doctype.delivery_date
child_item.uom = item.stock_uom
child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0
+ child_item.warehouse = p_doctype.set_warehouse or p_doctype.items[0].warehouse
return child_item
diff --git a/erpnext/education/doctype/fee_schedule/fee_schedule.py b/erpnext/education/doctype/fee_schedule/fee_schedule.py
index a42800a80d5..bba101f2f1f 100644
--- a/erpnext/education/doctype/fee_schedule/fee_schedule.py
+++ b/erpnext/education/doctype/fee_schedule/fee_schedule.py
@@ -123,9 +123,11 @@ def get_students(student_group, academic_year, academic_term=None, student_categ
students = frappe.db.sql("""
select pe.student, pe.student_name, pe.program, pe.student_batch_name
- from `tabStudent Group Student` sgs, `tabProgram Enrollment` pe
+ from `tabStudent Group Student` sgs, `tabProgram Enrollment` pe, `tabStudent Group` sg
where
pe.student = sgs.student and pe.academic_year = %s
+ and sg.program = pe.program
+ and sg.name = sgs.parent
and sgs.parent = %s and sgs.active = 1
{conditions}
""".format(conditions=conditions), (academic_year, student_group), as_dict=1)
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 10a8d8fc9bd..76202e5a6f3 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -625,7 +625,6 @@ def get_items_for_material_requests(doc, ignore_existing_ordered_qty=None):
for data in po_items:
planned_qty = data.get('required_qty') or data.get('planned_qty')
ignore_existing_ordered_qty = data.get('ignore_existing_ordered_qty') or ignore_existing_ordered_qty
- warehouse = data.get("warehouse") or warehouse
item_details = {}
if data.get("bom") or data.get("bom_no"):
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 17c9a20766d..9fde54225ac 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -648,3 +648,4 @@ erpnext.patches.v12_0.update_owner_fields_in_acc_dimension_custom_fields
erpnext.patches.v12_0.remove_denied_leaves_from_leave_ledger
erpnext.patches.v12_0.update_price_or_product_discount
erpnext.patches.v12_0.add_export_type_field_in_party_master
+erpnext.patches.v12_0.create_irs_1099_field_united_states
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/create_irs_1099_field_united_states.py b/erpnext/patches/v12_0/create_irs_1099_field_united_states.py
new file mode 100644
index 00000000000..3e4c87f434e
--- /dev/null
+++ b/erpnext/patches/v12_0/create_irs_1099_field_united_states.py
@@ -0,0 +1,10 @@
+from __future__ import unicode_literals
+import frappe
+from erpnext.regional.united_states.setup import make_custom_fields
+
+def execute():
+ company = frappe.get_all('Company', filters = {'country': 'United States'})
+ if not company:
+ return
+
+ make_custom_fields()
\ No newline at end of file
diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js
index 4ec12ce8e7f..23895ee4c02 100644
--- a/erpnext/public/js/utils/serial_no_batch_selector.js
+++ b/erpnext/public/js/utils/serial_no_batch_selector.js
@@ -90,7 +90,8 @@ erpnext.SerialNoBatchSelector = Class.extend({
args: {
qty: qty,
item_code: me.item_code,
- warehouse: me.warehouse_details.name
+ warehouse: me.warehouse_details.name,
+ batch_no: me.item.batch_no || null
}
});
@@ -392,7 +393,7 @@ erpnext.SerialNoBatchSelector = Class.extend({
delivery_document_no: ""
}
- if (this.has_batch) {
+ if (this.item.batch_no) {
serial_no_filters["batch_no"] = this.item.batch_no;
}
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index 9f258828660..43778404b60 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -174,15 +174,11 @@ def get_child_groups(item_group_name):
and show_in_website = 1""", {"lft": item_group.lft, "rgt": item_group.rgt})
def get_child_item_groups(item_group_name):
- child_item_groups = frappe.cache().hget("child_item_groups", item_group_name)
+ item_group = frappe.get_cached_value("Item Group",
+ item_group_name, ["lft", "rgt"], as_dict=1)
- if not child_item_groups:
- item_group = frappe.get_cached_doc("Item Group", item_group_name)
-
- child_item_groups = [d.name for d in frappe.get_all('Item Group',
- filters= {'lft': ('>=', item_group.lft),'rgt': ('>=', item_group.rgt)})]
-
- frappe.cache().hset("child_item_groups", item_group_name, child_item_groups)
+ child_item_groups = [d.name for d in frappe.get_all('Item Group',
+ filters= {'lft': ('>=', item_group.lft),'rgt': ('<=', item_group.rgt)})]
return child_item_groups or {}
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index f34b0472f0d..50f27c18e31 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -477,10 +477,11 @@ def get_delivery_note_serial_no(item_code, qty, delivery_note):
return serial_nos
@frappe.whitelist()
-def auto_fetch_serial_number(qty, item_code, warehouse):
+def auto_fetch_serial_number(qty, item_code, warehouse, batch_no=None):
serial_numbers = frappe.get_list("Serial No", filters={
"item_code": item_code,
"warehouse": warehouse,
+ "batch_no": batch_no,
"delivery_document_no": "",
"sales_invoice": ""
}, limit=qty, order_by="creation")
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 4b07f0aef9f..56cb3f06b94 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -1056,7 +1056,7 @@ class StockEntry(StockController):
req_qty_each = flt(req_qty / manufacturing_qty)
consumed_qty = flt(req_items[0].consumed_qty)
- if trans_qty and manufacturing_qty >= (produced_qty + flt(self.fg_completed_qty)):
+ if trans_qty and manufacturing_qty > (produced_qty + flt(self.fg_completed_qty)):
if qty >= req_qty:
qty = (req_qty/trans_qty) * flt(self.fg_completed_qty)
else: