From 7a8c5b0c2c019063c5c98e4c1323ec6d0a4575a3 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 25 Sep 2018 18:34:33 +0530 Subject: [PATCH 1/4] fix(setup wizard): Validate FY dates (#15473) --- erpnext/public/js/setup_wizard.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js index 6fa710d982..484d81decc 100644 --- a/erpnext/public/js/setup_wizard.js +++ b/erpnext/public/js/setup_wizard.js @@ -138,10 +138,15 @@ erpnext.setup.slides_settings = [ validate: function () { // validate fiscal year start and end dates - if (this.values.fy_start_date == 'Invalid date' || this.values.fy_end_date == 'Invalid date') { + const invalid = this.values.fy_start_date == 'Invalid date' || + this.values.fy_end_date == 'Invalid date'; + const start_greater_than_end = this.values.fy_start_date > this.values.fy_end_date; + + if (invalid || start_greater_than_end) { frappe.msgprint(__("Please enter valid Financial Year Start and End Dates")); return false; } + return true; }, From fe1e4a41e66436e754b301d8904b6e648e4ea688 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 25 Sep 2018 18:36:32 +0530 Subject: [PATCH 2/4] Validate negative stock serial number (#15492) --- erpnext/stock/doctype/serial_no/serial_no.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index a8cab80cbe..3d1979dd81 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -187,13 +187,14 @@ def process_serial_no(sle): update_serial_nos(sle, item_det) def validate_serial_no(sle, item_det): + serial_nos = get_serial_nos(sle.serial_no) if sle.serial_no else [] + if item_det.has_serial_no==0: - if sle.serial_no: + if serial_nos: frappe.throw(_("Item {0} is not setup for Serial Nos. Column must be blank").format(sle.item_code), SerialNoNotRequiredError) elif sle.is_cancelled == "No": - if sle.serial_no: - serial_nos = get_serial_nos(sle.serial_no) + if serial_nos: if cint(sle.actual_qty) != flt(sle.actual_qty): frappe.throw(_("Serial No {0} quantity {1} cannot be a fraction").format(sle.item_code, sle.actual_qty)) @@ -239,6 +240,12 @@ def validate_serial_no(sle, item_det): elif sle.actual_qty < 0 or not item_det.serial_no_series: frappe.throw(_("Serial Nos Required for Serialized Item {0}").format(sle.item_code), SerialNoRequiredError) + elif serial_nos: + for serial_no in serial_nos: + sr = frappe.db.get_value("Serial No", serial_no, ["name", "warehouse"], as_dict=1) + if sr and sle.actual_qty < 0 and sr.warehouse != sle.warehouse: + frappe.throw(_("Cannot cancel {0} {1} because Serial No {2} does not belong to the warehouse {3}") + .format(sle.voucher_type, sle.voucher_no, serial_no, sle.warehouse)) def has_duplicate_serial_no(sn, sle): if sn.warehouse: From fafc27766600f098f72b6175272bc62b724d47c3 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 25 Sep 2018 18:59:20 +0530 Subject: [PATCH 3/4] [Fix] BOM update tool, too many writes in one request. Please send smaller requests (#15432) --- erpnext/accounts/doctype/sales_invoice/pos.py | 2 +- .../bom_update_tool/bom_update_tool.py | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index a5157240ac..93cabb043c 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -506,7 +506,7 @@ def save_invoice(doc, name, name_list): frappe.db.commit() name_list.append(name) except Exception: - frappe.log_error(frappe.get_traceback()) frappe.db.rollback() + frappe.log_error(frappe.get_traceback()) return name_list diff --git a/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py b/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py index c91bb8f332..3f6cb44c49 100644 --- a/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py +++ b/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py @@ -16,16 +16,23 @@ class BOMUpdateTool(Document): self.update_new_bom() bom_list = self.get_parent_boms(self.new_bom) updated_bom = [] + for bom in bom_list: - bom_obj = frappe.get_doc("BOM", bom) - bom_obj.get_doc_before_save() - updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) - bom_obj.calculate_cost() - bom_obj.update_parent_cost() - bom_obj.db_update() - if (getattr(bom_obj.meta, 'track_changes', False) - and bom_obj._doc_before_save and not bom_obj.flags.ignore_version): - bom_obj.save_version() + try: + bom_obj = frappe.get_doc("BOM", bom) + bom_obj.get_doc_before_save() + updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) + bom_obj.calculate_cost() + bom_obj.update_parent_cost() + bom_obj.db_update() + if (getattr(bom_obj.meta, 'track_changes', False) + and bom_obj._doc_before_save and not bom_obj.flags.ignore_version): + bom_obj.save_version() + + frappe.db.commit() + except Exception: + frappe.db.rollback() + frappe.log_error(frappe.get_traceback()) def validate_bom(self): if cstr(self.current_bom) == cstr(self.new_bom): From e04431ea5c7f02b38f51861ed90418375a08020a Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Wed, 26 Sep 2018 07:26:49 +0000 Subject: [PATCH 4/4] bumped to version 10.1.54 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index a7ec84ade6..68f1fa749b 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.53' +__version__ = '10.1.54' def get_default_company(user=None): '''Get default company for user'''