Merge pull request #3718 from rmehta/item-cleanup

[cleanup] yes/no selects changed to checks in Item
This commit is contained in:
Nabin Hait
2015-07-29 15:49:54 +05:30
59 changed files with 731 additions and 689 deletions

View File

@@ -5,8 +5,8 @@ cur_frm.fields_dict['item'].get_query = function(doc, cdt, cdn) {
return {
query: "erpnext.controllers.queries.item_query",
filters:{
'is_stock_item': 'Yes',
'has_batch_no': 'Yes'
'is_stock_item': 1,
'has_batch_no': 1
}
}
}
}

View File

@@ -7,10 +7,10 @@ from frappe import _
from frappe.model.document import Document
class Batch(Document):
def validate(self):
self.item_has_batch_enabled()
def item_has_batch_enabled(self):
if frappe.db.get_value("Item",self.item,"has_batch_no") =='No':
if frappe.db.get_value("Item",self.item,"has_batch_no") == 0:
frappe.throw(_("The selected item cannot have Batch"))

View File

@@ -108,7 +108,7 @@ class DeliveryNote(SellingController):
if not self.installation_status: self.installation_status = 'Not Installed'
def validate_with_previous_doc(self):
for fn in (("Sales Order", "against_sales_order", "so_detail"),
for fn in (("Sales Order", "against_sales_order", "so_detail"),
("Sales Invoice", "against_sales_invoice", "si_detail")):
if filter(None, [getattr(d, fn[1], None) for d in self.get("items")]):
super(DeliveryNote, self).validate_with_previous_doc({
@@ -118,9 +118,9 @@ class DeliveryNote(SellingController):
["currency", "="]],
},
})
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
self.validate_rate_with_reference_doc([["Sales Order", "sales_order", "so_detail"],
self.validate_rate_with_reference_doc([["Sales Order", "sales_order", "so_detail"],
["Sales Invoice", "sales_invoice", "si_detail"]])
def validate_proj_cust(self):
@@ -138,7 +138,7 @@ class DeliveryNote(SellingController):
e = [d.item_code, d.description, d.warehouse, d.against_sales_order or d.against_sales_invoice, d.batch_no or '']
f = [d.item_code, d.description, d.against_sales_order or d.against_sales_invoice]
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1:
if e in check_list:
msgprint(_("Note: Item {0} entered multiple times").format(d.item_code))
else:
@@ -151,7 +151,7 @@ class DeliveryNote(SellingController):
def validate_warehouse(self):
for d in self.get_item_list():
if frappe.db.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
if frappe.db.get_value("Item", d['item_code'], "is_stock_item") == 1:
if not d['warehouse']:
frappe.throw(_("Warehouse required for stock Item {0}").format(d["item_code"]))
@@ -247,7 +247,7 @@ class DeliveryNote(SellingController):
def update_stock_ledger(self):
sl_entries = []
for d in self.get_item_list():
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 \
and d.warehouse and flt(d['qty']):
self.update_reserved_qty(d)

View File

@@ -43,7 +43,7 @@ frappe.ui.form.on("Item", {
erpnext.item.edit_prices_button(frm);
if (!frm.doc.__islocal && frm.doc.is_stock_item == 'Yes') {
if (!frm.doc.__islocal && frm.doc.is_stock_item) {
frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method', 'has_batch_no'],
(frm.doc.__onload && frm.doc.__onload.sle_exists=="exists") ? false : true);
}
@@ -80,11 +80,11 @@ frappe.ui.form.on("Item", {
method: "copy_specification_from_item_group"
});
},
is_stock_item: function(frm) {
erpnext.item.toggle_reqd(frm);
},
manage_variants: function(frm) {
if (cur_frm.doc.__unsaved==1) {
frappe.throw(__("You have unsaved changes. Please save."))
@@ -168,7 +168,7 @@ $.extend(erpnext.item, {
},
toggle_reqd: function(frm) {
frm.toggle_reqd("default_warehouse", frm.doc.is_stock_item==="Yes");
frm.toggle_reqd("default_warehouse", frm.doc.is_stock_item);
},
make_dashboard: function(frm) {

View File

@@ -28,7 +28,7 @@
"read_only": 0
},
{
"description": "Item will be saved by this name in the data base.",
"description": "",
"fieldname": "item_code",
"fieldtype": "Data",
"in_filter": 0,
@@ -80,7 +80,7 @@
"reqd": 1
},
{
"description": "Unit of measurement of this item (e.g. Kg, Unit, No, Pair).",
"description": "",
"fieldname": "stock_uom",
"fieldtype": "Link",
"ignore_user_permissions": 1,
@@ -113,17 +113,6 @@
"permlevel": 0,
"read_only": 0
},
{
"default": "2099-12-31",
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"fieldname": "end_of_life",
"fieldtype": "Date",
"label": "End of Life",
"oldfieldname": "end_of_life",
"oldfieldtype": "Date",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
@@ -166,11 +155,233 @@
"reqd": 1,
"search_index": 0
},
{
"fieldname": "inventory",
"fieldtype": "Section Break",
"label": "Inventory",
"oldfieldtype": "Section Break",
"options": "icon-truck",
"permlevel": 0,
"read_only": 0
},
{
"default": "1",
"description": "",
"fieldname": "is_stock_item",
"fieldtype": "Check",
"label": "Maintain Stock",
"oldfieldname": "is_stock_item",
"oldfieldtype": "Select",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"default": "",
"depends_on": "eval:doc.is_stock_item",
"fieldname": "has_batch_no",
"fieldtype": "Check",
"label": "Has Batch No",
"oldfieldname": "has_batch_no",
"oldfieldtype": "Select",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"default": "",
"depends_on": "eval:doc.is_stock_item",
"description": "Selecting \"Yes\" will give a unique identity to each entity of this item which can be viewed in the Serial No master.",
"fieldname": "has_serial_no",
"fieldtype": "Check",
"in_filter": 1,
"label": "Has Serial No",
"oldfieldname": "has_serial_no",
"oldfieldtype": "Select",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "has_serial_no",
"description": "Example: ABCD.#####\nIf series is set and Serial No is not mentioned in transactions, then automatic serial number will be created based on this series. If you always want to explicitly mention Serial Nos for this item. leave this blank.",
"fieldname": "serial_no_series",
"fieldtype": "Data",
"label": "Serial Number Series",
"no_copy": 0,
"permlevel": 0
},
{
"default": "",
"depends_on": "eval:doc.is_stock_item",
"description": "",
"fieldname": "is_asset_item",
"fieldtype": "Check",
"label": "Is Fixed Asset Item",
"oldfieldname": "is_asset_item",
"oldfieldtype": "Select",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "is_stock_item",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"width": "50%"
},
{
"depends_on": "",
"description": "",
"fieldname": "default_warehouse",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Warehouse",
"oldfieldname": "default_warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "is_stock_item",
"description": "",
"fieldname": "tolerance",
"fieldtype": "Float",
"label": "Allow over delivery or receipt upto this percent",
"oldfieldname": "tolerance",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "is_stock_item",
"fieldname": "valuation_method",
"fieldtype": "Select",
"label": "Valuation Method",
"options": "\nFIFO\nMoving Average",
"permlevel": 0,
"read_only": 0
},
{
"default": "0.00",
"depends_on": "is_stock_item",
"description": "",
"fieldname": "min_order_qty",
"fieldtype": "Float",
"hidden": 0,
"label": "Minimum Order Qty",
"oldfieldname": "min_order_qty",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item",
"fieldname": "warranty_period",
"fieldtype": "Data",
"label": "Warranty Period (in days)",
"oldfieldname": "warranty_period",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0
},
{
"default": "2099-12-31",
"depends_on": "is_stock_item",
"fieldname": "end_of_life",
"fieldtype": "Date",
"label": "End of Life",
"oldfieldname": "end_of_life",
"oldfieldtype": "Date",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "is_stock_item",
"description": "",
"fieldname": "net_weight",
"fieldtype": "Float",
"label": "Net Weight",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item",
"fieldname": "weight_uom",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Weight UOM",
"options": "UOM",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item",
"description": "",
"fieldname": "reorder_section",
"fieldtype": "Section Break",
"label": "Auto re-order",
"options": "icon-rss",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:(doc.is_stock_item && !doc.apply_warehouse_wise_reorder_level)",
"description": "Automatically create Material Request if quantity falls below this level",
"fieldname": "re_order_level",
"fieldtype": "Float",
"label": "Re-order Level",
"oldfieldname": "re_order_level",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:(doc.is_stock_item && !doc.apply_warehouse_wise_reorder_level)",
"fieldname": "re_order_qty",
"fieldtype": "Float",
"label": "Re-order Qty",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "is_stock_item",
"fieldname": "apply_warehouse_wise_reorder_level",
"fieldtype": "Check",
"label": "Apply Warehouse-wise Reorder Level",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "eval:(doc.is_stock_item && doc.apply_warehouse_wise_reorder_level)",
"fieldname": "section_break_31",
"fieldtype": "Section Break",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:(doc.is_stock_item && doc.apply_warehouse_wise_reorder_level)",
"description": "Will also apply for variants unless overrridden",
"fieldname": "reorder_levels",
"fieldtype": "Table",
"label": "Warehouse-wise Reorder Levels",
"options": "Item Reorder",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:!doc.variant_of",
"fieldname": "variants_section",
"fieldtype": "Section Break",
"label": "Variant",
"label": "Variants",
"permlevel": 0,
"precision": ""
},
@@ -219,253 +430,34 @@
"precision": "",
"read_only": 1
},
{
"fieldname": "inventory",
"fieldtype": "Section Break",
"label": "Inventory",
"oldfieldtype": "Section Break",
"options": "icon-truck",
"permlevel": 0,
"read_only": 0
},
{
"default": "Yes",
"description": "Select \"Yes\" if you are maintaining stock of this item in your Inventory.",
"fieldname": "is_stock_item",
"fieldtype": "Select",
"label": "Is Stock Item",
"oldfieldname": "is_stock_item",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "",
"description": "Mandatory if Stock Item is \"Yes\". Also the default warehouse where reserved quantity is set from Sales Order.",
"fieldname": "default_warehouse",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Warehouse",
"oldfieldname": "default_warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "Percentage variation in quantity to be allowed while receiving or delivering this item.",
"fieldname": "tolerance",
"fieldtype": "Float",
"label": "Allowance Percent",
"oldfieldname": "tolerance",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"fieldname": "valuation_method",
"fieldtype": "Select",
"label": "Valuation Method",
"options": "\nFIFO\nMoving Average",
"permlevel": 0,
"read_only": 0
},
{
"default": "0.00",
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "You can enter the minimum quantity of this item to be ordered.",
"fieldname": "min_order_qty",
"fieldtype": "Float",
"hidden": 0,
"label": "Minimum Order Qty",
"oldfieldname": "min_order_qty",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"width": "50%"
},
{
"default": "No",
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "Select \"Yes\" if this item is used for some internal purpose in your company.",
"fieldname": "is_asset_item",
"fieldtype": "Select",
"label": "Is Fixed Asset Item",
"oldfieldname": "is_asset_item",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"default": "No",
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"fieldname": "has_batch_no",
"fieldtype": "Select",
"label": "Has Batch No",
"oldfieldname": "has_batch_no",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"default": "No",
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "Selecting \"Yes\" will give a unique identity to each entity of this item which can be viewed in the Serial No master.",
"fieldname": "has_serial_no",
"fieldtype": "Select",
"in_filter": 1,
"label": "Has Serial No",
"oldfieldname": "has_serial_no",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "eval: doc.has_serial_no===\"Yes\"",
"description": "Example: ABCD.#####\nIf series is set and Serial No is not mentioned in transactions, then automatic serial number will be created based on this series. If you always want to explicitly mention Serial Nos for this item. leave this blank.",
"fieldname": "serial_no_series",
"fieldtype": "Data",
"label": "Serial Number Series",
"no_copy": 0,
"permlevel": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"fieldname": "warranty_period",
"fieldtype": "Data",
"label": "Warranty Period (in days)",
"oldfieldname": "warranty_period",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "Net Weight of each Item",
"fieldname": "net_weight",
"fieldtype": "Float",
"label": "Net Weight",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"fieldname": "weight_uom",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Weight UOM",
"options": "UOM",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "Auto-raise Material Request if quantity goes below re-order level in default warehouse",
"fieldname": "reorder_section",
"fieldtype": "Section Break",
"label": "Re-order",
"options": "icon-rss",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:(doc.is_stock_item==\"Yes\" && !doc.apply_warehouse_wise_reorder_level)",
"fieldname": "re_order_level",
"fieldtype": "Float",
"label": "Re-Order Level",
"oldfieldname": "re_order_level",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:(doc.is_stock_item==\"Yes\" && !doc.apply_warehouse_wise_reorder_level)",
"fieldname": "re_order_qty",
"fieldtype": "Float",
"label": "Re-Order Qty",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"fieldname": "apply_warehouse_wise_reorder_level",
"fieldtype": "Check",
"label": "Apply Warehouse-wise Reorder Level",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "eval:(doc.is_stock_item==\"Yes\" && doc.apply_warehouse_wise_reorder_level)",
"fieldname": "section_break_31",
"fieldtype": "Section Break",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:(doc.is_stock_item==\"Yes\" && doc.apply_warehouse_wise_reorder_level)",
"description": "Will also apply for variants unless overrridden",
"fieldname": "reorder_levels",
"fieldtype": "Table",
"label": "Warehouse-wise Reorder Levels",
"options": "Item Reorder",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "purchase_details",
"fieldtype": "Section Break",
"label": "",
"label": "Purchase Details",
"oldfieldtype": "Section Break",
"options": "icon-shopping-cart",
"permlevel": 0,
"read_only": 0
},
{
"default": "Yes",
"description": "Selecting \"Yes\" will allow this item to appear in Purchase Order , Purchase Receipt.",
"default": "1",
"description": "",
"fieldname": "is_purchase_item",
"fieldtype": "Select",
"fieldtype": "Check",
"label": "Is Purchase Item",
"oldfieldname": "is_purchase_item",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"fieldname": "default_supplier",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Supplier",
"options": "Supplier",
"permlevel": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"description": "Lead Time days is number of days by which this item is expected in your warehouse. This days is fetched in Material Request when you select this item.",
"depends_on": "is_purchase_item",
"description": "Average time taken by the supplier to deliver",
"fieldname": "lead_time_days",
"fieldtype": "Int",
"label": "Lead Time Days",
"label": "Lead Time in days",
"no_copy": 0,
"oldfieldname": "lead_time_days",
"oldfieldtype": "Int",
@@ -473,20 +465,7 @@
"read_only": 0
},
{
"depends_on": "",
"description": "Default Purchase Account in which cost of the item will be debited.",
"fieldname": "expense_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Expense Account",
"oldfieldname": "purchase_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "",
"depends_on": "is_purchase_item",
"description": "",
"fieldname": "buying_cost_center",
"fieldtype": "Link",
@@ -499,27 +478,28 @@
"read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"fieldname": "last_purchase_rate",
"fieldtype": "Float",
"label": "Last Purchase Rate",
"no_copy": 1,
"oldfieldname": "last_purchase_rate",
"oldfieldtype": "Currency",
"depends_on": "is_purchase_item",
"description": "",
"fieldname": "expense_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Expense Account",
"oldfieldname": "purchase_account",
"oldfieldtype": "Link",
"options": "Account",
"permlevel": 0,
"read_only": 1
"read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"fieldname": "column_break2",
"depends_on": "is_purchase_item",
"fieldname": "unit_of_measure_conversion",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"label": "Unit of Measure Conversion",
"permlevel": 0,
"read_only": 0,
"width": "50%"
"precision": ""
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"depends_on": "is_purchase_item",
"description": "Will also apply for variants",
"fieldname": "uoms",
"fieldtype": "Table",
@@ -532,7 +512,35 @@
"read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"depends_on": "is_purchase_item",
"fieldname": "last_purchase_rate",
"fieldtype": "Float",
"label": "Last Purchase Rate",
"no_copy": 1,
"oldfieldname": "last_purchase_rate",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 1
},
{
"depends_on": "is_purchase_item",
"fieldname": "supplier_details",
"fieldtype": "Section Break",
"label": "Supplier Details",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "eval:doc.is_purchase_item",
"fieldname": "default_supplier",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"label": "Default Supplier",
"options": "Supplier",
"permlevel": 0
},
{
"depends_on": "eval:doc.is_purchase_item",
"fieldname": "manufacturer",
"fieldtype": "Data",
"label": "Manufacturer",
@@ -540,7 +548,7 @@
"read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"depends_on": "eval:doc.is_purchase_item",
"fieldname": "manufacturer_part_no",
"fieldtype": "Data",
"label": "Manufacturer Part Number",
@@ -548,7 +556,17 @@
"read_only": 0
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"depends_on": "is_purchase_item",
"fieldname": "column_break2",
"fieldtype": "Column Break",
"label": "Item Code for Suppliers",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"width": "50%"
},
{
"depends_on": "is_purchase_item",
"fieldname": "supplier_items",
"fieldtype": "Table",
"label": "Supplier Items",
@@ -566,30 +584,30 @@
"read_only": 0
},
{
"default": "Yes",
"description": "Selecting \"Yes\" will allow this item to figure in Sales Order, Delivery Note",
"default": "1",
"description": "",
"fieldname": "is_sales_item",
"fieldtype": "Select",
"fieldtype": "Check",
"in_filter": 1,
"label": "Is Sales Item",
"oldfieldname": "is_sales_item",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"default": "No",
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
"description": "Select \"Yes\" if this item represents some work like training, designing, consulting etc.",
"default": "",
"depends_on": "eval:doc.is_sales_item",
"description": "Allow in Sales Order of type \"Service\"",
"fieldname": "is_service_item",
"fieldtype": "Select",
"fieldtype": "Check",
"in_filter": 1,
"label": "Is Service Item",
"oldfieldname": "is_service_item",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
@@ -614,17 +632,7 @@
"precision": ""
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
"fieldname": "max_discount",
"fieldtype": "Float",
"label": "Max Discount (%)",
"oldfieldname": "max_discount",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
"depends_on": "is_sales_item",
"fieldname": "income_account",
"fieldtype": "Link",
"ignore_user_permissions": 1,
@@ -634,7 +642,7 @@
"read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
"depends_on": "is_sales_item",
"fieldname": "selling_cost_center",
"fieldtype": "Link",
"ignore_user_permissions": 1,
@@ -644,17 +652,18 @@
"read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
"depends_on": "is_sales_item",
"fieldname": "column_break3",
"fieldtype": "Column Break",
"label": "Customer Item Codes",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0,
"width": "50%"
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
"description": "For the convenience of customers, these codes can be used in print formats like Invoices and Delivery Notes",
"depends_on": "is_sales_item",
"description": "",
"fieldname": "customer_items",
"fieldtype": "Table",
"label": "Customer Items",
@@ -662,6 +671,16 @@
"permlevel": 0,
"read_only": 0
},
{
"depends_on": "eval:doc.is_sales_item",
"fieldname": "max_discount",
"fieldtype": "Float",
"label": "Max Discount (%)",
"oldfieldname": "max_discount",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "item_tax_section_break",
"fieldtype": "Section Break",
@@ -692,20 +711,20 @@
"read_only": 0
},
{
"default": "No",
"default": "",
"fieldname": "inspection_required",
"fieldtype": "Select",
"fieldtype": "Check",
"label": "Inspection Required",
"no_copy": 0,
"oldfieldname": "inspection_required",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"depends_on": "eval:doc.inspection_required==\"Yes\"",
"depends_on": "inspection_required",
"description": "Will also apply to variants",
"fieldname": "quality_parameters",
"fieldtype": "Table",
@@ -725,6 +744,39 @@
"permlevel": 0,
"read_only": 0
},
{
"default": "",
"depends_on": "",
"description": "",
"fieldname": "is_pro_applicable",
"fieldtype": "Check",
"label": "Allow Production Order",
"oldfieldname": "is_pro_applicable",
"oldfieldtype": "Select",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"default": "",
"description": "If subcontracted to a vendor",
"fieldname": "is_sub_contracted_item",
"fieldtype": "Check",
"label": "Supply Raw Materials for Purchase",
"oldfieldname": "is_sub_contracted_item",
"oldfieldtype": "Select",
"options": "",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "column_break_74",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "",
"fieldname": "default_bom",
@@ -738,33 +790,6 @@
"permlevel": 0,
"read_only": 1
},
{
"default": "No",
"depends_on": "",
"description": "Selecting \"Yes\" will allow you to make a Production Order for this item.",
"fieldname": "is_pro_applicable",
"fieldtype": "Select",
"label": "Allow Production Order",
"oldfieldname": "is_pro_applicable",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"default": "No",
"description": "",
"fieldname": "is_sub_contracted_item",
"fieldtype": "Select",
"label": "Supply Raw Materials for Purchase",
"oldfieldname": "is_sub_contracted_item",
"oldfieldtype": "Select",
"options": "Yes\nNo",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "customer_code",
"fieldtype": "Data",
@@ -803,7 +828,7 @@
},
{
"depends_on": "show_in_website",
"description": "Products will be sorted by weight-age in default searches. More the weight-age, higher the product will appear in the list.",
"description": "Items with higher weightage will be shown higher",
"fieldname": "weightage",
"fieldtype": "Int",
"label": "Weightage",
@@ -865,6 +890,13 @@
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "website_specifications_cb",
"fieldtype": "Column Break",
"label": "Website Specifications",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "show_in_website",
"fieldname": "copy_from_item_group",
@@ -903,7 +935,7 @@
"icon": "icon-tag",
"idx": 1,
"max_attachments": 1,
"modified": "2015-07-13 05:28:28.698107",
"modified": "2015-07-24 06:04:28.448050",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",

View File

@@ -87,7 +87,7 @@ class Item(WebsiteGenerator):
return context
def check_warehouse_is_set_for_stock_item(self):
if self.is_stock_item=="Yes" and not self.default_warehouse and frappe.get_all("Warehouse"):
if self.is_stock_item==1 and not self.default_warehouse and frappe.get_all("Warehouse"):
frappe.msgprint(_("Default Warehouse is mandatory for stock Item."),
raise_exception=WarehouseNotSet)
@@ -158,13 +158,13 @@ class Item(WebsiteGenerator):
frappe.throw(_("Conversion factor for default Unit of Measure must be 1 in row {0}").format(d.idx))
def validate_item_type(self):
if self.is_pro_applicable == 'Yes' and self.is_stock_item == 'No':
if self.is_pro_applicable == 1 and self.is_stock_item==0:
frappe.throw(_("As Production Order can be made for this item, it must be a stock item."))
if self.has_serial_no == 'Yes' and self.is_stock_item == 'No':
if self.has_serial_no == 1 and self.is_stock_item == 0:
msgprint(_("'Has Serial No' can not be 'Yes' for non-stock item"), raise_exception=1)
if self.has_serial_no == "No" and self.serial_no_series:
if self.has_serial_no == 0 and self.serial_no_series:
self.serial_no_series = None
@@ -208,7 +208,7 @@ class Item(WebsiteGenerator):
vals = frappe.db.get_value("Item", self.name,
["has_serial_no", "is_stock_item", "valuation_method", "has_batch_no"], as_dict=True)
if vals and ((self.is_stock_item == "No" and vals.is_stock_item == "Yes") or
if vals and ((self.is_stock_item == 0 and vals.is_stock_item == 1) or
vals.has_serial_no != self.has_serial_no or
vals.has_batch_no != self.has_batch_no or
cstr(vals.valuation_method) != cstr(self.valuation_method)):
@@ -313,11 +313,11 @@ class Item(WebsiteGenerator):
def update_item_desc(self):
if frappe.db.get_value('BOM',self.name, 'description') != self.description:
frappe.db.sql("""update `tabBOM` set description = %s where item = %s and docstatus < 2""",(self.description, self.name))
frappe.db.sql("""update `tabBOM Item` set description = %s where
frappe.db.sql("""update `tabBOM Item` set description = %s where
item_code = %s and docstatus < 2""",(self.description, self.name))
frappe.db.sql("""update `tabBOM Explosion Item` set description = %s where
frappe.db.sql("""update `tabBOM Explosion Item` set description = %s where
item_code = %s and docstatus < 2""",(self.description, self.name))
def update_variants(self):
if self.has_variants:
updated = []
@@ -327,7 +327,7 @@ class Item(WebsiteGenerator):
updated.append(d.item_code)
if updated:
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
def validate_has_variants(self):
if not self.has_variants and frappe.db.get_value("Item", self.name, "has_variants"):
if frappe.db.exists("Item", {"variant_of": self.name}):
@@ -336,11 +336,11 @@ class Item(WebsiteGenerator):
def validate_stock_for_template_must_be_zero(self):
if self.has_variants:
stock_in = frappe.db.sql_list("""select warehouse from tabBin
where item_code=%s and (ifnull(actual_qty, 0) > 0 or ifnull(ordered_qty, 0) > 0
where item_code=%s and (ifnull(actual_qty, 0) > 0 or ifnull(ordered_qty, 0) > 0
or ifnull(reserved_qty, 0) > 0 or ifnull(indented_qty, 0) > 0 or ifnull(planned_qty, 0) > 0)""", self.name)
if stock_in:
frappe.throw(_("Item Template cannot have stock or Open Sales/Purchase/Production Orders."), ItemTemplateCannotHaveStock)
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
if not end_of_life:
end_of_life = frappe.db.get_value("Item", item_code, "end_of_life")
@@ -353,7 +353,7 @@ def validate_is_stock_item(item_code, is_stock_item=None, verbose=1):
if not is_stock_item:
is_stock_item = frappe.db.get_value("Item", item_code, "is_stock_item")
if is_stock_item != "Yes":
if is_stock_item != 1:
msg = _("Item {0} is not a stock Item").format(item_code)
_msgprint(msg, verbose)
@@ -445,4 +445,3 @@ def invalidate_cache_for_item(doc):
if doc.get("old_item_group") and doc.get("old_item_group") != doc.item_group:
invalidate_cache_for(doc, doc.old_item_group)

View File

@@ -21,16 +21,16 @@ class TestItem(unittest.TestCase):
else:
item = frappe.get_doc("Item", item_code)
return item
def test_template_cannot_have_stock(self):
item = self.get_item(10)
se = make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, incoming_rate=1)
make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, incoming_rate=1)
item.has_variants = 1
self.assertRaises(ItemTemplateCannotHaveStock, item.save)
def test_default_warehouse(self):
item = frappe.copy_doc(test_records[0])
item.is_stock_item = "Yes"
item.is_stock_item = 1
item.default_warehouse = None
self.assertRaises(WarehouseNotSet, item.insert)

View File

@@ -5,17 +5,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "No",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item",
"item_group": "_Test Item Group",
"item_name": "_Test Item",
@@ -38,17 +38,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "No",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item 2",
"item_group": "_Test Item Group",
"item_name": "_Test Item 2",
@@ -62,17 +62,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "No",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item Home Desktop 100",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop 100",
@@ -92,17 +92,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "No",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item Home Desktop 200",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop 200",
@@ -113,17 +113,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "No",
"is_sub_contracted_item": "No",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 0,
"is_sub_contracted_item": 0,
"item_code": "_Test Product Bundle Item",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Product Bundle Item",
@@ -135,17 +135,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "Yes",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "Yes",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 1,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 1,
"item_code": "_Test FG Item",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test FG Item",
@@ -154,16 +154,16 @@
{
"description": "_Test Non Stock Item 7",
"doctype": "Item",
"has_batch_no": "No",
"has_serial_no": "No",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "No",
"is_sub_contracted_item": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 0,
"is_sub_contracted_item": 0,
"item_code": "_Test Non Stock Item",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Non Stock Item",
@@ -173,16 +173,16 @@
"default_warehouse": "_Test Warehouse - _TC",
"description": "_Test Serialized Item 8",
"doctype": "Item",
"has_batch_no": "No",
"has_serial_no": "Yes",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "No",
"has_batch_no": 0,
"has_serial_no": 1,
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Serialized Item",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Serialized Item",
@@ -192,16 +192,16 @@
"default_warehouse": "_Test Warehouse - _TC",
"description": "_Test Serialized Item 9",
"doctype": "Item",
"has_batch_no": "No",
"has_serial_no": "Yes",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "No",
"has_batch_no": 0,
"has_serial_no": 1,
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 0,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Serialized Item With Series",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Serialized Item With Series",
@@ -214,16 +214,16 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "No",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item Home Desktop Manufactured",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop Manufactured",
@@ -235,17 +235,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "Yes",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "Yes",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 1,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 1,
"item_code": "_Test FG Item 2",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test FG Item 2",
@@ -257,17 +257,17 @@
"doctype": "Item",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center - _TC",
"has_batch_no": "No",
"has_serial_no": "No",
"has_batch_no": 0,
"has_serial_no": 0,
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "Yes",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"is_stock_item": "Yes",
"is_sub_contracted_item": "Yes",
"inspection_required": 0,
"is_asset_item": 0,
"is_pro_applicable": 1,
"is_purchase_item": 1,
"is_sales_item": 1,
"is_service_item": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 1,
"item_code": "_Test Variant Item",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Variant Item",

View File

@@ -15,7 +15,7 @@ class LandedCostVoucher(Document):
pr_items = frappe.db.sql("""select pr_item.item_code, pr_item.description,
pr_item.qty, pr_item.base_rate, pr_item.base_amount, pr_item.name
from `tabPurchase Receipt Item` pr_item where parent = %s
and exists(select name from tabItem where name = pr_item.item_code and is_stock_item = 'Yes')""",
and exists(select name from tabItem where name = pr_item.item_code and is_stock_item = 1)""",
pr.purchase_receipt, as_dict=True)
for d in pr_items:
@@ -69,7 +69,7 @@ class LandedCostVoucher(Document):
def set_applicable_charges_for_item(self):
based_on = self.distribute_charges_based_on.lower()
total = sum([flt(d.get(based_on)) for d in self.get("items")])
if not total:
frappe.throw(_("Total {0} for all items is zero, may you should change 'Distribute Charges Based On'").format(based_on))

View File

@@ -152,7 +152,7 @@ class MaterialRequest(BuyingController):
item_wh_list = []
for d in self.get("items"):
if (not mr_item_rows or d.name in mr_item_rows) and [d.item_code, d.warehouse] not in item_wh_list \
and frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes" and d.warehouse:
and frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 and d.warehouse:
item_wh_list.append([d.item_code, d.warehouse])
for item_code, warehouse in item_wh_list:

View File

@@ -198,10 +198,7 @@ class PurchaseReceipt(BuyingController):
def validate_inspection(self):
for d in self.get('items'): #Enter inspection date for all items that require inspection
ins_reqd = frappe.db.sql("select inspection_required from `tabItem` where name = %s",
(d.item_code,), as_dict = 1)
ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No'
if ins_reqd == 'Yes' and not d.qa_no:
if frappe.db.get_value("Item", d.item_code, "inspection_required") and not d.qa_no:
frappe.msgprint(_("Quality Inspection required for Item {0}").format(d.item_code))
if self.docstatus==1:
raise frappe.ValidationError

View File

@@ -11,7 +11,7 @@ cur_frm.add_fetch("item_code", "brand", "brand")
cur_frm.cscript.onload = function() {
cur_frm.set_query("item_code", function() {
return erpnext.queries.item({"is_stock_item": "Yes", "has_serial_no": "Yes"})
return erpnext.queries.item({"is_stock_item": 1, "has_serial_no": 1})
});
};

View File

@@ -66,7 +66,7 @@ class SerialNo(StockController):
Validate whether serial no is required for this item
"""
item = frappe.get_doc("Item", self.item_code)
if item.has_serial_no!="Yes":
if item.has_serial_no!=1:
frappe.throw(_("Item {0} is not setup for Serial Nos. Check Item master").format(self.item_code))
self.item_group = item.item_group
@@ -198,7 +198,7 @@ def process_serial_no(sle):
update_serial_nos(sle, item_det)
def validate_serial_no(sle, item_det):
if item_det.has_serial_no=="No":
if item_det.has_serial_no==0:
if sle.serial_no:
frappe.throw(_("Item {0} is not setup for Serial Nos. Column must be blank").format(sle.item_code),
SerialNoNotRequiredError)
@@ -246,7 +246,7 @@ def validate_serial_no(sle, item_det):
def update_serial_nos(sle, item_det):
if sle.is_cancelled == "No" and not sle.serial_no and sle.actual_qty > 0 \
and item_det.has_serial_no == "Yes" and item_det.serial_no_series:
and item_det.has_serial_no == 1 and item_det.serial_no_series:
from frappe.model.naming import make_autoname
serial_nos = []
for i in xrange(cint(sle.actual_qty)):

View File

@@ -7,7 +7,7 @@ frappe.provide("erpnext.stock");
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
setup: function() {
var me = this;
this.frm.fields_dict.bom_no.get_query = function() {
return {
filters:{ 'docstatus': 1 }
@@ -15,7 +15,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
};
this.frm.fields_dict.items.grid.get_field('item_code').get_query = function() {
return erpnext.queries.item({is_stock_item: "Yes"});
return erpnext.queries.item({is_stock_item: 1});
};
this.frm.set_query("purchase_order", function() {
@@ -252,13 +252,13 @@ cur_frm.fields_dict['items'].grid.get_field('batch_no').get_query = function(doc
var filters = {
'item_code': item.item_code,
'posting_date': me.frm.doc.posting_date || nowdate()
}
}
} else {
var filters = {
'item_code': item.item_code
}
}
if(item.s_warehouse) filters["warehouse"] = item.s_warehouse
return {

View File

@@ -354,12 +354,12 @@ class StockEntry(StockController):
if d.bom_no and flt(d.transfer_qty) != flt(self.fg_completed_qty):
frappe.throw(_("Quantity in row {0} ({1}) must be same as manufactured quantity {2}"). \
format(d.idx, d.transfer_qty, self.fg_completed_qty))
if self.production_order and self.purpose == "Manufacture" and d.t_warehouse:
items_with_target_warehouse.append(d.item_code)
if self.production_order and self.purpose == "Manufacture":
production_item = frappe.db.get_value("Production Order",
production_item = frappe.db.get_value("Production Order",
self.production_order, "production_item")
if production_item not in items_with_target_warehouse:
frappe.throw(_("Finished Item {0} must be entered for Manufacture type entry")
@@ -427,7 +427,7 @@ class StockEntry(StockController):
(args.get('item_code')), as_dict = 1)
if not item:
frappe.throw(_("Item {0} is not active or end of life has been reached").format(args.get("item_code")))
item = item[0]
ret = {
@@ -642,7 +642,7 @@ class StockEntry(StockController):
mreq_item.warehouse != (item.s_warehouse if self.purpose== "Material Issue" else item.t_warehouse):
frappe.throw(_("Item or Warehouse for row {0} does not match Material Request").format(item.idx),
frappe.MappingMismatchError)
def validate_batch(self):
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]:
for item in self.get("items"):

View File

@@ -64,18 +64,18 @@ class StockLedgerEntry(Document):
item_det = item_det[0]
if item_det.is_stock_item != 'Yes':
if item_det.is_stock_item != 1:
frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))
# check if batch number is required
if self.voucher_type != 'Stock Reconciliation':
if item_det.has_batch_no =='Yes':
if item_det.has_batch_no ==1:
if not self.batch_no:
frappe.throw(_("Batch number is mandatory for Item {0}").format(self.item_code))
elif not frappe.db.get_value("Batch",{"item": self.item_code, "name": self.batch_no}):
frappe.throw(_("{0} is not a valid Batch Number for Item {1}").format(self.batch_no, self.item_code))
elif item_det.has_batch_no =='No' and self.batch_no:
elif item_det.has_batch_no ==0 and self.batch_no:
frappe.throw(_("The Item {0} cannot have Batch").format(self.item_code))
if item_det.has_variants:

View File

@@ -134,12 +134,12 @@ class StockReconciliation(StockController):
validate_is_stock_item(item_code, item.is_stock_item, verbose=0)
# item should not be serialized
if item.has_serial_no == "Yes":
if item.has_serial_no == 1:
raise frappe.ValidationError, _("Serialized Item {0} cannot be updated \
using Stock Reconciliation").format(item_code)
# item managed batch-wise not allowed
if item.has_batch_no == "Yes":
if item.has_batch_no == 1:
raise frappe.ValidationError, _("Item: {0} managed batch-wise, can not be reconciled using \
Stock Reconciliation, instead use Stock Entry").format(item_code)
@@ -243,7 +243,7 @@ class StockReconciliation(StockController):
@frappe.whitelist()
def get_items(warehouse, posting_date, posting_time):
items = frappe.get_list("Item", fields=["name"], filters=
{"is_stock_item": "Yes", "has_serial_no": "No", "has_batch_no": "No"})
{"is_stock_item": 1, "has_serial_no": 0, "has_batch_no": 0})
for item in items:
item.item_code = item.name
item.warehouse = warehouse

View File

@@ -4,7 +4,7 @@
$.extend(cur_frm.cscript, {
onload: function() {
cur_frm.set_query("item_code", function() {
return erpnext.queries.item({"is_stock_item": "Yes"});
return erpnext.queries.item({"is_stock_item": 1});
});
},

View File

@@ -146,7 +146,7 @@ class Warehouse(Document):
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
for item in frappe.db.sql("""select distinct item_code from (
select name as item_code from `tabItem` where ifnull(is_stock_item, 'Yes')='Yes'
select name as item_code from `tabItem` where is_stock_item=1
union
select distinct item_code from tabBin) a"""):
repost_stock(item[0], newdn)

View File

@@ -37,7 +37,6 @@ def get_item_details(args):
item_doc = frappe.get_doc("Item", args.item_code)
item = item_doc
validate_item_details(args, item)
out = get_basic_details(args, item)
@@ -61,7 +60,7 @@ def get_item_details(args):
out.update(get_pricing_rule_for_item(args))
if args.get("parenttype") in ("Sales Invoice", "Delivery Note"):
if item_doc.has_serial_no == "Yes" and not args.serial_no:
if item_doc.has_serial_no == 1 and not args.serial_no:
out.serial_no = get_serial_nos_by_fifo(args, item_doc)
if args.transaction_date and item.lead_time_days:
@@ -119,10 +118,10 @@ def validate_item_details(args, item):
if args.transaction_type == "selling":
# validate if sales item or service item
if args.get("order_type") == "Maintenance":
if item.is_service_item != "Yes":
if item.is_service_item != 1:
throw(_("Item {0} must be a Service Item.").format(item.name))
elif item.is_sales_item != "Yes":
elif item.is_sales_item != 1:
throw(_("Item {0} must be a Sales Item").format(item.name))
if cint(item.has_variants):
@@ -130,10 +129,10 @@ def validate_item_details(args, item):
elif args.transaction_type == "buying" and args.parenttype != "Material Request":
# validate if purchase item or subcontracted item
if item.is_purchase_item != "Yes":
if item.is_purchase_item != 1:
throw(_("Item {0} must be a Purchase Item").format(item.name))
if args.get("is_subcontracted") == "Yes" and item.is_sub_contracted_item != "Yes":
if args.get("is_subcontracted") == "Yes" and item.is_sub_contracted_item != 1:
throw(_("Item {0} must be a Sub-contracted Item").format(item.name))
def get_basic_details(args, item):
@@ -338,7 +337,7 @@ def get_batch_qty(batch_no,warehouse,item_code):
actual_batch_qty = get_actual_batch_qty(batch_no,warehouse,item_code)
if batch_no:
return {'actual_batch_qty': actual_batch_qty}
@frappe.whitelist()
def apply_price_list(args):
"""

View File

@@ -69,7 +69,7 @@ def get_item_warehouse_projected_qty():
from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != ''
and exists (select name from `tabItem`
where `tabItem`.name = `tabBin`.item_code and
is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and
is_stock_item=1 and (is_purchase_item=1 or is_sub_contracted_item=1) and
(ifnull(end_of_life, '0000-00-00')='0000-00-00' or end_of_life > %s))
and exists (select name from `tabWarehouse`
where `tabWarehouse`.name = `tabBin`.warehouse

View File

@@ -1,17 +1,17 @@
{
"apply_user_permissions": 1,
"creation": "2013-08-20 15:08:10",
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2014-06-03 07:18:17.128918",
"modified_by": "Administrator",
"module": "Stock",
"name": "Items To Be Requested",
"owner": "Administrator",
"query": "SELECT\n tabBin.item_code as \"Item:Link/Item:120\",\n tabBin.warehouse as \"Warehouse:Link/Warehouse:120\",\n tabBin.actual_qty as \"Actual:Float:90\",\n tabBin.indented_qty as \"Requested:Float:90\",\n tabBin.reserved_qty as \"Reserved:Float:90\",\n tabBin.ordered_qty as \"Ordered:Float:90\",\n tabBin.projected_qty as \"Projected:Float:90\"\nFROM\n tabBin, tabItem\nWHERE\n tabBin.item_code = tabItem.name\n AND tabItem.is_purchase_item = \"Yes\"\n AND tabBin.projected_qty < 0\nORDER BY\n tabBin.projected_qty ASC",
"ref_doctype": "Item",
"report_name": "Items To Be Requested",
"apply_user_permissions": 1,
"creation": "2013-08-20 15:08:10",
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2014-06-03 07:18:17.128918",
"modified_by": "Administrator",
"module": "Stock",
"name": "Items To Be Requested",
"owner": "Administrator",
"query": "SELECT\n tabBin.item_code as \"Item:Link/Item:120\",\n tabBin.warehouse as \"Warehouse:Link/Warehouse:120\",\n tabBin.actual_qty as \"Actual:Float:90\",\n tabBin.indented_qty as \"Requested:Float:90\",\n tabBin.reserved_qty as \"Reserved:Float:90\",\n tabBin.ordered_qty as \"Ordered:Float:90\",\n tabBin.projected_qty as \"Projected:Float:90\"\nFROM\n tabBin, tabItem\nWHERE\n tabBin.item_code = tabItem.name\n AND tabItem.is_purchase_item = 1\n AND tabBin.projected_qty < 0\nORDER BY\n tabBin.projected_qty ASC",
"ref_doctype": "Item",
"report_name": "Items To Be Requested",
"report_type": "Query Report"
}
}

View File

@@ -18,7 +18,7 @@ def execute(filters=None):
total_qty = total_amount = 0.0
if consumed_details.get(item_code):
for cd in consumed_details.get(item_code):
if (cd.voucher_no not in material_transfer_vouchers):
if cd.voucher_type=="Delivery Note":
delivered_qty += abs(flt(cd.actual_qty))
@@ -40,7 +40,7 @@ def execute(filters=None):
def get_columns(filters):
"""return columns based on filters"""
columns = [_("Item") + ":Link/Item:100"] + [_("Item Name") + "::100"] + \
[_("Description") + "::150"] + [_("UOM") + ":Link/UOM:90"] + \
[_("Consumed Qty") + ":Float:110"] + [_("Consumed Amount") + ":Currency:130"] + \
@@ -64,10 +64,10 @@ def get_consumed_details(filters):
conditions, values = get_conditions(filters)
consumed_details = {}
for d in frappe.db.sql("""select sle.item_code, i.item_name, i.description,
i.stock_uom, sle.actual_qty, sle.stock_value_difference,
for d in frappe.db.sql("""select sle.item_code, i.item_name, i.description,
i.stock_uom, sle.actual_qty, sle.stock_value_difference,
sle.voucher_no, sle.voucher_type
from `tabStock Ledger Entry` sle, `tabItem` i
from `tabStock Ledger Entry` sle, `tabItem` i
where sle.item_code=i.name and sle.actual_qty < 0 %s""" % conditions, values, as_dict=1):
consumed_details.setdefault(d.item_code, []).append(d)
@@ -77,20 +77,20 @@ def get_suppliers_details(filters):
item_supplier_map = {}
supplier = filters.get('supplier')
for d in frappe.db.sql("""select pr.supplier, pri.item_code from
`tabPurchase Receipt` pr, `tabPurchase Receipt Item` pri
where pr.name=pri.parent and pr.docstatus=1 and
pri.item_code=(select name from `tabItem` where
ifnull(is_stock_item, 'Yes')='Yes' and name=pri.item_code)""", as_dict=1):
for d in frappe.db.sql("""select pr.supplier, pri.item_code from
`tabPurchase Receipt` pr, `tabPurchase Receipt Item` pri
where pr.name=pri.parent and pr.docstatus=1 and
pri.item_code=(select name from `tabItem` where
is_stock_item=1 and name=pri.item_code)""", as_dict=1):
item_supplier_map.setdefault(d.item_code, []).append(d.supplier)
if supplier:
for item_code, suppliers in item_supplier_map.items():
if supplier not in suppliers:
del item_supplier_map[item_code]
return item_supplier_map
def get_material_transfer_vouchers():
return frappe.db.sql_list("""select name from `tabStock Entry` where
purpose='Material Transfer' and docstatus=1""")
return frappe.db.sql_list("""select name from `tabStock Entry` where
purpose='Material Transfer' and docstatus=1""")

View File

@@ -81,7 +81,7 @@ def get_bin(item_code, warehouse):
def update_bin(args, allow_negative_stock=False, via_landed_cost_voucher=False):
is_stock_item = frappe.db.get_value('Item', args.get("item_code"), 'is_stock_item')
if is_stock_item == 'Yes':
if is_stock_item:
bin = get_bin(args.get("item_code"), args.get("warehouse"))
bin.update_stock(args, allow_negative_stock, via_landed_cost_voucher)
return bin
@@ -173,4 +173,3 @@ def validate_warehouse_company(warehouse, company):
if warehouse_company and warehouse_company != company:
frappe.throw(_("Warehouse {0} does not belong to company {1}").format(warehouse, company),
InvalidWarehouseCompany)