Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta committed Jan 27, 2017
2 parents b736aaf + 149c033 commit 83cc7c9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''
Expand Down
14 changes: 12 additions & 2 deletions erpnext/controllers/stock_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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}")
Expand Down
4 changes: 2 additions & 2 deletions erpnext/crm/doctype/opportunity/opportunity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
erpnext.patches.v7_2.set_null_value_to_fields
erpnext.patches.v7_2.update_abbr_in_salary_slips
13 changes: 13 additions & 0 deletions erpnext/patches/v7_2/update_abbr_in_salary_slips.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 83cc7c9

Please sign in to comment.