Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Anand Doshi 2012-06-08 12:57:28 +05:30
commit fa1963164c
20 changed files with 128 additions and 23 deletions

View File

@ -127,7 +127,7 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/ /*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
cur_frm.fields_dict['purchase_tax_details'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['purchase_tax_details'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type in ("Tax", "Chargeable", "Expense") or (tabAccount.is_pl_account = "Yes" and tabAccount.debit_or_credit = "Debit")) AND tabAccount.company = "' + doc.company + '" AND tabAccount.name LIKE "%s"' return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type in ("Tax", "Chargeable", "Expense Account") or (tabAccount.is_pl_account = "Yes" and tabAccount.debit_or_credit = "Debit")) AND tabAccount.company = "' + doc.company + '" AND tabAccount.name LIKE "%s"'
} }

View File

@ -211,6 +211,9 @@ class DocType(TransactionBase):
ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0 ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
return ret 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 # Fetch ref rate from item master as per selected price list
def get_adj_percent(self, arg=''): def get_adj_percent(self, arg=''):

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2012-03-27 14:35:48', 'creation': '2012-04-13 11:56:18',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-03-27 14:35:48', 'modified': '2012-06-07 19:05:06',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'Administrator' 'owner': u'Administrator'
}, },
@ -22,7 +22,7 @@
'section_style': u'Tray', 'section_style': u'Tray',
'server_code_error': u' ', 'server_code_error': u' ',
'show_in_menu': 0, 'show_in_menu': 0,
'version': 29 'version': 1
}, },
# These values are common for all DocField # These values are common for all DocField
@ -40,6 +40,16 @@
'name': u'Sales Invoice Item' 'name': u'Sales Invoice Item'
}, },
# DocField
{
'doctype': u'DocField',
'fieldname': u'barcode',
'fieldtype': u'Data',
'label': u'Barcode',
'permlevel': 0,
'print_hide': 1
},
# DocField # DocField
{ {
'doctype': u'DocField', 'doctype': u'DocField',

View File

@ -140,7 +140,7 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/ /*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.account_type in ("Tax", "Chargeable", "Income") AND tabAccount.company = "'+doc.company+'" AND tabAccount.name LIKE "%s"' return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.account_type in ("Tax", "Chargeable", "Income Account") AND tabAccount.company = "'+doc.company+'" AND tabAccount.name LIKE "%s"'
} }
cur_frm.fields_dict['other_charges'].grid.get_field("cost_center_other_charges").get_query = function(doc) { cur_frm.fields_dict['other_charges'].grid.get_field("cost_center_other_charges").get_query = function(doc) {

View File

View 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()

View File

@ -0,0 +1,4 @@
def execute():
import webnotes
webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Order Item` t2 set t1.uom = t2.uom where ifnull(t1.po_detail, '') != '' and t1.po_detail = t2.name")
webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Receipt Item` t2 set t1.uom = t2.uom where ifnull(t1.pr_detail, '') != '' and t1.pr_detail = t2.name")

View File

@ -412,4 +412,14 @@ patch_list = [
'patch_file': 'remove_communication_log', 'patch_file': 'remove_communication_log',
'description': 'Remove Communication Log and replace it with Communication' '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'
},
{
'patch_module': 'patches.june_2012',
'patch_file': 'copy_uom_for_pur_inv_item',
'description': 'Copy uom for pur inv item from PO and PR item table'
},
] ]

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2012-05-15 12:14:54', 'creation': '2012-06-04 15:40:56',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-05-18 18:21:08', 'modified': '2012-06-07 17:58:39',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'Administrator' 'owner': u'Administrator'
}, },

View File

@ -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 *************************** // *********************** QUANTITY ***************************
cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); } cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }

View File

@ -128,12 +128,13 @@ class DocType(TransactionBase):
if not obj.doc.price_list_name: if not obj.doc.price_list_name:
msgprint("Please Select Price List before selecting Items") msgprint("Please Select Price List before selecting Items")
raise Exception 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']) tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , args['item_code'])
t = {} t = {}
for x in tax: t[x[0]] = flt(x[1]) for x in tax: t[x[0]] = flt(x[1])
ret = { ret = {
'description' : item and item[0]['description_html'] or item[0]['description'], '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_group' : item and item[0]['item_group'] or '',
'item_name' : item and item[0]['item_name'] or '', 'item_name' : item and item[0]['item_name'] or '',
'brand' : item and item[0]['brand'] or '', 'brand' : item and item[0]['brand'] or '',
@ -172,13 +173,30 @@ class DocType(TransactionBase):
return ret return ret
# ***************** Get Ref rate as entered in Item Master ******************** # ***************** Get Ref rate as entered in Item Master ********************
def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate): def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
ref_rate = webnotes.conn.sql("select ref_rate from `tabItem Price` where parent = %s and price_list_name = %s and ref_currency = %s", (item_code, price_list_name, price_list_currency)) ref_rate = webnotes.conn.sql("select ref_rate from `tabItem Price` where parent = %s and price_list_name = %s and ref_currency = %s", (item_code, price_list_name, price_list_currency))
base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0 base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0
return base_ref_rate 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 ****** # ****** Re-cancellculates Basic Rate & amount based on Price List Selected ******
def get_adj_percent(self, obj): def get_adj_percent(self, obj):

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2012-03-27 14:36:15', 'creation': '2012-04-13 11:56:28',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-03-27 14:36:15', 'modified': '2012-06-07 18:04:52',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'Administrator' 'owner': u'Administrator'
}, },
@ -22,7 +22,7 @@
'section_style': u'Tray', 'section_style': u'Tray',
'server_code_error': u' ', 'server_code_error': u' ',
'show_in_menu': 0, 'show_in_menu': 0,
'version': 54 'version': 1
}, },
# These values are common for all DocField # These values are common for all DocField
@ -68,7 +68,7 @@
'permlevel': 0, 'permlevel': 0,
'print_hide': 1, 'print_hide': 1,
'reqd': 1, 'reqd': 1,
'width': u'150px' 'width': u'150'
}, },
# DocField # DocField

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2012-03-27 14:36:21', 'creation': '2012-04-13 11:56:31',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-03-27 14:36:21', 'modified': '2012-06-07 18:41:50',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'Administrator' 'owner': u'Administrator'
}, },
@ -22,7 +22,7 @@
'name_case': u'Title Case', 'name_case': u'Title Case',
'section_style': u'Simple', 'section_style': u'Simple',
'show_in_menu': 1, 'show_in_menu': 1,
'version': 26 'version': 1
}, },
# These values are common for all DocField # These values are common for all DocField
@ -104,6 +104,15 @@
'label': u'Brands' '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 # DocField
{ {
'doctype': u'DocField', 'doctype': u'DocField',

View File

@ -93,6 +93,11 @@ pscript.feature_dict = {
'Stock Entry': {'mtn_details':['serial_no']}, 'Stock Entry': {'mtn_details':['serial_no']},
'Stock Ledger Entry': {'fields':['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': { 'fs_item_group_in_details': {
'Delivery Note': {'delivery_note_details':['item_group']}, 'Delivery Note': {'delivery_note_details':['item_group']},
'Opportunity': {'enquiry_details':['item_group']}, 'Opportunity': {'enquiry_details':['item_group']},

View File

@ -122,6 +122,9 @@ class DocType(TransactionBase):
if not doc.fields.get(r): if not doc.fields.get(r):
doc.fields[r] = ret[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 *** # *** Re-calculates Basic Rate & amount based on Price List Selected ***
def get_adj_percent(self, arg=''): def get_adj_percent(self, arg=''):

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2012-03-27 14:36:29', 'creation': '2012-04-13 11:56:35',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-03-27 14:36:29', 'modified': '2012-06-07 17:57:14',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'Administrator' 'owner': u'Administrator'
}, },
@ -23,7 +23,7 @@
'section_style': u'Tray', 'section_style': u'Tray',
'server_code_error': u' ', 'server_code_error': u' ',
'show_in_menu': 0, 'show_in_menu': 0,
'version': 56 'version': 1
}, },
# These values are common for all DocField # These values are common for all DocField
@ -41,6 +41,16 @@
'name': u'Delivery Note Item' 'name': u'Delivery Note Item'
}, },
# DocField
{
'doctype': u'DocField',
'fieldname': u'barcode',
'fieldtype': u'Data',
'label': u'Barcode',
'permlevel': 0,
'print_hide': 1
},
# DocField # DocField
{ {
'doctype': u'DocField', 'doctype': u'DocField',

View File

@ -128,6 +128,12 @@ class DocType:
msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(check), cstr(self.doc.name))) msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(check), cstr(self.doc.name)))
raise Exception 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): def validate(self):
fl = {'is_manufactured_item' :'Is Manufactured Item', fl = {'is_manufactured_item' :'Is Manufactured Item',
'is_sub_contracted_item':'Is Sub Contracted Item', 'is_sub_contracted_item':'Is Sub Contracted Item',
@ -139,6 +145,7 @@ class DocType:
self.check_ref_rate_detail() self.check_ref_rate_detail()
self.fill_customer_code() self.fill_customer_code()
self.check_item_tax() self.check_item_tax()
self.validate_barcode()
if not self.doc.min_order_qty: if not self.doc.min_order_qty:
self.doc.min_order_qty = 0 self.doc.min_order_qty = 0
self.check_non_asset_warehouse() self.check_non_asset_warehouse()

View File

@ -5,7 +5,7 @@
{ {
'creation': '2012-04-30 18:33:53', 'creation': '2012-04-30 18:33:53',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-05-31 11:18:10', 'modified': '2012-06-07 16:16:24',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'Administrator' 'owner': u'Administrator'
}, },
@ -235,6 +235,15 @@
'reqd': 0 'reqd': 0
}, },
# DocField
{
'doctype': u'DocField',
'fieldname': u'barcode',
'fieldtype': u'Data',
'label': u'Barcode',
'permlevel': 0
},
# DocField # DocField
{ {
'doctype': u'DocField', 'doctype': u'DocField',

View File

@ -5,7 +5,7 @@
{ {
'creation': '2012-04-13 11:56:36', 'creation': '2012-04-13 11:56:36',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-05-09 14:25:12', 'modified': '2012-06-07 18:07:12',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'Administrator' 'owner': u'Administrator'
}, },

File diff suppressed because one or more lines are too long