From edf87a258f59e240c62778afe1efedc9371f103d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 21 May 2014 15:38:23 +0530 Subject: [PATCH] Create serial no based on series only if item is serialized --- erpnext/stock/doctype/item/item.json | 5 ++++- erpnext/stock/doctype/item/item.py | 4 ++++ erpnext/stock/doctype/serial_no/serial_no.py | 3 ++- .../stock/doctype/stock_ledger_entry/stock_ledger_entry.py | 6 ++---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index f42f35ccfa..0e12cd2963 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -277,6 +277,7 @@ "fieldname": "serial_no_series", "fieldtype": "Data", "label": "Serial Number Series", + "no_copy": 1, "permlevel": 0 }, { @@ -728,6 +729,7 @@ "fieldname": "page_name", "fieldtype": "Data", "label": "Page Name", + "no_copy": 1, "permlevel": 0, "read_only": 1 }, @@ -825,6 +827,7 @@ "fieldtype": "Link", "ignore_restrictions": 1, "label": "Parent Website Route", + "no_copy": 1, "options": "Website Route", "permlevel": 0 } @@ -832,7 +835,7 @@ "icon": "icon-tag", "idx": 1, "max_attachments": 1, - "modified": "2014-05-12 07:54:58.118118", + "modified": "2014-05-21 15:37:30.124881", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 642a4293a5..104f905383 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -119,6 +119,10 @@ class Item(WebsiteGenerator): if self.has_serial_no == 'Yes' and self.is_stock_item == 'No': msgprint(_("'Has Serial No' can not be 'Yes' for non-stock item"), raise_exception=1) + if self.has_serial_no == "No" and self.serial_no_series: + self.serial_no_series = None + + def check_for_active_boms(self): if self.is_purchase_item != "Yes": bom_mat = frappe.db.sql("""select distinct t1.parent diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index dbbc3efdc6..ff4d519cf9 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -248,7 +248,8 @@ def validate_serial_no(sle, item_det): SerialNoRequiredError) def update_serial_nos(sle, item_det): - if sle.is_cancelled == "No" and not sle.serial_no and sle.actual_qty > 0 and item_det.serial_no_series: + if sle.is_cancelled == "No" and not sle.serial_no and sle.actual_qty > 0 \ + and item_det.has_serial_no == "Yes" and item_det.serial_no_series: from frappe.model.naming import make_autoname serial_nos = [] for i in xrange(cint(sle.actual_qty)): diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 79eeddf2a8..df3fef437b 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -50,10 +50,8 @@ class StockLedgerEntry(Document): frappe.throw(_("{0} is required").format(self.meta.get_label(k))) def validate_item(self): - item_det = frappe.db.sql("""select name, has_batch_no, docstatus, - is_stock_item, has_serial_no, serial_no_series - from tabItem where name=%s""", - self.item_code, as_dict=True)[0] + item_det = frappe.db.sql("""select name, has_batch_no, docstatus, is_stock_item + from tabItem where name=%s""", self.item_code, as_dict=True)[0] if item_det.is_stock_item != 'Yes': frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))