diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 7ad096edd72e..d22936a4b29f 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import frappe -__version__ = '7.2.14' +__version__ = '7.2.15' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 2e6f45433e38..e167860234fd 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -9,6 +9,7 @@ from erpnext.accounts.utils import get_fiscal_year from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries, process_gl_map from erpnext.controllers.accounts_controller import AccountsController +from erpnext.stock.stock_ledger import get_valuation_rate class StockController(AccountsController): def validate(self): @@ -51,8 +52,9 @@ def get_gl_entries(self, warehouse_account=None, default_expense_account=None, # from warehouse account self.check_expense_account(item_row) - + if not sle.stock_value_difference: + self.update_stock_ledger_entries(sle) self.validate_negative_stock(sle) gl_list.append(self.get_gl_dict({ @@ -84,7 +86,15 @@ def get_gl_entries(self, warehouse_account=None, default_expense_account=None, "\n".join(warehouse_with_no_account)) return process_gl_map(gl_list) - + + def update_stock_ledger_entries(self, sle): + sle.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse, + sle.voucher_type, sle.voucher_no) + sle.stock_value = flt(sle.qty_after_transaction) * flt(sle.valuation_rate) + sle.stock_value_difference = sle.stock_value + sle.doctype="Stock Ledger Entry" + frappe.get_doc(sle).db_update() + def validate_negative_stock(self, sle): if sle.qty_after_transaction < 0 and sle.actual_qty < 0: frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting {1} {2}") diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 21fba7b1e72a..b86a5a528744 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -23,7 +23,7 @@ frappe.ui.form.on("Opportunity", { refresh: function(frm) { var doc = frm.doc; frm.events.enquiry_from(frm); - if(doc.status!=="Lost") { + if(!doc.__islocal && doc.status!=="Lost") { if(doc.with_items){ frm.add_custom_button(__('Supplier Quotation'), function() { @@ -109,7 +109,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { erpnext.toggle_naming_series(); var frm = cur_frm; - if(frm.perm[0].write && doc.docstatus==0) { + if(!doc.__islocal && frm.perm[0].write && doc.docstatus==0) { if(frm.doc.status==="Open") { frm.add_custom_button(__("Close"), function() { frm.set_value("status", "Closed"); diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e600a576181f..b997dfc13b22 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -362,4 +362,5 @@ execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statm erpnext.patches.v7_2.update_website_for_variant erpnext.patches.v7_2.update_doctype_status erpnext.patches.v7_2.update_salary_slips -erpnext.patches.v7_2.set_null_value_to_fields \ No newline at end of file +erpnext.patches.v7_2.set_null_value_to_fields +erpnext.patches.v7_2.update_abbr_in_salary_slips \ No newline at end of file diff --git a/erpnext/patches/v7_2/update_abbr_in_salary_slips.py b/erpnext/patches/v7_2/update_abbr_in_salary_slips.py new file mode 100644 index 000000000000..aa6965f17cb7 --- /dev/null +++ b/erpnext/patches/v7_2/update_abbr_in_salary_slips.py @@ -0,0 +1,13 @@ +import frappe + +def execute(): + frappe.reload_doctype('Salary Slip') + if not frappe.db.has_column('Salary Detail', 'abbr'): + return + + salary_details = frappe.db.sql("""select abbr, salary_component, name from `tabSalary Detail` + where abbr is null or abbr = ''""", as_dict=True) + + for salary_detail in salary_details: + salary_component_abbr = frappe.get_value("Salary Component", salary_detail.salary_component, "salary_component_abbr") + frappe.db.sql("""update `tabSalary Detail` set abbr = %s where name = %s""",(salary_component_abbr, salary_detail.name)) \ No newline at end of file