diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 67d9a35cbdb..20f5e544e3e 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.17' 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 5ecab8d322b..032fd66d037 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -9,6 +9,7 @@ import frappe.defaults 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): @@ -54,6 +55,7 @@ class StockController(AccountsController): 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({ @@ -86,6 +88,14 @@ class StockController(AccountsController): 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 32171b06010..b5e195c6aac 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -30,7 +30,7 @@ frappe.ui.form.on("Opportunity", { frm.events.enquiry_from(frm); frm.trigger('set_contact_link'); - if(doc.status!=="Lost") { + if(!doc.__islocal && doc.status!=="Lost") { if(doc.with_items){ frm.add_custom_button(__('Supplier Quotation'), function() { @@ -121,7 +121,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 513d82fe0b7..87c070e0692 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -368,3 +368,4 @@ erpnext.patches.v7_2.contact_address_links erpnext.patches.v7_2.mark_students_active erpnext.patches.v7_2.set_null_value_to_fields erpnext.patches.v7_2.update_guardian_name_in_student_master +erpnext.patches.v7_2.update_abbr_in_salary_slips 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 00000000000..aa6965f17cb --- /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