From 4389cf0c48fbba407c6819d376e881c48fad1c24 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 15 Mar 2019 00:13:22 +0530 Subject: [PATCH] feat: provision to make Maintenance Schedule from sales invoice --- .../doctype/sales_invoice/sales_invoice.js | 13 ++ .../doctype/sales_invoice/sales_invoice.py | 16 +++ .../doctype/sales_team/sales_team.json | 44 ++++++- .../setup/doctype/item_group/item_group.json | 117 +++++++++++++----- 4 files changed, 157 insertions(+), 33 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 9a40d2b17e..3061af2130 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -89,6 +89,12 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }, __('Create')); } + if (doc.docstatus == 1) { + cur_frm.add_custom_button(__('Maintenance Schedule'), function () { + cur_frm.cscript.make_maintenance_schedule(); + }, __('Create')); + } + if(!doc.auto_repeat) { cur_frm.add_custom_button(__('Subscription'), function() { erpnext.utils.make_subscription(doc.doctype, doc.name) @@ -118,6 +124,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }, + make_maintenance_schedule: function() { + frappe.model.open_mapped_doc({ + method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule", + frm: cur_frm + }) + }, + on_submit: function(doc, dt, dn) { var me = this; diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 61e1224596..ce567eaa6d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1230,6 +1230,22 @@ def get_bank_cash_account(mode_of_payment, company): "account": account } +@frappe.whitelist() +def make_maintenance_schedule(source_name, target_doc=None): + doclist = get_mapped_doc("Sales Invoice", source_name, { + "Sales Invoice": { + "doctype": "Maintenance Schedule", + "validation": { + "docstatus": ["=", 1] + } + }, + "Sales Invoice Item": { + "doctype": "Maintenance Schedule Item", + }, + }, target_doc) + + return doclist + @frappe.whitelist() def make_delivery_note(source_name, target_doc=None): def set_missing_values(source, target): diff --git a/erpnext/selling/doctype/sales_team/sales_team.json b/erpnext/selling/doctype/sales_team/sales_team.json index 04027b2396..90521347de 100644 --- a/erpnext/selling/doctype/sales_team/sales_team.json +++ b/erpnext/selling/doctype/sales_team/sales_team.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_events_in_timeline": 0, "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, @@ -19,6 +20,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "sales_person", "fieldtype": "Link", "hidden": 0, @@ -55,6 +57,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "contact_no", "fieldtype": "Data", "hidden": 1, @@ -90,6 +93,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "allocated_percentage", "fieldtype": "Float", "hidden": 0, @@ -118,6 +122,40 @@ "unique": 0, "width": "100px" }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "item_group", + "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 Group", + "length": 0, + "no_copy": 0, + "options": "Item Group", + "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 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -125,6 +163,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "allocated_amount", "fieldtype": "Currency", "hidden": 0, @@ -161,6 +200,8 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "item_group.commission_rate", + "fetch_if_empty": 1, "fieldname": "commission_rate", "fieldtype": "Data", "hidden": 0, @@ -193,6 +234,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "incentives", "fieldtype": "Currency", "hidden": 0, @@ -231,7 +273,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-09-17 13:03:14.755974", + "modified": "2019-03-15 00:06:59.441936", "modified_by": "Administrator", "module": "Selling", "name": "Sales Team", diff --git a/erpnext/setup/doctype/item_group/item_group.json b/erpnext/setup/doctype/item_group/item_group.json index 656d460e0f..a99c9ea34f 100644 --- a/erpnext/setup/doctype/item_group/item_group.json +++ b/erpnext/setup/doctype/item_group/item_group.json @@ -21,6 +21,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "gs", "fieldtype": "Section Break", "hidden": 0, @@ -52,6 +53,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "item_group_name", "fieldtype": "Data", "hidden": 0, @@ -86,6 +88,7 @@ "collapsible": 0, "columns": 0, "description": "", + "fetch_if_empty": 0, "fieldname": "parent_item_group", "fieldtype": "Link", "hidden": 0, @@ -121,6 +124,7 @@ "collapsible": 0, "columns": 0, "description": "Only leaf nodes are allowed in transaction", + "fetch_if_empty": 0, "fieldname": "is_group", "fieldtype": "Check", "hidden": 0, @@ -155,6 +159,71 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 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, + "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 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "commission_rate", + "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": "Commission Rate", + "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 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, "fieldname": "image", "fieldtype": "Attach Image", "hidden": 1, @@ -187,36 +256,7 @@ "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, - "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 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "fetch_if_empty": 0, "fieldname": "defaults", "fieldtype": "Section Break", "hidden": 0, @@ -249,6 +289,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "item_group_defaults", "fieldtype": "Table", "hidden": 0, @@ -283,6 +324,7 @@ "collapsible": 0, "collapsible_depends_on": "", "columns": 0, + "fetch_if_empty": 0, "fieldname": "sec_break_taxes", "fieldtype": "Section Break", "hidden": 0, @@ -315,6 +357,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "taxes", "fieldtype": "Table", "hidden": 0, @@ -348,6 +391,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "sb9", "fieldtype": "Section Break", "hidden": 0, @@ -380,6 +424,7 @@ "collapsible": 0, "columns": 0, "description": "Check this if you want to show in website", + "fetch_if_empty": 0, "fieldname": "show_in_website", "fieldtype": "Check", "hidden": 0, @@ -412,6 +457,7 @@ "collapsible": 0, "columns": 0, "depends_on": "show_in_website", + "fetch_if_empty": 0, "fieldname": "route", "fieldtype": "Data", "hidden": 0, @@ -444,6 +490,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "weightage", "fieldtype": "Int", "hidden": 0, @@ -478,6 +525,7 @@ "columns": 0, "depends_on": "show_in_website", "description": "Show this slideshow at the top of the page", + "fetch_if_empty": 0, "fieldname": "slideshow", "fieldtype": "Link", "hidden": 0, @@ -512,6 +560,7 @@ "columns": 0, "depends_on": "show_in_website", "description": "HTML / Banner that will show on the top of product list.", + "fetch_if_empty": 0, "fieldname": "description", "fieldtype": "Text Editor", "hidden": 0, @@ -544,6 +593,7 @@ "collapsible": 0, "columns": 0, "depends_on": "show_in_website", + "fetch_if_empty": 0, "fieldname": "website_specifications", "fieldtype": "Table", "hidden": 0, @@ -576,6 +626,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "lft", "fieldtype": "Int", "hidden": 1, @@ -609,6 +660,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "rgt", "fieldtype": "Int", "hidden": 1, @@ -643,6 +695,7 @@ "collapsible": 0, "columns": 0, "description": "", + "fetch_if_empty": 0, "fieldname": "old_parent", "fieldtype": "Link", "hidden": 1, @@ -683,7 +736,7 @@ "issingle": 0, "istable": 0, "max_attachments": 3, - "modified": "2018-11-23 15:17:28.003933", + "modified": "2019-03-15 00:05:25.816002", "modified_by": "Administrator", "module": "Setup", "name": "Item Group", @@ -814,4 +867,4 @@ "track_changes": 0, "track_seen": 0, "track_views": 0 -} +} \ No newline at end of file