Merge branch 'develop' into guarding-name

This commit is contained in:
Neil Trini Lasrado 2017-01-27 16:54:50 +05:30 committed by GitHub
commit 7ff5682193
5 changed files with 27 additions and 3 deletions

View File

@ -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'''

View File

@ -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}")

View File

@ -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");

View File

@ -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

View File

@ -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))