Item Barcode implemented
This commit is contained in:
parent
91034af0dc
commit
2e3579a4eb
@ -211,6 +211,9 @@ class DocType(TransactionBase):
|
||||
ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
|
||||
return ret
|
||||
|
||||
def get_barcode_details(self, barcode):
|
||||
return get_obj('Sales Common').get_barcode_details(barcode)
|
||||
|
||||
|
||||
# Fetch ref rate from item master as per selected price list
|
||||
def get_adj_percent(self, arg=''):
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:48',
|
||||
'creation': '2012-04-13 11:56:18',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:48',
|
||||
'modified': '2012-06-07 19:05:06',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -22,7 +22,7 @@
|
||||
'section_style': u'Tray',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 29
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -40,6 +40,16 @@
|
||||
'name': u'Sales Invoice Item'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'barcode',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Barcode',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
@ -431,4 +441,4 @@
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
}
|
||||
]
|
||||
]
|
0
erpnext/patches/june_2012/__init__.py
Normal file
0
erpnext/patches/june_2012/__init__.py
Normal file
7
erpnext/patches/june_2012/barcode_in_feature_setup.py
Normal file
7
erpnext/patches/june_2012/barcode_in_feature_setup.py
Normal file
@ -0,0 +1,7 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.model.code import get_obj
|
||||
fs = get_obj('Features Setup')
|
||||
fs.doc.fs_item_barcode = 0
|
||||
fs.doc.save()
|
||||
fs.validate()
|
@ -412,4 +412,9 @@ patch_list = [
|
||||
'patch_file': 'remove_communication_log',
|
||||
'description': 'Remove Communication Log and replace it with Communication'
|
||||
},
|
||||
{
|
||||
'patch_module': 'patches.june_2012',
|
||||
'patch_file': 'barcode_in_feature_setup',
|
||||
'description': 'Track item by barcode'
|
||||
},
|
||||
]
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-05-15 12:14:54',
|
||||
'creation': '2012-06-04 15:40:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-18 18:21:08',
|
||||
'modified': '2012-06-07 17:58:39',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
@ -265,6 +265,16 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
}
|
||||
}
|
||||
|
||||
//Barcode
|
||||
//
|
||||
cur_frm.cscript.barcode = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
var callback = function(r, rt) {
|
||||
cur_frm.cscript.item_code(doc, cdt, cdn);
|
||||
}
|
||||
get_server_fields('get_barcode_details', d.barcode, cur_frm.cscript.fname, doc, cdt, cdn, 1, callback);
|
||||
}
|
||||
|
||||
|
||||
// *********************** QUANTITY ***************************
|
||||
cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
|
||||
|
@ -128,12 +128,13 @@ class DocType(TransactionBase):
|
||||
if not obj.doc.price_list_name:
|
||||
msgprint("Please Select Price List before selecting Items")
|
||||
raise Exception
|
||||
item = webnotes.conn.sql("select description, item_name, brand, item_group, stock_uom, default_warehouse, default_income_account, default_sales_cost_center, description_html from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life > now() or end_of_life = '0000-00-00') and (is_sales_item = 'Yes' or is_service_item = 'Yes')" % (args['item_code']), as_dict=1)
|
||||
item = webnotes.conn.sql("select description, item_name, brand, item_group, stock_uom, default_warehouse, default_income_account, default_sales_cost_center, description_html, barcode from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life > now() or end_of_life = '0000-00-00') and (is_sales_item = 'Yes' or is_service_item = 'Yes')" % (args['item_code']), as_dict=1)
|
||||
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , args['item_code'])
|
||||
t = {}
|
||||
for x in tax: t[x[0]] = flt(x[1])
|
||||
ret = {
|
||||
'description' : item and item[0]['description_html'] or item[0]['description'],
|
||||
'barcode' : item and item[0]['barcode'] or '',
|
||||
'item_group' : item and item[0]['item_group'] or '',
|
||||
'item_name' : item and item[0]['item_name'] or '',
|
||||
'brand' : item and item[0]['brand'] or '',
|
||||
@ -171,7 +172,6 @@ class DocType(TransactionBase):
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
# ***************** Get Ref rate as entered in Item Master ********************
|
||||
def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
|
||||
@ -179,6 +179,24 @@ class DocType(TransactionBase):
|
||||
base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0
|
||||
return base_ref_rate
|
||||
|
||||
def get_barcode_details(self, barcode):
|
||||
item = webnotes.conn.sql("select name, end_of_life, is_sales_item, is_service_item \
|
||||
from `tabItem` where barcode = %s", barcode, as_dict=1)
|
||||
ret = {}
|
||||
if not item:
|
||||
msgprint("""No item found for this barcode: %s.
|
||||
May be barcode not updated in item master. Please check""" % barcode)
|
||||
elif item[0]['end_of_life'] and getdate(cstr(item[0]['end_of_life'])) < nowdate():
|
||||
msgprint("Item: %s has been expired. Please check 'End of Life' field in item master" % item[0]['name'])
|
||||
elif item[0]['is_sales_item'] == 'No' and item[0]['is_service_item'] == 'No':
|
||||
msgprint("Item: %s is not a sales or service item" % item[0]['name'])
|
||||
elif len(item) > 1:
|
||||
msgprint("There are multiple item for this barcode. \nPlease select item code manually")
|
||||
else:
|
||||
ret = {'item_code': item and item[0]['name'] or ''}
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
# ****** Re-cancellculates Basic Rate & amount based on Price List Selected ******
|
||||
def get_adj_percent(self, obj):
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:15',
|
||||
'creation': '2012-04-13 11:56:28',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:15',
|
||||
'modified': '2012-06-07 18:04:52',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -22,7 +22,7 @@
|
||||
'section_style': u'Tray',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 54
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -68,7 +68,7 @@
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 1,
|
||||
'width': u'150px'
|
||||
'width': u'150'
|
||||
},
|
||||
|
||||
# DocField
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:21',
|
||||
'creation': '2012-04-13 11:56:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:21',
|
||||
'modified': '2012-06-07 18:41:50',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -22,7 +22,7 @@
|
||||
'name_case': u'Title Case',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 1,
|
||||
'version': 26
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -104,6 +104,15 @@
|
||||
'label': u'Brands'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'To track items using barcode. You will be able to enter items in Delivery Note and Sales Invoice by scanning barcode of item.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_item_barcode',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Item Barcode'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
|
@ -93,6 +93,11 @@ pscript.feature_dict = {
|
||||
'Stock Entry': {'mtn_details':['serial_no']},
|
||||
'Stock Ledger Entry': {'fields':['serial_no']}
|
||||
},
|
||||
'fs_item_barcode': {
|
||||
'Item': {'fields': ['barcode']},
|
||||
'Delivery Note': {'delivery_note_details': ['barcode']},
|
||||
'Sales Invoice': {'entries': ['barcode']}
|
||||
},
|
||||
'fs_item_group_in_details': {
|
||||
'Delivery Note': {'delivery_note_details':['item_group']},
|
||||
'Opportunity': {'enquiry_details':['item_group']},
|
||||
|
@ -122,6 +122,9 @@ class DocType(TransactionBase):
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
|
||||
def get_barcode_details(self, barcode):
|
||||
return get_obj('Sales Common').get_barcode_details(barcode)
|
||||
|
||||
|
||||
# *** Re-calculates Basic Rate & amount based on Price List Selected ***
|
||||
def get_adj_percent(self, arg=''):
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:29',
|
||||
'creation': '2012-04-13 11:56:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:29',
|
||||
'modified': '2012-06-07 17:57:14',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -23,7 +23,7 @@
|
||||
'section_style': u'Tray',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 56
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -41,6 +41,16 @@
|
||||
'name': u'Delivery Note Item'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'barcode',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Barcode',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
|
@ -127,6 +127,12 @@ class DocType:
|
||||
if bom and bom[0][0]:
|
||||
msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(check), cstr(self.doc.name)))
|
||||
raise Exception
|
||||
|
||||
def validate_barcode(self):
|
||||
if self.doc.barcode:
|
||||
duplicate = sql("select name from tabItem where barcode = %s and name != %s", (self.doc.barcode, self.doc.name))
|
||||
if duplicate:
|
||||
msgprint("Barcode: %s already used in item: %s" % (self.doc.barcode, cstr(duplicate[0][0])), raise_exception = 1)
|
||||
|
||||
def validate(self):
|
||||
fl = {'is_manufactured_item' :'Is Manufactured Item',
|
||||
@ -139,6 +145,7 @@ class DocType:
|
||||
self.check_ref_rate_detail()
|
||||
self.fill_customer_code()
|
||||
self.check_item_tax()
|
||||
self.validate_barcode()
|
||||
if not self.doc.min_order_qty:
|
||||
self.doc.min_order_qty = 0
|
||||
self.check_non_asset_warehouse()
|
||||
|
@ -5,7 +5,7 @@
|
||||
{
|
||||
'creation': '2012-04-30 18:33:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-31 11:18:10',
|
||||
'modified': '2012-06-07 16:16:24',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -235,6 +235,15 @@
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'barcode',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Barcode',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
|
@ -5,7 +5,7 @@
|
||||
{
|
||||
'creation': '2012-04-13 11:56:36',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-09 14:25:12',
|
||||
'modified': '2012-06-07 18:07:12',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user