fix: linters and travis
This commit is contained in:
parent
9b72845f0f
commit
7290dd87be
@ -316,10 +316,10 @@ def validate_serial_no_with_batch(serial_nos, item_code):
|
||||
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()
|
||||
|
@ -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) {
|
||||
|
||||
// }
|
||||
});
|
@ -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": []
|
||||
}
|
@ -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
|
@ -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
|
@ -52,10 +52,13 @@ class SerialandBatchBundle(Document):
|
||||
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 @@ class SerialandBatchBundle(Document):
|
||||
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 @@ class SerialandBatchBundle(Document):
|
||||
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 @@ class SerialandBatchBundle(Document):
|
||||
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()
|
||||
|
@ -133,17 +133,6 @@ def get_items_html(serial_nos, item_code):
|
||||
)
|
||||
|
||||
|
||||
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
|
||||
|
@ -900,6 +900,8 @@ class StockEntry(StockController):
|
||||
|
||||
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:
|
||||
|
@ -90,20 +90,20 @@ class StockLedgerEntry(Document):
|
||||
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 @@ class StockLedgerEntry(Document):
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user