From 565d986198c5fd68d9ebdfc981c629b0ee6457e6 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 7 Oct 2014 18:26:39 +0530 Subject: [PATCH] fiscal year auto fetch added to oppurtunity, quotation, material request, supplier quotation, expense claim doctypes + issues fixed --- .../supplier_quotation/supplier_quotation.js | 10 ++++ .../hr/doctype/expense_claim/expense_claim.js | 9 ++++ .../doctype/expense_claim/expense_claim.json | 47 +++++++++---------- erpnext/public/js/transaction.js | 4 +- erpnext/public/js/utils.js | 3 +- .../doctype/opportunity/opportunity.js | 8 ++++ .../doctype/opportunity/opportunity.json | 23 ++++----- .../selling/doctype/quotation/quotation.js | 9 ++++ .../material_request/material_request.js | 10 ++++ 9 files changed, 83 insertions(+), 40 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index b8d40ca236..13fb4e04d7 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -11,6 +11,8 @@ cur_frm.cscript.other_fname = "other_charges"; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} {% include 'accounts/doctype/sales_invoice/pos.js' %} +frappe.require("assets/erpnext/js/utils.js"); + erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ refresh: function() { this._super(); @@ -72,3 +74,11 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) { filters:{'supplier': doc.supplier} } } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index a4ba2eb7bf..a4a64d9092 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.hr"); +frappe.require("assets/erpnext/js/utils.js"); erpnext.hr.ExpenseClaimController = frappe.ui.form.Controller.extend({ make_bank_voucher: function() { @@ -154,3 +155,11 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.email_doc(frappe.boot.notification_settings.expense_claim_message); } } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.posting_date); +} + +cur_frm.cscript.posting_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.posting_date); +} \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.json b/erpnext/hr/doctype/expense_claim/expense_claim.json index 15ef03ed17..a82ef90c7b 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.json +++ b/erpnext/hr/doctype/expense_claim/expense_claim.json @@ -89,6 +89,16 @@ "options": "Simple", "permlevel": 0 }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1 + }, { "fieldname": "employee", "fieldtype": "Link", @@ -114,17 +124,6 @@ "search_index": 0, "width": "150px" }, - { - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", - "permlevel": 0, - "reqd": 1 - }, { "fieldname": "company", "fieldtype": "Link", @@ -136,21 +135,22 @@ "permlevel": 0, "reqd": 1 }, + { + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", + "permlevel": 0, + "reqd": 1 + }, { "fieldname": "cb1", "fieldtype": "Column Break", "permlevel": 0 }, - { - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "permlevel": 0, - "reqd": 1 - }, { "allow_on_submit": 0, "fieldname": "remark", @@ -190,7 +190,7 @@ "icon": "icon-money", "idx": 1, "is_submittable": 1, - "modified": "2014-08-27 07:08:48.454580", + "modified": "2014-10-07 18:22:14.689567", "modified_by": "Administrator", "module": "HR", "name": "Expense Claim", @@ -206,7 +206,6 @@ "read": 1, "report": 1, "role": "Employee", - "user_permission_doctypes": "[\"Company\",\"Employee\",\"Expense Claim\",\"Fiscal Year\"]", "write": 1 }, { @@ -222,7 +221,6 @@ "report": 1, "role": "Expense Approver", "submit": 1, - "user_permission_doctypes": "[\"Expense Claim\",\"User\"]", "write": 1 }, { @@ -238,7 +236,6 @@ "report": 1, "role": "HR User", "submit": 1, - "user_permission_doctypes": "[\"Company\",\"Expense Claim\",\"Fiscal Year\"]", "write": 1 } ], diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 355a11c01a..8fce8e89a7 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -223,11 +223,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.frm.script_manager.trigger("currency"); this.apply_pricing_rule(); } - erpnext.get_fiscal_year(this.frm.doc); + erpnext.get_fiscal_year(this.frm.doc.company, this.frm.doc.posting_date); }, posting_date: function() { - erpnext.get_fiscal_year(this.frm.doc); + erpnext.get_fiscal_year(this.frm.doc.company, this.frm.doc.posting_date); }, get_company_currency: function() { diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index b508471eaa..5a0e9d4954 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -22,8 +22,7 @@ $.extend(erpnext, { "verbose": '0' }, callback: function(r) { - var arr = r.message - if (arr != null) cur_frm.set_value("fiscal_year",arr[0]); + if (r.message) cur_frm.set_value("fiscal_year", r.message[0]); } }); }, diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js index df84d72b6b..b29c03ac0b 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.js +++ b/erpnext/selling/doctype/opportunity/opportunity.js @@ -8,6 +8,7 @@ frappe.ui.form.on_change("Opportunity", "contact_person", erpnext.utils.get_cont frappe.provide("erpnext.selling"); +frappe.require("assets/erpnext/js/utils.js"); cur_frm.email_field = "contact_email"; // TODO commonify this code @@ -145,3 +146,10 @@ cur_frm.cscript.send_sms = function() { var sms_man = new SMSManager(cur_frm.doc); } +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity/opportunity.json b/erpnext/selling/doctype/opportunity/opportunity.json index 270fe779fe..a47b21f176 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.json +++ b/erpnext/selling/doctype/opportunity/opportunity.json @@ -272,13 +272,13 @@ "width": "50px" }, { - "fieldname": "fiscal_year", + "fieldname": "company", "fieldtype": "Link", "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", "permlevel": 0, "print_hide": 1, "read_only": 0, @@ -307,13 +307,13 @@ "read_only": 0 }, { - "fieldname": "company", + "fieldname": "fiscal_year", "fieldtype": "Link", "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", "permlevel": 0, "print_hide": 1, "read_only": 0, @@ -388,7 +388,7 @@ "icon": "icon-info-sign", "idx": 1, "is_submittable": 1, - "modified": "2014-09-11 18:53:14.037512", + "modified": "2014-10-07 18:12:19.104820", "modified_by": "Administrator", "module": "Selling", "name": "Opportunity", @@ -396,6 +396,7 @@ "permissions": [ { "amend": 1, + "apply_user_permissions": 1, "cancel": 1, "create": 1, "delete": 1, diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 5f25446ed2..c00b6e1918 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -12,6 +12,8 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} {% include 'accounts/doctype/sales_invoice/pos.js' %} +frappe.require("assets/erpnext/js/utils.js"); + erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ onload: function(doc, dt, dn) { var me = this; @@ -171,3 +173,10 @@ cur_frm.cscript.send_sms = function() { var sms_man = new SMSManager(cur_frm.doc); } +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 3729b55c7e..27dd728cf5 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -6,6 +6,8 @@ cur_frm.cscript.fname = "indent_details"; {% include 'buying/doctype/purchase_common/purchase_common.js' %}; +frappe.require("assets/erpnext/js/utils.js"); + erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({ onload: function(doc) { this._super(); @@ -195,3 +197,11 @@ cur_frm.cscript.send_sms = function() { frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(cur_frm.doc); } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file