Merge branch 'hotfix'

This commit is contained in:
Ameya Shenoy 2018-09-26 07:26:49 +00:00
commit 0ff35a852a
No known key found for this signature in database
GPG Key ID: AC016A555657D0A3
5 changed files with 34 additions and 15 deletions

View File

@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides from erpnext.hooks import regional_overrides
from frappe.utils import getdate from frappe.utils import getdate
__version__ = '10.1.53' __version__ = '10.1.54'
def get_default_company(user=None): def get_default_company(user=None):
'''Get default company for user''' '''Get default company for user'''

View File

@ -506,7 +506,7 @@ def save_invoice(doc, name, name_list):
frappe.db.commit() frappe.db.commit()
name_list.append(name) name_list.append(name)
except Exception: except Exception:
frappe.log_error(frappe.get_traceback())
frappe.db.rollback() frappe.db.rollback()
frappe.log_error(frappe.get_traceback())
return name_list return name_list

View File

@ -16,7 +16,9 @@ class BOMUpdateTool(Document):
self.update_new_bom() self.update_new_bom()
bom_list = self.get_parent_boms(self.new_bom) bom_list = self.get_parent_boms(self.new_bom)
updated_bom = [] updated_bom = []
for bom in bom_list: for bom in bom_list:
try:
bom_obj = frappe.get_doc("BOM", bom) bom_obj = frappe.get_doc("BOM", bom)
bom_obj.get_doc_before_save() bom_obj.get_doc_before_save()
updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom)
@ -27,6 +29,11 @@ class BOMUpdateTool(Document):
and bom_obj._doc_before_save and not bom_obj.flags.ignore_version): and bom_obj._doc_before_save and not bom_obj.flags.ignore_version):
bom_obj.save_version() bom_obj.save_version()
frappe.db.commit()
except Exception:
frappe.db.rollback()
frappe.log_error(frappe.get_traceback())
def validate_bom(self): def validate_bom(self):
if cstr(self.current_bom) == cstr(self.new_bom): if cstr(self.current_bom) == cstr(self.new_bom):
frappe.throw(_("Current BOM and New BOM can not be same")) frappe.throw(_("Current BOM and New BOM can not be same"))

View File

@ -138,10 +138,15 @@ erpnext.setup.slides_settings = [
validate: function () { validate: function () {
// validate fiscal year start and end dates // 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")); frappe.msgprint(__("Please enter valid Financial Year Start and End Dates"));
return false; return false;
} }
return true; return true;
}, },

View File

@ -187,13 +187,14 @@ def process_serial_no(sle):
update_serial_nos(sle, item_det) update_serial_nos(sle, item_det)
def validate_serial_no(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 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), frappe.throw(_("Item {0} is not setup for Serial Nos. Column must be blank").format(sle.item_code),
SerialNoNotRequiredError) SerialNoNotRequiredError)
elif sle.is_cancelled == "No": elif sle.is_cancelled == "No":
if sle.serial_no: if serial_nos:
serial_nos = get_serial_nos(sle.serial_no)
if cint(sle.actual_qty) != flt(sle.actual_qty): 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)) 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: 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), frappe.throw(_("Serial Nos Required for Serialized Item {0}").format(sle.item_code),
SerialNoRequiredError) 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): def has_duplicate_serial_no(sn, sle):
if sn.warehouse: if sn.warehouse: