Merge pull request #6488 from rohitwaghchaure/timesheet_delete_transaction_issue
[Fix] Timesheet detail records not deleted with company transactions deletion
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index ced1e85..cedaf60 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -171,7 +171,7 @@
old_warehouse = cstr(frappe.db.get_value("Account", self.name, "warehouse"))
if old_warehouse != cstr(self.warehouse):
- if old_warehouse:
+ if old_warehouse and frappe.db.exists("Warehouse", old_warehouse):
self.validate_warehouse(old_warehouse)
if self.warehouse:
self.validate_warehouse(self.warehouse)
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 685b8a7..db811cf 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -218,14 +218,16 @@
conditions, values = self.prepare_conditions(party_type)
if self.filters.get(scrub(party_type)):
- select_fields = "debit_in_account_currency as debit, credit_in_account_currency as credit"
+ select_fields = "sum(debit_in_account_currency) as debit, sum(credit_in_account_currency) as credit"
else:
- select_fields = "debit, credit"
+ select_fields = "sum(debit) as debit, sum(credit) as credit"
- self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party,
- voucher_type, voucher_no, against_voucher_type, against_voucher, account_currency, remarks, {0}
+ self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party,
+ voucher_type, voucher_no, against_voucher_type, against_voucher,
+ account_currency, remarks, {0}
from `tabGL Entry`
where docstatus < 2 and party_type=%s and (party is not null and party != '') {1}
+ group by voucher_type, voucher_no, against_voucher_type, against_voucher
order by posting_date, party"""
.format(select_fields, conditions), values, as_dict=True)
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py
index 3407526..35d501a 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/cash_flow.py
@@ -59,7 +59,6 @@
company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
for cash_flow_account in cash_flow_accounts:
-
section_data = []
data.append({
"account_name": cash_flow_account['section_header'],
@@ -82,7 +81,8 @@
account_data = get_account_type_based_data(filters.company,
account['account_type'], period_list, filters.accumulated_values)
account_data.update({
- "account_name": account['label'],
+ "account_name": account['label'],
+ "account": account['label'],
"indent": 1,
"parent_account": cash_flow_account['section_header'],
"currency": company_currency
@@ -129,7 +129,7 @@
def add_total_row_account(out, data, label, period_list, currency):
total_row = {
"account_name": "'" + _("{0}").format(label) + "'",
- "account": None,
+ "account": "'" + _("{0}").format(label) + "'",
"currency": currency
}
for row in data:
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
index 62d6e69..f9e43db 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
@@ -34,7 +34,7 @@
total = 0
net_profit_loss = {
"account_name": "'" + _("Net Profit / Loss") + "'",
- "account": None,
+ "account": "'" + _("Net Profit / Loss") + "'",
"warn_if_negative": True,
"currency": frappe.db.get_value("Company", company, "default_currency")
}
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 838d8f7..42edc9f 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -97,12 +97,19 @@
.format(formatdate(future_allocation[0].from_date), future_allocation[0].name))
def validate_salary_processed_days(self):
- last_processed_pay_slip = frappe.db.sql("""select start_date, end_date from `tabSalary Slip`
- where docstatus != 2 and employee = %s and ((%s between start_date and end_date) or (%s between start_date and end_date)) order by modified desc limit 1""",(self.employee, self.to_date, self.from_date))
+ if not frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
+ return
+
+ last_processed_pay_slip = frappe.db.sql("""
+ select start_date, end_date from `tabSalary Slip`
+ where docstatus != 2 and employee = %s
+ and ((%s between start_date and end_date) or (%s between start_date and end_date))
+ order by modified desc limit 1
+ """,(self.employee, self.to_date, self.from_date))
if last_processed_pay_slip:
- frappe.throw(_("Salary already processed for period between {0} and {1}, Leave application period cannot be between this date range.").
- format(formatdate(last_processed_pay_slip[0][0]), formatdate(last_processed_pay_slip[0][1])))
+ frappe.throw(_("Salary already processed for period between {0} and {1}, Leave application period cannot be between this date range.").format(formatdate(last_processed_pay_slip[0][0]),
+ formatdate(last_processed_pay_slip[0][1])))
def show_block_day_warning(self):
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index f06e385..9822fc0 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -308,6 +308,7 @@
erpnext.patches.v7_0.set_material_request_type_in_item
erpnext.patches.v7_0.rename_examination_to_assessment
erpnext.patches.v7_0.set_portal_settings
+erpnext.patches.v7_0.update_change_amount_account
erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice
erpnext.patches.v7_0.fix_duplicate_icons
erpnext.patches.v7_0.repost_gle_for_pos_sales_return
diff --git a/erpnext/patches/v7_0/update_change_amount_account.py b/erpnext/patches/v7_0/update_change_amount_account.py
new file mode 100644
index 0000000..1741095
--- /dev/null
+++ b/erpnext/patches/v7_0/update_change_amount_account.py
@@ -0,0 +1,19 @@
+from __future__ import unicode_literals
+import frappe
+from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
+
+def execute():
+ frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
+
+ for company in frappe.db.sql("""select company from `tabSales Invoice`
+ where change_amount <> 0 and account_for_change_amount is null group by company""", as_list = 1):
+ cash_account = get_default_bank_cash_account(company[0], 'Cash').get('account')
+ if not cash_account:
+ bank_account = get_default_bank_cash_account(company[0], 'Bank').get('account')
+ cash_account = bank_account
+
+ if cash_account:
+ frappe.db.sql("""update `tabSales Invoice`
+ set account_for_change_amount = %(cash_account)s where change_amount <> 0
+ and company = %(company)s and account_for_change_amount is null""",
+ {'cash_account': cash_account, 'company': company[0]})
diff --git a/erpnext/portal/doctype/homepage/homepage.js b/erpnext/portal/doctype/homepage/homepage.js
index 100074f..0b07814 100644
--- a/erpnext/portal/doctype/homepage/homepage.js
+++ b/erpnext/portal/doctype/homepage/homepage.js
@@ -2,6 +2,14 @@
// For license information, please see license.txt
frappe.ui.form.on('Homepage', {
+ setup: function(frm) {
+ frm.fields_dict["products"].grid.get_field("item_code").get_query = function(){
+ return {
+ filters: {'show_in_website': 1}
+ }
+ }
+ },
+
refresh: function(frm) {
},
@@ -35,5 +43,12 @@
}
});
}
+ },
+
+ view: function(frm, cdt, cdn){
+ var child= locals[cdt][cdn]
+ if(child.item_code && frm.doc.products_url){
+ window.location.href = frm.doc.products_url + '/' + encodeURIComponent(child.item_code);
+ }
}
});
diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py
index 22fa12a..096f6c0 100644
--- a/erpnext/stock/stock_balance.py
+++ b/erpnext/stock/stock_balance.py
@@ -230,7 +230,7 @@
pass
def repost_all_stock_vouchers():
- warehouses_with_account = frappe.db.sql_list("""select master_name from tabAccount
+ warehouses_with_account = frappe.db.sql_list("""select warehouse from tabAccount
where ifnull(account_type, '') = 'Stock' and (warehouse is not null and warehouse != '')
and is_group=0""")
@@ -244,7 +244,7 @@
i = 0
for voucher_type, voucher_no in vouchers:
i+=1
- print i, "/", len(vouchers)
+ print i, "/", len(vouchers), voucher_type, voucher_no
try:
for dt in ["Stock Ledger Entry", "GL Entry"]:
frappe.db.sql("""delete from `tab%s` where voucher_type=%s and voucher_no=%s"""%