- validate EAN or UPC-A code
- made Item Barcode Doctpye standard - added stdnum to requirements
This commit is contained in:
parent
9b7e52cafb
commit
a04c756913
@ -483,12 +483,18 @@ class Item(WebsiteGenerator):
|
|||||||
check_list.append(d.tax_type)
|
check_list.append(d.tax_type)
|
||||||
|
|
||||||
def validate_barcode(self):
|
def validate_barcode(self):
|
||||||
|
from stdnum import ean
|
||||||
if len(self.barcodes) > 0:
|
if len(self.barcodes) > 0:
|
||||||
for barcode in self.barcodes:
|
for item_barcode in self.barcodes:
|
||||||
duplicate = frappe.db.sql("""select name from `tabItem Barcode` where barcode = %s and parent != %s""", (barcode, self.name))
|
duplicate = frappe.db.sql("""select name from `tabItem Barcode` where barcode = %s and parent != %s""", (item_barcode.barcode, self.name))
|
||||||
if duplicate:
|
if duplicate:
|
||||||
frappe.throw(_("Barcode {0} already used in Item {1}").format(
|
frappe.throw(_("Barcode {0} already used in Item {1}").format(
|
||||||
self.barcode, duplicate[0][0]))
|
item_barcode.barcode, duplicate[0][0]))
|
||||||
|
|
||||||
|
if item_barcode.barcode_type:
|
||||||
|
if not ean.is_valid(item_barcode.barcode):
|
||||||
|
frappe.throw(_("Barcode {0} is not a valid {1} code").format(
|
||||||
|
item_barcode.barcode, item_barcode.barcode_type))
|
||||||
|
|
||||||
def validate_warehouse_for_reorder(self):
|
def validate_warehouse_for_reorder(self):
|
||||||
'''Validate Reorder level table for duplicate and conditional mandatory'''
|
'''Validate Reorder level table for duplicate and conditional mandatory'''
|
||||||
|
0
erpnext/stock/doctype/item_barcode/__init__.py
Normal file
0
erpnext/stock/doctype/item_barcode/__init__.py
Normal file
102
erpnext/stock/doctype/item_barcode/item_barcode.json
Normal file
102
erpnext/stock/doctype/item_barcode/item_barcode.json
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
"allow_copy": 0,
|
||||||
|
"allow_guest_to_view": 0,
|
||||||
|
"allow_import": 0,
|
||||||
|
"allow_rename": 0,
|
||||||
|
"beta": 0,
|
||||||
|
"creation": "2017-12-09 18:54:50.562438",
|
||||||
|
"custom": 0,
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "barcode",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Barcode",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "barcode_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Barcode Type",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "\nEAN\nUPC-A",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"has_web_view": 0,
|
||||||
|
"hide_heading": 0,
|
||||||
|
"hide_toolbar": 0,
|
||||||
|
"idx": 0,
|
||||||
|
"image_view": 0,
|
||||||
|
"in_create": 0,
|
||||||
|
"is_submittable": 0,
|
||||||
|
"issingle": 0,
|
||||||
|
"istable": 1,
|
||||||
|
"max_attachments": 0,
|
||||||
|
"modified": "2017-12-10 18:39:10.566172",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Stock",
|
||||||
|
"name": "Item Barcode",
|
||||||
|
"name_case": "",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"quick_entry": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"read_only_onload": 0,
|
||||||
|
"show_name_in_global_search": 0,
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1,
|
||||||
|
"track_seen": 0
|
||||||
|
}
|
10
erpnext/stock/doctype/item_barcode/item_barcode.py
Normal file
10
erpnext/stock/doctype/item_barcode/item_barcode.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class ItemBarcode(Document):
|
||||||
|
pass
|
@ -2,3 +2,4 @@ frappe
|
|||||||
unidecode
|
unidecode
|
||||||
pygithub
|
pygithub
|
||||||
googlemaps
|
googlemaps
|
||||||
|
python-stdnum
|
||||||
|
Loading…
x
Reference in New Issue
Block a user