fix: linters and travis
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index a9df1e8..84ab74a 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -316,10 +316,10 @@
frappe.throw(_("There is no batch found against the {0}: {1}").format(message, serial_no_link))
-def make_batch(args):
- if frappe.db.get_value("Item", args.item, "has_batch_no"):
- args.doctype = "Batch"
- return frappe.get_doc(args).insert().name
+def make_batch(kwargs):
+ if frappe.db.get_value("Item", kwargs.item, "has_batch_no"):
+ kwargs.doctype = "Batch"
+ return frappe.get_doc(kwargs).insert().name
@frappe.whitelist()
diff --git a/erpnext/stock/doctype/package_item/__init__.py b/erpnext/stock/doctype/package_item/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/stock/doctype/package_item/__init__.py
+++ /dev/null
diff --git a/erpnext/stock/doctype/package_item/package_item.js b/erpnext/stock/doctype/package_item/package_item.js
deleted file mode 100644
index 65fda46..0000000
--- a/erpnext/stock/doctype/package_item/package_item.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
-// For license information, please see license.txt
-
-frappe.ui.form.on('Package Item', {
- // refresh: function(frm) {
-
- // }
-});
diff --git a/erpnext/stock/doctype/package_item/package_item.json b/erpnext/stock/doctype/package_item/package_item.json
deleted file mode 100644
index 5b0246f..0000000
--- a/erpnext/stock/doctype/package_item/package_item.json
+++ /dev/null
@@ -1,138 +0,0 @@
-{
- "actions": [],
- "creation": "2022-09-29 14:56:38.338267",
- "doctype": "DocType",
- "editable_grid": 1,
- "engine": "InnoDB",
- "field_order": [
- "item_details_tab",
- "company",
- "item_code",
- "column_break_4",
- "warehouse",
- "qty",
- "serial_no_and_batch_no_tab",
- "transactions",
- "reference_details_tab",
- "voucher_type",
- "voucher_no",
- "column_break_12",
- "voucher_detail_no",
- "amended_from"
- ],
- "fields": [
- {
- "fieldname": "item_code",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Item Code",
- "options": "Item",
- "reqd": 1
- },
- {
- "fieldname": "amended_from",
- "fieldtype": "Link",
- "label": "Amended From",
- "no_copy": 1,
- "options": "Package Item",
- "print_hide": 1,
- "read_only": 1
- },
- {
- "fieldname": "item_details_tab",
- "fieldtype": "Tab Break",
- "label": "Item Details"
- },
- {
- "fieldname": "warehouse",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Warehouse",
- "options": "Warehouse",
- "reqd": 1
- },
- {
- "fieldname": "column_break_4",
- "fieldtype": "Column Break"
- },
- {
- "fieldname": "company",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Company",
- "options": "Company",
- "reqd": 1
- },
- {
- "fieldname": "qty",
- "fieldtype": "Float",
- "label": "Total Qty"
- },
- {
- "fieldname": "reference_details_tab",
- "fieldtype": "Tab Break",
- "label": "Reference Details"
- },
- {
- "fieldname": "voucher_type",
- "fieldtype": "Link",
- "label": "Voucher Type",
- "options": "DocType",
- "reqd": 1
- },
- {
- "fieldname": "voucher_no",
- "fieldtype": "Dynamic Link",
- "label": "Voucher No",
- "options": "voucher_type"
- },
- {
- "fieldname": "voucher_detail_no",
- "fieldtype": "Data",
- "label": "Voucher Detail No",
- "read_only": 1
- },
- {
- "fieldname": "serial_no_and_batch_no_tab",
- "fieldtype": "Tab Break",
- "label": "Serial No and Batch No"
- },
- {
- "fieldname": "column_break_12",
- "fieldtype": "Column Break"
- },
- {
- "fieldname": "transactions",
- "fieldtype": "Table",
- "label": "Items",
- "options": "Serial and Batch No Transaction",
- "reqd": 1
- }
- ],
- "index_web_pages_for_search": 1,
- "is_submittable": 1,
- "links": [],
- "modified": "2022-10-06 22:07:31.732744",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Package Item",
- "owner": "Administrator",
- "permissions": [
- {
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "System Manager",
- "share": 1,
- "submit": 1,
- "write": 1
- }
- ],
- "sort_field": "modified",
- "sort_order": "DESC",
- "states": []
-}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/package_item/package_item.py b/erpnext/stock/doctype/package_item/package_item.py
deleted file mode 100644
index c0a2eaa..0000000
--- a/erpnext/stock/doctype/package_item/package_item.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors
-# For license information, please see license.txt
-
-# import frappe
-from frappe.model.document import Document
-
-
-class PackageItem(Document):
- pass
diff --git a/erpnext/stock/doctype/package_item/test_package_item.py b/erpnext/stock/doctype/package_item/test_package_item.py
deleted file mode 100644
index 6dcc9cb..0000000
--- a/erpnext/stock/doctype/package_item/test_package_item.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
-# See license.txt
-
-# import frappe
-from frappe.tests.utils import FrappeTestCase
-
-
-class TestPackageItem(FrappeTestCase):
- pass
diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py
index afcc676..0624ae9 100644
--- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py
+++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py
@@ -52,10 +52,13 @@
if (
not serial_no_warehouse.get(serial_no) or serial_no_warehouse.get(serial_no) != self.warehouse
):
- frappe.throw(
- _(f"Serial No {bold(serial_no)} is not present in the warehouse {bold(self.warehouse)}.")
+ self.throw_error_message(
+ f"Serial No {bold(serial_no)} is not present in the warehouse {bold(self.warehouse)}."
)
+ def throw_error_message(self, message):
+ frappe.throw(_(message), title=_("Error"))
+
def set_incoming_rate(self, row=None, save=False):
if self.type_of_transaction == "Outward":
self.set_incoming_rate_for_outward_transaction(row, save)
@@ -223,10 +226,10 @@
return
if self.voucher_no and not frappe.db.exists(self.voucher_type, self.voucher_no):
- frappe.throw(_(f"The {self.voucher_type} # {self.voucher_no} does not exist"))
+ self.throw_error_message(f"The {self.voucher_type} # {self.voucher_no} does not exist")
if frappe.get_cached_value(self.voucher_type, self.voucher_no, "docstatus") != 1:
- frappe.throw(_(f"The {self.voucher_type} # {self.voucher_no} should be submit first."))
+ self.throw_error_message(f"The {self.voucher_type} # {self.voucher_no} should be submit first.")
def check_future_entries_exists(self):
if not self.has_serial_no:
@@ -286,10 +289,8 @@
qty_field = "consumed_qty"
if abs(flt(self.total_qty, precision)) - abs(flt(row.get(qty_field), precision)) > 0.01:
- frappe.throw(
- _(
- f"Total quantity {self.total_qty} in the Serial and Batch Bundle {self.name} does not match with the Item {self.item_code} in the {self.voucher_type} # {self.voucher_no}"
- )
+ self.throw_error_message(
+ f"Total quantity {self.total_qty} in the Serial and Batch Bundle {self.name} does not match with the Item {self.item_code} in the {self.voucher_type} # {self.voucher_no}"
)
def set_is_outward(self):
@@ -364,12 +365,12 @@
if serial_nos:
for key, value in collections.Counter(serial_nos).items():
if value > 1:
- frappe.throw(_(f"Duplicate Serial No {key} found"))
+ self.throw_error_message(f"Duplicate Serial No {key} found")
if batch_nos:
for key, value in collections.Counter(batch_nos).items():
if value > 1:
- frappe.throw(_(f"Duplicate Batch No {key} found"))
+ self.throw_error_message(f"Duplicate Batch No {key} found")
def before_cancel(self):
self.delink_serial_and_batch_bundle()
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index 03c40eb..64684d9 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -133,17 +133,6 @@
)
-def get_item_details(item_code):
- return frappe.db.sql(
- """select name, has_batch_no, docstatus,
- is_stock_item, has_serial_no, serial_no_series, description, item_name,
- item_group, stock_uom
- from tabItem where name=%s""",
- item_code,
- as_dict=True,
- )[0]
-
-
def get_serial_nos(serial_no):
if isinstance(serial_no, list):
return serial_no
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 8ba8d11..fb5a93c 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -900,6 +900,8 @@
def make_serial_and_batch_bundle_for_outward(self):
serial_or_batch_items = get_serial_or_batch_items(self.items)
+ if not serial_or_batch_items:
+ return
for row in self.items:
if row.serial_and_batch_bundle or row.item_code not in serial_or_batch_items:
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 35d7661..cdb3e5f 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -90,20 +90,20 @@
self.db_set(values_to_be_change)
if not item_detail:
- frappe.throw(_("Item {0} not found").format(self.item_code))
+ self.throw_error_message(f"Item {self.item_code} not found")
if item_detail.has_variants:
- frappe.throw(
- _("Stock cannot exist for Item {0} since has variants").format(self.item_code),
+ self.throw_error_message(
+ f"Stock cannot exist for Item {self.item_code} since has variants",
ItemTemplateCannotHaveStock,
)
if item_detail.is_stock_item != 1:
- frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))
+ self.throw_error_message("Item {0} must be a stock Item").format(self.item_code)
if item_detail.has_serial_no or item_detail.has_batch_no:
if not self.serial_and_batch_bundle:
- frappe.throw(_(f"Serial No / Batch No are mandatory for Item {self.item_code}"))
+ self.throw_error_message(f"Serial No / Batch No are mandatory for Item {self.item_code}")
else:
bundle_data = frappe.get_cached_value(
"Serial and Batch Bundle", self.serial_and_batch_bundle, ["item_code", "docstatus"], as_dict=1
@@ -113,7 +113,10 @@
self.submit_serial_and_batch_bundle()
if self.serial_and_batch_bundle and not (item_detail.has_serial_no or item_detail.has_batch_no):
- frappe.throw(_(f"Serial No and Batch No are not allowed for Item {self.item_code}"))
+ self.throw_error_message(f"Serial No and Batch No are not allowed for Item {self.item_code}")
+
+ def throw_error_message(self, message, exception=frappe.ValidationError):
+ frappe.throw(_(message), exception)
def submit_serial_and_batch_bundle(self):
doc = frappe.get_doc("Serial and Batch Bundle", self.serial_and_batch_bundle)