From 0a6529a643c66fb48659b8f3ec9c7d374581cf38 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 28 Sep 2016 12:55:02 +0530 Subject: [PATCH 01/10] Remove time log, time log batch from Doc Field. --- erpnext/patches.txt | 2 +- .../patches/v7_0/remove_doctypes_and_reports.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 07bf0f0027..be0013e3ff 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -282,7 +282,7 @@ execute:frappe.reload_doc('projects', 'doctype', 'project_user') erpnext.patches.v7_0.convert_timelogbatch_to_timesheet erpnext.patches.v7_0.convert_timelog_to_timesheet erpnext.patches.v7_0.move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet -erpnext.patches.v7_0.remove_doctypes_and_reports +erpnext.patches.v7_0.remove_doctypes_and_reports #2016-10-29 erpnext.patches.v7_0.update_maintenance_module_in_doctype erpnext.patches.v7_0.update_prevdoc_values_for_supplier_quotation_item erpnext.patches.v7_0.rename_advance_table_fields diff --git a/erpnext/patches/v7_0/remove_doctypes_and_reports.py b/erpnext/patches/v7_0/remove_doctypes_and_reports.py index 0a302b1441..3c45be4377 100644 --- a/erpnext/patches/v7_0/remove_doctypes_and_reports.py +++ b/erpnext/patches/v7_0/remove_doctypes_and_reports.py @@ -5,6 +5,21 @@ def execute(): frappe.db.sql("""delete from `tabDocType` where name in('Time Log Batch', 'Time Log Batch Detail', 'Time Log')""") + frappe.db.sql("""delete from `tabDocField` where parent in ('Time Log', 'Time Log Batch')""") + frappe.db.sql("""update `tabCustom Script` set dt = 'Timesheet' where dt = 'Time Log'""") + + for data in frappe.db.sql(""" select label, fieldname from `tabCustom Field` where dt = 'Time Log'""", as_dict=1): + custom_field = frappe.get_doc({ + 'doctype': 'Custom Field', + 'label': data.label, + 'dt': 'Timesheet Detail', + 'fieldname': data.fieldname + }).insert(ignore_permissions=True) + + frappe.db.sql("""delete from `tabCustom Field` where dt = 'Time Log'""") + frappe.reload_doc('projects', 'doctype', 'timesheet') + frappe.reload_doc('projects', 'doctype', 'timesheet_detail') + report = "Daily Time Log Summary" if frappe.db.exists("Report", report): frappe.delete_doc('Report', report) \ No newline at end of file From d63bfaa5f21a7aaf7b16aaa1ec3c08f9b1478615 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 28 Sep 2016 14:08:47 +0530 Subject: [PATCH 02/10] Fixed view button functionality in homepage --- erpnext/portal/doctype/homepage/homepage.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/portal/doctype/homepage/homepage.js b/erpnext/portal/doctype/homepage/homepage.js index 100074f07d..0b07814f75 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 @@ frappe.ui.form.on('Homepage Featured Product', { } }); } + }, + + 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); + } } }); From 7441a93a10efa4b13b0878dbe3753235a4597118 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 28 Sep 2016 14:57:57 +0530 Subject: [PATCH 03/10] [Fix] sub-heading is missing in the excel sheet of the cash flow --- erpnext/accounts/report/cash_flow/cash_flow.py | 6 +++--- .../profit_and_loss_statement/profit_and_loss_statement.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py index 3407526516..35d501aef9 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.py +++ b/erpnext/accounts/report/cash_flow/cash_flow.py @@ -59,7 +59,6 @@ def execute(filters=None): 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 @@ def execute(filters=None): 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 get_account_type_based_data(company, account_type, period_list, accumulated_ 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 62d6e69623..f9e43dbf0c 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 @@ def get_net_profit_loss(income, expense, period_list, company): 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") } From b3bc41131e9cac842d1f28936a0f962d1249d630 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 28 Sep 2016 18:17:52 +0530 Subject: [PATCH 04/10] Reposting of GLE and SLE for all stock transactions --- erpnext/accounts/doctype/account/account.py | 2 +- erpnext/stock/stock_balance.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index ced1e8516d..cedaf60f9f 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -171,7 +171,7 @@ class Account(Document): 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/stock/stock_balance.py b/erpnext/stock/stock_balance.py index 22fa12a09b..096f6c07b6 100644 --- a/erpnext/stock/stock_balance.py +++ b/erpnext/stock/stock_balance.py @@ -230,7 +230,7 @@ def reset_serial_no_status_and_warehouse(serial_nos=None): 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 @@ def repost_all_stock_vouchers(): 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"""% From f21f1af0c9a0b73acb7218c41f616cc73df87ace Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 28 Sep 2016 17:24:02 +0530 Subject: [PATCH 05/10] [Enhancement] Added allocate payment amount checkbox in Payment Entry --- .../doctype/payment_entry/payment_entry.js | 38 +++++++++++++------ .../doctype/payment_entry/payment_entry.json | 30 ++++++++++++++- .../doctype/payment_entry/payment_entry.py | 1 + 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 695a721553..6ce8bf0587 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -511,6 +511,18 @@ frappe.ui.form.on('Payment Entry', { }); }, + allocate_payment_amount: function(frm) { + if(frm.doc.payment_type == 'Internal Transfer'){ + return + } + + if(frm.doc.references.length == 0){ + frm.events.get_outstanding_documents(frm); + } + + frm.events.allocate_party_amount_against_ref_docs(frm, frm.doc.received_amount); + }, + allocate_party_amount_against_ref_docs: function(frm, paid_amount) { var total_positive_outstanding_including_order = 0; var total_negative_outstanding = 0; @@ -552,22 +564,24 @@ frappe.ui.form.on('Payment Entry', { } $.each(frm.doc.references || [], function(i, row) { - row.allocated_amount = 0 + row.allocated_amount = 0 //If allocate payment amount checkbox is unchecked, set zero to allocate amount + if(frm.doc.allocate_payment_amount){ + if(row.outstanding_amount > 0 && allocated_positive_outstanding > 0) { + if(row.outstanding_amount >= allocated_positive_outstanding) + row.allocated_amount = allocated_positive_outstanding; + else row.allocated_amount = row.outstanding_amount; - if(row.outstanding_amount > 0 && allocated_positive_outstanding > 0) { - if(row.outstanding_amount >= allocated_positive_outstanding) - row.allocated_amount = allocated_positive_outstanding; - else row.allocated_amount = row.outstanding_amount; + allocated_positive_outstanding -= flt(row.allocated_amount); + } else if (row.outstanding_amount < 0 && allocated_negative_outstanding) { + if(Math.abs(row.outstanding_amount) >= allocated_negative_outstanding) + row.allocated_amount = -1*allocated_negative_outstanding; + else row.allocated_amount = row.outstanding_amount; - allocated_positive_outstanding -= flt(row.allocated_amount); - } else if (row.outstanding_amount < 0 && allocated_negative_outstanding) { - if(Math.abs(row.outstanding_amount) >= allocated_negative_outstanding) - row.allocated_amount = -1*allocated_negative_outstanding; - else row.allocated_amount = row.outstanding_amount; - - allocated_negative_outstanding -= Math.abs(flt(row.allocated_amount)); + allocated_negative_outstanding -= Math.abs(flt(row.allocated_amount)); + } } }) + frm.refresh_fields() frm.events.set_total_allocated_amount(frm); }, diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json index 2057d07d83..6018571696 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.json +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json @@ -772,6 +772,34 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "1", + "depends_on": "eval:in_list(['Pay', 'Receive'], doc.payment_type)", + "fieldname": "allocate_payment_amount", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Allocate Payment Amount", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -1426,7 +1454,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-09-05 11:06:18.183458", + "modified": "2016-09-28 18:20:47.625383", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Entry", diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 179a321d19..7b9bf16bff 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -669,6 +669,7 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount= pe.paid_to_account_currency = party_account_currency if payment_type=="Pay" else bank.account_currency pe.paid_amount = paid_amount pe.received_amount = received_amount + pe.allocate_payment_amount = 1 pe.append("references", { "reference_doctype": dt, From 17adb970f1c11568808ac76bf6fdcc7dfd33e3cf Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 29 Sep 2016 01:07:28 +0530 Subject: [PATCH 06/10] [Fix] Timesheet detail records not deleted with company transactions deletion --- erpnext/patches.txt | 1 + .../setup/doctype/company/delete_company_transactions.py | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index be0013e3ff..f06e385276 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -315,4 +315,5 @@ erpnext.patches.v7_0.update_missing_employee_in_timesheet erpnext.patches.v7_0.update_status_for_timesheet erpnext.patches.v7_0.set_party_name_in_payment_entry execute:frappe.db.sql("update `tabTimesheet` ts, `tabEmployee` emp set ts.employee_name = emp.employee_name where emp.name = ts.employee and ts.employee_name is null and ts.employee is not null") +execute:frappe.db.sql("delete from `tabTimesheet Detail` where NOT EXISTS (select name from `tabTimesheet` where name = `tabTimesheet Detail`.parent)") erpnext.patches.v7_0.update_mode_of_payment_type diff --git a/erpnext/setup/doctype/company/delete_company_transactions.py b/erpnext/setup/doctype/company/delete_company_transactions.py index 7e1681c38e..8f058e86ed 100644 --- a/erpnext/setup/doctype/company/delete_company_transactions.py +++ b/erpnext/setup/doctype/company/delete_company_transactions.py @@ -18,7 +18,6 @@ def delete_company_transactions(company_name): frappe.PermissionError) delete_bins(company_name) - delete_time_sheets(company_name) delete_lead_addresses(company_name) for doctype in frappe.db.sql_list("""select parent from @@ -70,14 +69,6 @@ def delete_bins(company_name): frappe.db.sql("""delete from tabBin where warehouse in (select name from tabWarehouse where company=%s)""", company_name) -def delete_time_sheets(company_name): - # Delete Time Logs as it is linked to Production Order / Project / Task, which are linked to company - frappe.db.sql(""" - delete from `tabTimesheet` - where - company=%(company)s - """, {"company": company_name}) - def delete_lead_addresses(company_name): """Delete addresses to which leads are linked""" for lead in frappe.get_all("Lead", filters={"company": company_name}): From 2e31d7c7bf23f4b6248f1ed434c58499cf7ceccc Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 29 Sep 2016 10:59:46 +0530 Subject: [PATCH 07/10] [fix] Validate leave application period with salary slip only if leave type is LWP --- .../leave_application/leave_application.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 838d8f7513..42edc9ff13 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -97,12 +97,19 @@ class LeaveApplication(Document): .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): From 4b24683c271c4db2a790f842ea358944311fde3d Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 29 Sep 2016 12:54:24 +0530 Subject: [PATCH 08/10] [Fix] added account for missing change amount account in the sales invoice --- erpnext/patches.txt | 1 + .../v7_0/update_change_amount_account.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 erpnext/patches/v7_0/update_change_amount_account.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index be0013e3ff..253b3194e8 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -308,6 +308,7 @@ erpnext.patches.v7_0.update_refdoc_in_landed_cost_voucher 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 0000000000..1741095ea9 --- /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]}) From f1d2fd2436b54833c64689c6a10802f82f914adb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 29 Sep 2016 13:03:10 +0530 Subject: [PATCH 09/10] [fix] Accounts Receivable report if negative write off in invoice --- .../report/accounts_receivable/accounts_receivable.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 685b8a77dd..db811cfe48 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -218,14 +218,16 @@ class ReceivablePayableReport(object): 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) From 626fcd5199d0d133631e88b740c4573e13910b41 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 29 Sep 2016 14:46:42 +0600 Subject: [PATCH 10/10] bumped to version 7.0.51 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index b449e2a4b2..bec17c1f0b 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import frappe -__version__ = '7.0.50' +__version__ = '7.0.51' def get_default_company(user=None): '''Get default company for user'''