Merge branch 'develop' of https://github.com/frappe/erpnext into leave-management
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index fc46132..8098329 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -683,8 +683,8 @@
order_list = []
for d in orders:
- if not (d.outstanding_amount >= filters.get("outstanding_amt_greater_than")
- and d.outstanding_amount <= filters.get("outstanding_amt_less_than")):
+ if not (flt(d.outstanding_amount) >= flt(filters.get("outstanding_amt_greater_than"))
+ and flt(d.outstanding_amount) <= flt(filters.get("outstanding_amt_less_than"))):
continue
d["voucher_type"] = voucher_type
@@ -761,9 +761,23 @@
@frappe.whitelist()
def get_account_details(account, date, cost_center=None):
frappe.has_permission('Payment Entry', throw=True)
+
+ # to check if the passed account is accessible under reference doctype Payment Entry
+ account_list = frappe.get_list('Account', {
+ 'name': account
+ }, reference_doctype='Payment Entry', limit=1)
+
+ # There might be some user permissions which will allow account under certain doctypes
+ # except for Payment Entry, only in such case we should throw permission error
+ if not account_list:
+ frappe.throw(_('Account: {0} is not permitted under Payment Entry').format(account))
+
+ account_balance = get_balance_on(account, date, cost_center=cost_center,
+ ignore_account_permission=True)
+
return frappe._dict({
"account_currency": get_account_currency(account),
- "account_balance": get_balance_on(account, date, cost_center=cost_center),
+ "account_balance": account_balance,
"account_type": frappe.db.get_value("Account", account, "account_type")
})
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index e1ed642..ac69fd3 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -84,7 +84,8 @@
throw(_("{0} '{1}' not in Fiscal Year {2}").format(label, formatdate(date), fiscal_year))
@frappe.whitelist()
-def get_balance_on(account=None, date=None, party_type=None, party=None, company=None, in_account_currency=True, cost_center=None):
+def get_balance_on(account=None, date=None, party_type=None, party=None, company=None,
+ in_account_currency=True, cost_center=None, ignore_account_permission=False):
if not account and frappe.form_dict.get("account"):
account = frappe.form_dict.get("account")
if not date and frappe.form_dict.get("date"):
@@ -140,7 +141,8 @@
if account:
- if not frappe.flags.ignore_account_permission:
+ if not (frappe.flags.ignore_account_permission
+ or ignore_account_permission):
acc.check_permission("read")
if report_type == 'Profit and Loss':
diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.js b/erpnext/hr/doctype/payroll_entry/payroll_entry.js
index e4ab680..adc0671 100644
--- a/erpnext/hr/doctype/payroll_entry/payroll_entry.js
+++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.js
@@ -69,7 +69,7 @@
},
add_context_buttons: function(frm) {
- if(frm.doc.salary_slips_submitted) {
+ if(frm.doc.salary_slips_submitted || (frm.doc.__onload && frm.doc.__onload.submitted_ss)) {
frm.events.add_bank_entry_button(frm);
} else if(frm.doc.salary_slips_created) {
frm.add_custom_button(__("Submit Salary Slip"), function() {
diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.py b/erpnext/hr/doctype/payroll_entry/payroll_entry.py
index 8803a9a..9b988e0 100644
--- a/erpnext/hr/doctype/payroll_entry/payroll_entry.py
+++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.py
@@ -18,9 +18,8 @@
# check if salary slips were manually submitted
entries = frappe.db.count("Salary Slip", {'payroll_entry': self.name, 'docstatus': 1}, ['name'])
- if cint(entries) == len(self.employees) and not self.salary_slips_submitted:
- self.db_set("salary_slips_submitted", 1)
- self.reload()
+ if cint(entries) == len(self.employees):
+ self.set_onload("submitted_ss", True)
def on_submit(self):
self.create_salary_slips()
@@ -429,7 +428,6 @@
'start_date': start_date, 'end_date': end_date
})
-
def get_frequency_kwargs(frequency_name):
frequency_dict = {
'monthly': {'months': 1},
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ac9b01f..7b82809 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -596,6 +596,7 @@
erpnext.patches.v12_0.move_target_distribution_from_parent_to_child
erpnext.patches.v12_0.stock_entry_enhancements
erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 #25-06-2019
+erpnext.patches.v12_0.make_item_manufacturer
erpnext.patches.v12_0.move_item_tax_to_item_tax_template
erpnext.patches.v11_1.set_variant_based_on
erpnext.patches.v11_1.woocommerce_set_creation_user
@@ -606,7 +607,6 @@
erpnext.patches.v12_0.rename_tolerance_fields
erpnext.patches.v12_0.make_custom_fields_for_bank_remittance #14-06-2019
execute:frappe.delete_doc_if_exists("Page", "support-analytics")
-erpnext.patches.v12_0.make_item_manufacturer
erpnext.patches.v12_0.remove_patient_medical_record_page
erpnext.patches.v11_1.move_customer_lead_to_dynamic_column
erpnext.patches.v11_1.set_default_action_for_quality_inspection
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index da29d20..4b34dc1 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -252,7 +252,7 @@
def set_mode_of_payment_account(self):
cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name')
if cash and self.default_cash_account \
- and not frappe.db.get_value('Mode of Payment Account', {'company': self.name, 'parent': 'Cash'}):
+ and not frappe.db.get_value('Mode of Payment Account', {'company': self.name, 'parent': cash}):
mode_of_payment = frappe.get_doc('Mode of Payment', cash)
mode_of_payment.append('accounts', {
'company': self.name,
diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.js b/erpnext/stock/doctype/quality_inspection/quality_inspection.js
index aa9854a..22f29e0 100644
--- a/erpnext/stock/doctype/quality_inspection/quality_inspection.js
+++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.js
@@ -39,11 +39,12 @@
query: "erpnext.stock.doctype.quality_inspection.quality_inspection.item_query",
filters: {
"from": doctype,
- "parent": doc.reference_name
+ "parent": doc.reference_name,
+ "inspection_type": doc.inspection_type
}
- }
+ };
}
-}
+},
// Serial No based on item_code
cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) {
diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.py b/erpnext/stock/doctype/quality_inspection/quality_inspection.py
index e0b7382..4e42e70 100644
--- a/erpnext/stock/doctype/quality_inspection/quality_inspection.py
+++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+from frappe import _
from frappe.model.document import Document
from erpnext.stock.doctype.quality_inspection_template.quality_inspection_template \
import get_template_details
@@ -11,6 +12,7 @@
def validate(self):
if not self.readings and self.item_code:
self.get_item_specification_details()
+ self.validate_inspection_type()
def get_item_specification_details(self):
if not self.quality_inspection_template:
@@ -27,6 +29,14 @@
child.value = d.value
child.status = "Accepted"
+ def validate_inspection_type(self):
+ if self.inspection_type != "In Process":
+ inspection_required = frappe.db.get_value("Item", filters={
+ 'name': self.item_code
+ }, fieldname=['inspection_required_before_purchase', 'inspection_required_before_delivery'])
+ if 0 in inspection_required:
+ frappe.throw(_('Inspection type for the item can only be in process.'))
+
def get_quality_inspection_template(self):
template = ''
if self.bom_no:
@@ -63,10 +73,12 @@
mcond = get_match_cond(filters["from"])
cond, qi_condition = "", "and (quality_inspection is null or quality_inspection = '')"
- if filters.get('from') in ['Purchase Invoice Item', 'Purchase Receipt Item']:
+ if filters.get('from') in ['Purchase Invoice Item', 'Purchase Receipt Item']\
+ and filters.get("inspection_type") != "In Process":
cond = """and item_code in (select name from `tabItem` where
inspection_required_before_purchase = 1)"""
- elif filters.get('from') in ['Sales Invoice Item', 'Delivery Note Item']:
+ elif filters.get('from') in ['Sales Invoice Item', 'Delivery Note Item']\
+ and filters.get("inspection_type") != "In Process":
cond = """and item_code in (select name from `tabItem` where
inspection_required_before_delivery = 1)"""
elif filters.get('from') == 'Stock Entry Detail':