diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 99981bd713e..a4647e3b0ac 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '10.1.6' +__version__ = '10.1.7' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json index 029421990bd..3ab73b717d1 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json @@ -159,6 +159,36 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "include_pos_transactions", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Include POS Transactions", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -292,7 +322,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-04-21 16:58:26.902732", + "modified": "2018-03-07 18:58:48.658687", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Reconciliation", diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index e8b60ac09a2..7814b0883da 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -53,10 +53,26 @@ class BankReconciliation(Document): posting_date ASC, name DESC """.format(condition), {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1) - - entries = sorted(list(payment_entries)+list(journal_entries), + + pos_entries = [] + if self.include_pos_transactions: + pos_entries = frappe.db.sql(""" + select + "Sales Invoice Payment" as payment_document, sip.name as payment_entry, sip.amount as debit, + si.posting_date, si.debit_to as against_account, sip.clearance_date, + account.account_currency, 0 as credit + from `tabSales Invoice Payment` sip, `tabSales Invoice` si, `tabAccount` account + where + sip.account=%(account)s and si.docstatus=1 and sip.parent = si.name + and account.name = sip.account and si.posting_date >= %(from)s and si.posting_date <= %(to)s {0} + order by + si.posting_date ASC, si.name DESC + """.format(condition), + {"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1) + + entries = sorted(list(payment_entries)+list(journal_entries+list(pos_entries)), key=lambda k: k['posting_date'] or getdate(nowdate())) - + self.set('payment_entries', []) self.total_amount = 0.0 diff --git a/erpnext/accounts/doctype/bank_reconciliation/test_bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/test_bank_reconciliation.py new file mode 100644 index 00000000000..932fb3384cf --- /dev/null +++ b/erpnext/accounts/doctype/bank_reconciliation/test_bank_reconciliation.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals +import unittest + +class TestBankReconciliation(unittest.TestCase): + pass diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 8800a0a7e48..7bdb6fbd12a 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -685,6 +685,24 @@ def get_company_defaults(company): return ret +def get_outstanding_on_journal_entry(name): + res = frappe.db.sql( + 'SELECT ' + 'CASE WHEN party_type IN ("Customer", "Student") ' + 'THEN ifnull(sum(debit_in_account_currency - credit_in_account_currency), 0) ' + 'ELSE ifnull(sum(credit_in_account_currency - debit_in_account_currency), 0) ' + 'END as outstanding_amount ' + 'FROM `tabGL Entry` WHERE (voucher_no=%s OR against_voucher=%s) ' + 'AND party_type IS NOT NULL ' + 'AND party_type != ""', + (name, name), as_dict=1 + ) + + outstanding_amount = res[0].get('outstanding_amount', 0) if res else 0 + + return outstanding_amount + + @frappe.whitelist() def get_reference_details(reference_doctype, reference_name, party_account_currency): total_amount = outstanding_amount = exchange_rate = None @@ -695,6 +713,13 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre total_amount = ref_doc.get("grand_total") exchange_rate = 1 outstanding_amount = ref_doc.get("outstanding_amount") + elif reference_doctype == "Journal Entry" and ref_doc.docstatus == 1: + total_amount = ref_doc.get("total_amount") + if ref_doc.multi_currency: + exchange_rate = get_exchange_rate(party_account_currency, company_currency, ref_doc.posting_date) + else: + exchange_rate = 1 + outstanding_amount = get_outstanding_on_journal_entry(reference_name) elif reference_doctype != "Journal Entry": if party_account_currency == company_currency: if ref_doc.doctype == "Expense Claim": diff --git a/erpnext/accounts/doctype/payment_schedule/payment_schedule.json b/erpnext/accounts/doctype/payment_schedule/payment_schedule.json index 2fcd44f6973..3ae7d62c17f 100644 --- a/erpnext/accounts/doctype/payment_schedule/payment_schedule.json +++ b/erpnext/accounts/doctype/payment_schedule/payment_schedule.json @@ -42,6 +42,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -73,6 +74,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -104,6 +106,7 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -135,6 +138,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -166,6 +170,39 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "mode_of_payment", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Mode of Payment", + "length": 0, + "no_copy": 0, + "options": "Mode of Payment", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 } ], @@ -179,8 +216,8 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-12-19 16:20:33.546984", - "modified_by": "nabinhait@gmail.com", + "modified": "2018-03-08 11:26:18.266987", + "modified_by": "Administrator", "module": "Accounts", "name": "Payment Schedule", "name_case": "", diff --git a/erpnext/accounts/doctype/payment_term/payment_term.json b/erpnext/accounts/doctype/payment_term/payment_term.json index 10cfcf2a325..723d3bd72cd 100644 --- a/erpnext/accounts/doctype/payment_term/payment_term.json +++ b/erpnext/accounts/doctype/payment_term/payment_term.json @@ -41,6 +41,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -71,6 +72,39 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "mode_of_payment", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Mode of Payment", + "length": 0, + "no_copy": 0, + "options": "Mode of Payment", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -100,6 +134,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -131,6 +166,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -162,6 +198,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -193,6 +230,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -222,6 +260,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -252,6 +291,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 } ], @@ -265,7 +305,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-01-24 11:13:42.800048", + "modified": "2018-03-08 10:47:32.830478", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Term", diff --git a/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.json b/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.json index f808a0f8637..ee2cfc00aab 100644 --- a/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.json +++ b/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.json @@ -42,6 +42,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -73,6 +74,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -105,6 +107,7 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -136,6 +139,7 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -169,6 +173,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -201,6 +206,39 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "mode_of_payment", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Mode of Payment", + "length": 0, + "no_copy": 0, + "options": "Mode of Payment", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 } ], @@ -214,7 +252,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-09-26 05:21:51.738319", + "modified": "2018-03-08 11:07:09.014151", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Terms Template Detail", diff --git a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json index 531622d6ac5..b9e5c8d517e 100644 --- a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json +++ b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json @@ -227,6 +227,36 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "clearance_date", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Clearance Date", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "has_web_view": 0, @@ -239,7 +269,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-07-24 17:25:03.765856", + "modified": "2018-03-07 18:34:39.552769", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Payment", diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index ccb5553bf5d..e5bcba498d1 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -394,7 +394,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.frm = {} this.frm.doc = this.doc this.set_transaction_defaults("Customer"); - this.frm.doc["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false, + this.frm.doc["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false; + this.frm.doc["allow_user_to_edit_discount"] = this.pos_profile_data["allow_user_to_edit_discount"] ? true : false; this.wrapper.html(frappe.render_template("pos", this.frm.doc)); this.make_search(); this.make_customer(); @@ -1257,6 +1258,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ $(this.wrapper).find('.selected-item').empty(); if(this.child_doc.length) { this.child_doc[0]["allow_user_to_edit_rate"] = this.pos_profile_data["allow_user_to_edit_rate"] ? true : false, + this.child_doc[0]["allow_user_to_edit_discount"] = this.pos_profile_data["allow_user_to_edit_discount"] ? true : false; this.selected_row = $(frappe.render_template("pos_selected_item", this.child_doc[0])) $(this.wrapper).find('.selected-item').html(this.selected_row) } @@ -1692,7 +1694,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ setInterval(function () { me.freeze_screen = false; me.sync_sales_invoice() - }, 60000) + }, 180000) }, sync_sales_invoice: function () { diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js index 0f9fdd7c023..57fe4b05be4 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js @@ -28,5 +28,10 @@ frappe.query_reports["Bank Reconciliation Statement"] = { "default": frappe.datetime.get_today(), "reqd": 1 }, + { + "fieldname":"include_pos_transactions", + "label": __("Include POS Transactions"), + "fieldtype": "Check" + }, ] -} +} \ No newline at end of file diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py index 95b7ff7545f..eca59750d5b 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py @@ -138,7 +138,23 @@ def get_entries(filters): and ifnull(clearance_date, '4000-01-01') > %(report_date)s """, filters, as_dict=1) - return sorted(list(payment_entries)+list(journal_entries), + pos_entries = [] + if filters.include_pos_transactions: + pos_entries = frappe.db.sql(""" + select + "Sales Invoice Payment" as payment_document, sip.name as payment_entry, sip.amount as debit, + si.posting_date, si.debit_to as against_account, sip.clearance_date, + account.account_currency, 0 as credit + from `tabSales Invoice Payment` sip, `tabSales Invoice` si, `tabAccount` account + where + sip.account=%(account)s and si.docstatus=1 and sip.parent = si.name + and account.name = sip.account and si.posting_date <= %(report_date)s and + ifnull(sip.clearance_date, '4000-01-01') > %(report_date)s + order by + si.posting_date ASC, si.name DESC + """, filters, as_dict=1) + + return sorted(list(payment_entries)+list(journal_entries+list(pos_entries)), key=lambda k: k['posting_date'] or getdate(nowdate())) def get_amounts_not_reflected_in_system(filters): diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py index 610475acfcb..73bb4dc22d8 100644 --- a/erpnext/accounts/report/purchase_register/purchase_register.py +++ b/erpnext/accounts/report/purchase_register/purchase_register.py @@ -179,7 +179,7 @@ def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts): invoice_tax_map = {} for d in tax_details: if d.account_head in expense_accounts: - if invoice_expense_map[d.parent].has_key(d.account_head): + if d.account_head in invoice_expense_map[d.parent]: invoice_expense_map[d.parent][d.account_head] += flt(d.tax_amount) else: invoice_expense_map[d.parent][d.account_head] = flt(d.tax_amount) diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py index ace8d549167..4debbd6cb8e 100644 --- a/erpnext/accounts/report/sales_register/sales_register.py +++ b/erpnext/accounts/report/sales_register/sales_register.py @@ -189,7 +189,7 @@ def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts): invoice_tax_map = {} for d in tax_details: if d.account_head in income_accounts: - if invoice_income_map[d.parent].has_key(d.account_head): + if d.account_head in invoice_income_map[d.parent]: invoice_income_map[d.parent][d.account_head] += flt(d.tax_amount) else: invoice_income_map[d.parent][d.account_head] = flt(d.tax_amount) diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 7142c699555..8c55df5c4aa 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -175,7 +175,7 @@ def accumulate_values_into_parents(accounts, accounts_by_name): def prepare_data(accounts, filters, total_row, parent_children_map, company_currency): data = [] - tmpaccnt = sorted(accounts) + tmpaccnt = sorted(accounts, key = lambda account: account.name) if not (accounts[0].account_number is None): accounts = tmpaccnt diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index c715fbd2a62..6aa3b019d59 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe import frappe.defaults from frappe import msgprint, _ -from frappe.model.naming import make_autoname +from frappe.model.naming import set_name_by_naming_series from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address from erpnext.utilities.transaction_base import TransactionBase from erpnext.accounts.party import validate_party_accounts, get_dashboard_info, get_timeline_data # keep this @@ -28,7 +28,7 @@ class Supplier(TransactionBase): if supp_master_name == 'Supplier Name': self.name = self.supplier_name else: - self.name = make_autoname(self.naming_series + '.#####') + set_name_by_naming_series(self) def on_update(self): if not self.naming_series: diff --git a/erpnext/config/crm.py b/erpnext/config/crm.py index e51275c260f..dd67005ecf6 100644 --- a/erpnext/config/crm.py +++ b/erpnext/config/crm.py @@ -126,6 +126,11 @@ def get_data(): "link": "Tree/Sales Person", "description": _("Manage Sales Person Tree."), }, + { + "type": "doctype", + "name": "Lead Source", + "description": _("Track Leads by Lead Source.") + }, ] }, { diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py index fef902e32d1..b48cafc99ab 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -173,6 +173,11 @@ def get_data(): "name": "Industry Type", "description": _("Track Leads by Industry Type.") }, + { + "type": "doctype", + "name": "Lead Source", + "description": _("Track Leads by Lead Source.") + }, ] }, { diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index c6d911a26ff..3884bef1a46 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -947,6 +947,7 @@ def get_payment_term_details(term, posting_date=None, grand_total=None, bill_dat if getdate(term_details.due_date) < getdate(posting_date): term_details.due_date = posting_date + term_details.mode_of_payment = term.mode_of_payment return term_details diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py index e8260d9e3d0..7749ac5f054 100644 --- a/erpnext/controllers/item_variant.py +++ b/erpnext/controllers/item_variant.py @@ -94,7 +94,10 @@ def validate_is_incremental(numeric_attribute, attribute, value, item): InvalidItemAttributeValueError, title=_('Invalid Attribute')) def validate_item_attribute_value(attributes_list, attribute, attribute_value, item): - if attribute_value not in attributes_list: + allow_rename_attribute_value = frappe.db.get_single_value('Item Variant Settings', 'allow_rename_attribute_value') + if allow_rename_attribute_value: + pass + elif attribute_value not in attributes_list: frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format( attribute_value, attribute, item), InvalidItemAttributeValueError, title=_('Invalid Attribute')) diff --git a/erpnext/education/doctype/instructor/instructor.py b/erpnext/education/doctype/instructor/instructor.py index 78e42613756..0756b5f01a4 100644 --- a/erpnext/education/doctype/instructor/instructor.py +++ b/erpnext/education/doctype/instructor/instructor.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.model.document import Document -from frappe.model.naming import make_autoname +from frappe.model.naming import set_name_by_naming_series class Instructor(Document): def autoname(self): @@ -15,7 +15,7 @@ class Instructor(Document): frappe.throw(_("Please setup Instructor Naming System in Education > Education Settings")) else: if naming_method == 'Naming Series': - self.name = make_autoname(self.naming_series + '.####') + set_name_by_naming_series(self) elif naming_method == 'Employee Number': if not self.employee: frappe.throw(_("Please select Employee")) diff --git a/erpnext/education/doctype/instructor/test_records.json b/erpnext/education/doctype/instructor/test_records.json index 3747c0d21b5..220d84eb960 100644 --- a/erpnext/education/doctype/instructor/test_records.json +++ b/erpnext/education/doctype/instructor/test_records.json @@ -1,12 +1,12 @@ [ { "naming_series": "_T-Instructor-", - "employee": "_T-Employee-0001", + "employee": "_T-Employee-00001", "instructor_name": "_Test Instructor" }, { "naming_series": "_T-Instructor-", - "employee": "_T-Employee-0002", + "employee": "_T-Employee-00002", "instructor_name": "_Test Instructor 2" } ] diff --git a/erpnext/education/report/final_assessment_grades/final_assessment_grades.py b/erpnext/education/report/final_assessment_grades/final_assessment_grades.py index efc9aff083e..e6e0ba2ebc2 100644 --- a/erpnext/education/report/final_assessment_grades/final_assessment_grades.py +++ b/erpnext/education/report/final_assessment_grades/final_assessment_grades.py @@ -27,26 +27,27 @@ def execute(filters=None): course_dict = values.get("course_dict") for student in args.students: - student_row = {} - student_row["student"] = student - student_row["student_name"] = student_details[student] - for course in course_dict: - scrub_course = frappe.scrub(course) - if assessment_group in assessment_result[student][course]: - student_row["grade_" + scrub_course] = assessment_result[student][course][assessment_group]["Total Score"]["grade"] - student_row["score_" + scrub_course] = assessment_result[student][course][assessment_group]["Total Score"]["score"] + if student_details.get(student): + student_row = {} + student_row["student"] = student + student_row["student_name"] = student_details[student] + for course in course_dict: + scrub_course = frappe.scrub(course) + if assessment_group in assessment_result[student][course]: + student_row["grade_" + scrub_course] = assessment_result[student][course][assessment_group]["Total Score"]["grade"] + student_row["score_" + scrub_course] = assessment_result[student][course][assessment_group]["Total Score"]["score"] - # create the list of possible grades - if student_row["grade_" + scrub_course] not in grades: - grades.append(student_row["grade_" + scrub_course]) + # create the list of possible grades + if student_row["grade_" + scrub_course] not in grades: + grades.append(student_row["grade_" + scrub_course]) - # create the dict of for gradewise analysis - if student_row["grade_" + scrub_course] not in course_wise_analysis[course]: - course_wise_analysis[course][student_row["grade_" + scrub_course]] = 1 - else: - course_wise_analysis[course][student_row["grade_" + scrub_course]] += 1 + # create the dict of for gradewise analysis + if student_row["grade_" + scrub_course] not in course_wise_analysis[course]: + course_wise_analysis[course][student_row["grade_" + scrub_course]] = 1 + else: + course_wise_analysis[course][student_row["grade_" + scrub_course]] += 1 - data.append(student_row) + data.append(student_row) course_list = [d for d in course_dict] columns = get_column(course_dict) diff --git a/erpnext/healthcare/doctype/consultation/consultation.js b/erpnext/healthcare/doctype/consultation/consultation.js index b0dbff5a554..dc4870fc633 100644 --- a/erpnext/healthcare/doctype/consultation/consultation.js +++ b/erpnext/healthcare/doctype/consultation/consultation.js @@ -15,23 +15,7 @@ frappe.ui.form.on('Consultation', { {fieldname: 'test_comment', columns: 4} ]; }, - onload: function(frm){ - if(frm.doc.patient){ - frappe.call({ - "method": "erpnext.healthcare.doctype.patient.patient.get_patient_detail", - args: { - patient: frm.doc.patient - }, - callback: function (data) { - var age = null; - if(data.message.dob){ - age = calculate_age(data.message.dob); - } - frappe.model.set_value(frm.doctype,frm.docname, "patient_age", age); - } - }); - } - }, + refresh: function(frm) { refresh_field('drug_prescription'); refresh_field('test_prescription'); diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py index b01f56ad6de..d0332d80d01 100644 --- a/erpnext/healthcare/doctype/patient/patient.py +++ b/erpnext/healthcare/doctype/patient/patient.py @@ -8,7 +8,7 @@ from frappe import _ from frappe.model.document import Document from frappe.utils import cint, cstr, getdate import dateutil -from frappe.model.naming import make_autoname +from frappe.model.naming import set_name_by_naming_series from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account,get_income_account,send_registration_sms class Patient(Document): @@ -42,10 +42,7 @@ class Patient(Document): if patient_master_name == 'Patient Name': self.name = self.get_patient_name() else: - if not self.naming_series: - frappe.throw(_("Series is mandatory"), frappe.MandatoryError) - - self.name = make_autoname(self.naming_series+'.#####') + set_name_by_naming_series(self) def get_patient_name(self): name = self.patient_name diff --git a/erpnext/healthcare/doctype/physician/physician.json b/erpnext/healthcare/doctype/physician/physician.json index e29561e91e7..300dc9707d2 100644 --- a/erpnext/healthcare/doctype/physician/physician.json +++ b/erpnext/healthcare/doctype/physician/physician.json @@ -750,7 +750,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-01-19 15:25:43.166877", + "modified": "2018-03-09 15:25:43.166877", "modified_by": "Administrator", "module": "Healthcare", "name": "Physician", diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 844763dae13..de70489a872 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -201,11 +201,11 @@ doc_events = { "Sales Invoice": { 'validate': 'erpnext.regional.india.utils.set_place_of_supply', "on_submit": "erpnext.regional.france.utils.create_transaction_log", - "on_trash": "erpnext.regional.france.utils.check_deletion_permission" + "on_trash": "erpnext.regional.check_deletion_permission" }, "Payment Entry": { "on_submit": ["erpnext.regional.france.utils.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.make_status_as_paid"], - "on_trash": "erpnext.regional.france.utils.check_deletion_permission" + "on_trash": "erpnext.regional.check_deletion_permission" }, 'Address': { 'validate': 'erpnext.regional.india.utils.validate_gstin_for_india' @@ -278,4 +278,4 @@ regional_overrides = { 'Saudi Arabia': { 'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.united_arab_emirates.utils.update_itemised_tax_data' } -} +} \ No newline at end of file diff --git a/erpnext/hr/doctype/attendance/test_records.json b/erpnext/hr/doctype/attendance/test_records.json index 1c8f3b5633e..096f95c6f7b 100644 --- a/erpnext/hr/doctype/attendance/test_records.json +++ b/erpnext/hr/doctype/attendance/test_records.json @@ -2,7 +2,7 @@ { "doctype": "Attendance", "name": "_Test Attendance 1", - "employee": "_T-Employee-0001", + "employee": "_T-Employee-00001", "status": "Present", "attendance_date": "2014-02-01", "company": "_Test Company" diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index 25d3ec4bc95..5446a6e4a81 100755 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.utils import getdate, validate_email_add, today, add_years -from frappe.model.naming import make_autoname +from frappe.model.naming import set_name_by_naming_series from frappe import throw, _, scrub import frappe.permissions from frappe.model.document import Document @@ -24,7 +24,7 @@ class Employee(NestedSet): throw(_("Please setup Employee Naming System in Human Resource > HR Settings")) else: if naming_method == 'Naming Series': - self.name = make_autoname(self.naming_series + '.####') + set_name_by_naming_series(self) elif naming_method == 'Employee Number': self.name = self.employee_number elif naming_method == 'Full Name': diff --git a/erpnext/hr/doctype/employee_advance/test_employee_advance.py b/erpnext/hr/doctype/employee_advance/test_employee_advance.py index cacf90ef059..2097e711de4 100644 --- a/erpnext/hr/doctype/employee_advance/test_employee_advance.py +++ b/erpnext/hr/doctype/employee_advance/test_employee_advance.py @@ -35,7 +35,7 @@ def make_payment_entry(advance): def make_employee_advance(): doc = frappe.new_doc("Employee Advance") - doc.employee = "_T-Employee-0001" + doc.employee = "_T-Employee-00001" doc.company = "_Test company" doc.purpose = "For site visit" doc.advance_amount = 1000 @@ -43,5 +43,5 @@ def make_employee_advance(): doc.advance_account = "_Test Employee Advance - _TC" doc.insert() doc.submit() - + return doc \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index e0ba088fed7..f89beba2f60 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -87,7 +87,7 @@ def get_payable_account(company): def make_expense_claim(payable_account,claim_amount, sanctioned_amount, company, account, project=None, task_name=None): expense_claim = frappe.get_doc({ "doctype": "Expense Claim", - "employee": "_T-Employee-0001", + "employee": "_T-Employee-00001", "payable_account": payable_account, "company": company, "expenses": diff --git a/erpnext/hr/doctype/leave_allocation/test_records.json b/erpnext/hr/doctype/leave_allocation/test_records.json index 106ed0e615d..23acbb026ef 100644 --- a/erpnext/hr/doctype/leave_allocation/test_records.json +++ b/erpnext/hr/doctype/leave_allocation/test_records.json @@ -2,7 +2,7 @@ { "docstatus": 1, "doctype": "Leave Allocation", - "employee": "_T-Employee-0001", + "employee": "_T-Employee-00001", "from_date": "2013-01-01", "to_date": "2013-12-31", "leave_type": "_Test Leave Type", @@ -11,7 +11,7 @@ { "docstatus": 1, "doctype": "Leave Allocation", - "employee": "_T-Employee-0002", + "employee": "_T-Employee-00002", "from_date": "2013-01-01", "to_date": "2013-12-31", "leave_type": "_Test Leave Type", diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 4a9a001339d..38b10f7df18 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -14,7 +14,7 @@ _test_records = [ { "company": "_Test Company", "doctype": "Leave Application", - "employee": "_T-Employee-0001", + "employee": "_T-Employee-00001", "from_date": "2013-05-01", "leave_type": "_Test Leave Type", "posting_date": "2013-01-02", @@ -23,7 +23,7 @@ _test_records = [ { "company": "_Test Company", "doctype": "Leave Application", - "employee": "_T-Employee-0002", + "employee": "_T-Employee-00002", "from_date": "2013-05-01", "leave_type": "_Test Leave Type", "posting_date": "2013-01-02", @@ -32,7 +32,7 @@ _test_records = [ { "company": "_Test Company", "doctype": "Leave Application", - "employee": "_T-Employee-0001", + "employee": "_T-Employee-00001", "from_date": "2013-01-15", "leave_type": "_Test Leave Type LWP", "posting_date": "2013-01-02", @@ -188,7 +188,7 @@ class TestLeaveApplication(unittest.TestCase): application.half_day_date = application.from_date self.assertRaises(OverlapError, application.insert) - + def test_overlap_with_half_day_3(self): self._clear_roles() self._clear_applications() @@ -206,14 +206,14 @@ class TestLeaveApplication(unittest.TestCase): application.half_day = 1 application.half_day_date = "2013-01-05" application.insert() - + # Apply leave from 4-7, half day on 5th application = self.get_application(_test_records[0]) application.from_date = "2013-01-04" application.to_date = "2013-01-07" application.half_day = 1 application.half_day_date = "2013-01-05" - + self.assertRaises(OverlapError, application.insert) # Apply leave from 5-7, half day on 5th @@ -230,15 +230,15 @@ class TestLeaveApplication(unittest.TestCase): from frappe.utils.user import add_role add_role("test1@example.com", "Employee") add_role("test@example.com", "Leave Approver") - self._add_employee_leave_approver("_T-Employee-0002", "test@example.com") + self._add_employee_leave_approver("_T-Employee-00002", "test@example.com") - make_allocation_record(employee="_T-Employee-0002") + make_allocation_record(employee="_T-Employee-00002") application = self.get_application(_test_records[1]) frappe.db.set_value("Leave Block List", "_Test Leave Block List", "applies_to_all_departments", 1) - frappe.db.set_value("Employee", "_T-Employee-0002", "department", + frappe.db.set_value("Employee", "_T-Employee-00002", "department", "_Test Department") frappe.set_user("test1@example.com") @@ -255,7 +255,7 @@ def make_allocation_record(employee=None, leave_type=None): allocation = frappe.get_doc({ "doctype": "Leave Allocation", - "employee": employee or "_T-Employee-0001", + "employee": employee or "_T-Employee-00001", "leave_type": leave_type or "_Test Leave Type", "from_date": "2013-01-01", "to_date": "2015-12-31", diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index c6463fa37d8..ea33f4ed02e 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -573,7 +573,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True) for item in items: - if item_dict.has_key(item.item_code): + if item.item_code in item_dict: item_dict[item.item_code]["qty"] += flt(item.qty) else: item_dict[item.item_code] = item @@ -653,4 +653,4 @@ def get_boms_in_bottom_up_order(bom_no=None): bom_list.append(child_bom) count += 1 - return bom_list \ No newline at end of file + return bom_list diff --git a/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py b/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py index bf286449c46..139751a684d 100644 --- a/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py +++ b/erpnext/patches/v10_0/remove_and_copy_fields_in_physician.py @@ -1,12 +1,13 @@ import frappe def execute(): - if frappe.db.exists("DocType", "Physician"): - frappe.reload_doc("healthcare", "doctype", "physician") - frappe.reload_doc("healthcare", "doctype", "physician_service_unit_schedule") - if frappe.db.has_column('Physician', 'physician_schedule'): - for doc in frappe.get_all('Physician'): - _doc = frappe.get_doc('Physician', doc.name) - if _doc.physician_schedule: - _doc.append('physician_schedules', {'schedule': _doc.physician_schedule}) - _doc.save() + if frappe.db.exists("DocType", "Physician"): + frappe.reload_doc("healthcare", "doctype", "physician") + frappe.reload_doc("healthcare", "doctype", "physician_service_unit_schedule") + + if frappe.db.has_column('Physician', 'physician_schedule'): + for doc in frappe.get_all('Physician'): + _doc = frappe.get_doc('Physician', doc.name) + if _doc.physician_schedule: + _doc.append('physician_schedules', {'schedule': _doc.physician_schedule}) + _doc.save() diff --git a/erpnext/projects/doctype/activity_cost/test_activity_cost.py b/erpnext/projects/doctype/activity_cost/test_activity_cost.py index 58c3f21bef8..67d76eb1eee 100644 --- a/erpnext/projects/doctype/activity_cost/test_activity_cost.py +++ b/erpnext/projects/doctype/activity_cost/test_activity_cost.py @@ -13,7 +13,7 @@ class TestActivityCost(unittest.TestCase): frappe.db.sql("delete from `tabActivity Cost`") activity_cost1 = frappe.new_doc('Activity Cost') activity_cost1.update({ - "employee": "_T-Employee-0001", + "employee": "_T-Employee-00001", "employee_name": "_Test Employee", "activity_type": "_Test Activity Type 1", "billing_rate": 100, diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 793355e1fc7..2458db0cba1 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -14,8 +14,8 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal class TestTimesheet(unittest.TestCase): def test_timesheet_billing_amount(self): - make_salary_structure("_T-Employee-0001") - timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=1) + make_salary_structure("_T-Employee-00001") + timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1) self.assertEqual(timesheet.total_hours, 2) self.assertEqual(timesheet.total_billable_hours, 2) @@ -24,8 +24,8 @@ class TestTimesheet(unittest.TestCase): self.assertEqual(timesheet.total_billable_amount, 100) def test_timesheet_billing_amount_not_billable(self): - make_salary_structure("_T-Employee-0001") - timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=0) + make_salary_structure("_T-Employee-00001") + timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=0) self.assertEqual(timesheet.total_hours, 2) self.assertEqual(timesheet.total_billable_hours, 0) @@ -34,8 +34,8 @@ class TestTimesheet(unittest.TestCase): self.assertEqual(timesheet.total_billable_amount, 0) def test_salary_slip_from_timesheet(self): - salary_structure = make_salary_structure("_T-Employee-0001") - timesheet = make_timesheet("_T-Employee-0001", simulate = True, billable=1) + salary_structure = make_salary_structure("_T-Employee-00001") + timesheet = make_timesheet("_T-Employee-00001", simulate = True, billable=1) salary_slip = make_salary_slip(timesheet.name) salary_slip.submit() @@ -44,7 +44,7 @@ class TestTimesheet(unittest.TestCase): self.assertEqual(salary_slip.net_pay, 150) self.assertEqual(salary_slip.timesheets[0].time_sheet, timesheet.name) self.assertEqual(salary_slip.timesheets[0].working_hours, 2) - + timesheet = frappe.get_doc('Timesheet', timesheet.name) self.assertEqual(timesheet.status, 'Payslip') salary_slip.cancel() @@ -53,7 +53,7 @@ class TestTimesheet(unittest.TestCase): self.assertEqual(timesheet.status, 'Submitted') def test_sales_invoice_from_timesheet(self): - timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=1) + timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1) sales_invoice = make_sales_invoice(timesheet.name, '_Test Item', '_Test Customer') sales_invoice.due_date = nowdate() sales_invoice.submit() @@ -68,7 +68,7 @@ class TestTimesheet(unittest.TestCase): self.assertEqual(item.rate, 50.00) def test_timesheet_billing_based_on_project(self): - timesheet = make_timesheet("_T-Employee-0001", simulate=True, billable=1, project = '_Test Project', company='_Test Company') + timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1, project = '_Test Project', company='_Test Company') sales_invoice = create_sales_invoice(do_not_save=True) sales_invoice.project = '_Test Project' sales_invoice.submit() @@ -85,7 +85,7 @@ class TestTimesheet(unittest.TestCase): update_activity_type("_Test Activity Type") timesheet = frappe.new_doc("Timesheet") - timesheet.employee = "_T-Employee-0001" + timesheet.employee = "_T-Employee-00001" timesheet.append( 'time_logs', { @@ -140,11 +140,11 @@ def make_salary_structure(employee): "base": 1200, "from_date": add_months(nowdate(),-1) }) - - + + es = salary_structure.append('earnings', { "salary_component": "_Test Allowance", - "amount": 100 + "amount": 100 }) ds = salary_structure.append('deductions', { diff --git a/erpnext/public/js/pos/pos.html b/erpnext/public/js/pos/pos.html index 1d9fd7c20f4..af90756963b 100644 --- a/erpnext/public/js/pos/pos.html +++ b/erpnext/public/js/pos/pos.html @@ -37,20 +37,22 @@