Merge pull request #3718 from rmehta/item-cleanup
[cleanup] yes/no selects changed to checks in Item
This commit is contained in:
commit
18c2c54633
@ -69,7 +69,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
supplier: function() {
|
||||
var me = this;
|
||||
if(this.frm.updating_party_details)
|
||||
@ -152,7 +152,7 @@ cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(do
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters:{
|
||||
'is_purchase_item': 'Yes'
|
||||
'is_purchase_item': 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -232,4 +232,3 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
|
||||
else
|
||||
cur_frm.pformat.print_heading = __("Purchase Invoice");
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class PurchaseInvoice(BuyingController):
|
||||
def check_active_purchase_items(self):
|
||||
for d in self.get('items'):
|
||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
||||
if frappe.db.get_value("Item", d.item_code, "is_purchase_item") != 'Yes':
|
||||
if frappe.db.get_value("Item", d.item_code, "is_purchase_item") != 1:
|
||||
msgprint(_("Item {0} is not Purchase Item").format(d.item_code), raise_exception=True)
|
||||
|
||||
def check_conversion_rate(self):
|
||||
|
@ -11,9 +11,9 @@ def get_items(price_list, sales_or_purchase, item=None):
|
||||
args = {"price_list": price_list}
|
||||
|
||||
if sales_or_purchase == "Sales":
|
||||
condition = "i.is_sales_item='Yes'"
|
||||
condition = "i.is_sales_item=1"
|
||||
else:
|
||||
condition = "i.is_purchase_item='Yes'"
|
||||
condition = "i.is_purchase_item=1"
|
||||
|
||||
if item:
|
||||
# search serial no
|
||||
|
@ -85,7 +85,7 @@ class SalesInvoice(SellingController):
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
self.check_credit_limit()
|
||||
|
||||
|
||||
# this sequence because outstanding may get -ve
|
||||
self.make_gl_entries()
|
||||
|
||||
@ -102,15 +102,15 @@ class SalesInvoice(SellingController):
|
||||
self.update_stock_ledger()
|
||||
|
||||
self.check_stop_sales_order("sales_order")
|
||||
|
||||
|
||||
from erpnext.accounts.utils import remove_against_link_from_jv
|
||||
remove_against_link_from_jv(self.doctype, self.name, "against_invoice")
|
||||
|
||||
|
||||
if not self.is_return:
|
||||
self.update_status_updater_args()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
|
||||
|
||||
self.validate_c_form_on_cancel()
|
||||
|
||||
self.make_gl_entries_on_cancel()
|
||||
@ -248,12 +248,10 @@ class SalesInvoice(SellingController):
|
||||
def validate_fixed_asset_account(self):
|
||||
"""Validate Fixed Asset and whether Income Account Entered Exists"""
|
||||
for d in self.get('items'):
|
||||
item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem`
|
||||
where name = %s""", d.item_code)
|
||||
acc = frappe.db.sql("""select account_type from `tabAccount`
|
||||
where name = %s and docstatus != 2""", d.income_account)
|
||||
if item and item[0][1] == 'Yes' and acc and acc[0][0] != 'Fixed Asset':
|
||||
msgprint(_("Account {0} must be of type 'Fixed Asset' as Item {1} is an Asset Item").format(acc[0][0], d.item_code), raise_exception=True)
|
||||
is_asset_item = frappe.db.get_value("Item", d.item_code, "is_asset_item")
|
||||
account_type = frappe.db.get_value("Account", d.income_account, "account_type")
|
||||
if is_asset_item == 1 and account_type != 'Fixed Asset':
|
||||
msgprint(_("Account {0} must be of type 'Fixed Asset' as Item {1} is an Asset Item").format(d.income_account, d.item_code), raise_exception=True)
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(SalesInvoice, self).validate_with_previous_doc({
|
||||
@ -271,7 +269,7 @@ class SalesInvoice(SellingController):
|
||||
|
||||
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"],
|
||||
["Sales Order", "sales_order", "so_detail"],
|
||||
["Delivery Note", "delivery_note", "dn_detail"]
|
||||
])
|
||||
|
||||
@ -296,7 +294,7 @@ class SalesInvoice(SellingController):
|
||||
for i in dic:
|
||||
if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes':
|
||||
for d in self.get('items'):
|
||||
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 not d.get(i.lower().replace(' ','_')):
|
||||
msgprint(_("{0} is mandatory for Item {1}").format(i,d.item_code), raise_exception=1)
|
||||
|
||||
@ -426,11 +424,13 @@ class SalesInvoice(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" and d.warehouse:
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 \
|
||||
and d.warehouse:
|
||||
incoming_rate = 0
|
||||
if cint(self.is_return) and self.return_against and self.docstatus==1:
|
||||
incoming_rate = self.get_incoming_rate_for_sales_return(d.item_code, self.return_against)
|
||||
|
||||
incoming_rate = self.get_incoming_rate_for_sales_return(d.item_code,
|
||||
self.return_against)
|
||||
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": -1*flt(d.qty),
|
||||
"stock_uom": frappe.db.get_value("Item", d.item_code, "stock_uom"),
|
||||
@ -664,4 +664,4 @@ def make_delivery_note(source_name, target_doc=None):
|
||||
@frappe.whitelist()
|
||||
def make_sales_return(source_name, target_doc=None):
|
||||
from erpnext.controllers.sales_and_purchase_return import make_return_doc
|
||||
return make_return_doc("Sales Invoice", source_name, target_doc)
|
||||
return make_return_doc("Sales Invoice", source_name, target_doc)
|
||||
|
@ -215,7 +215,7 @@ class GrossProfitGenerator(object):
|
||||
if self.filters.to_date:
|
||||
conditions += " and posting_date <= %(to_date)s"
|
||||
|
||||
self.si_list = frappe.db.sql("""select item.parenttype, item.parent,
|
||||
self.si_list = frappe.db.sql("""select item.parenttype, item.parent,
|
||||
si.posting_date, si.posting_time, si.project_name, si.update_stock,
|
||||
si.customer, si.customer_group, si.territory,
|
||||
item.item_code, item.item_name, item.description, item.warehouse,
|
||||
@ -257,4 +257,4 @@ class GrossProfitGenerator(object):
|
||||
|
||||
def load_non_stock_items(self):
|
||||
self.non_stock_items = frappe.db.sql_list("""select name from tabItem
|
||||
where ifnull(is_stock_item, 'No')='No'""")
|
||||
where is_stock_item=0""")
|
||||
|
@ -44,12 +44,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
if(me.frm.doc.is_subcontracted == "Yes") {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters:{ 'is_sub_contracted_item': 'Yes' }
|
||||
filters:{ 'is_sub_contracted_item': 1 }
|
||||
}
|
||||
} else {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: { 'is_purchase_item': 'Yes' }
|
||||
filters: { 'is_purchase_item': 1 }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -56,24 +56,25 @@ class PurchaseCommon(BuyingController):
|
||||
d.set(x, f_lst[x])
|
||||
|
||||
item = frappe.db.sql("""select is_stock_item, is_purchase_item,
|
||||
is_sub_contracted_item, end_of_life from `tabItem` where name=%s""", d.item_code)
|
||||
is_sub_contracted_item, end_of_life from `tabItem` where name=%s""",
|
||||
d.item_code, as_dict=1)[0]
|
||||
|
||||
from erpnext.stock.doctype.item.item import validate_end_of_life
|
||||
validate_end_of_life(d.item_code, item[0][3])
|
||||
validate_end_of_life(d.item_code, item.end_of_life)
|
||||
|
||||
# validate stock item
|
||||
if item[0][0]=='Yes' and d.qty and not d.warehouse:
|
||||
if item.is_stock_item==1 and d.qty and not d.warehouse:
|
||||
frappe.throw(_("Warehouse is mandatory for stock Item {0} in row {1}").format(d.item_code, d.idx))
|
||||
|
||||
# validate purchase item
|
||||
if not (obj.doctype=="Material Request" and getattr(obj, "material_request_type", None)=="Material Transfer"):
|
||||
if item[0][1] != 'Yes' and item[0][2] != 'Yes':
|
||||
if item.is_purchase_item != 1 and item.is_sub_contracted_item != 1:
|
||||
frappe.throw(_("{0} must be a Purchased or Sub-Contracted Item in row {1}").format(d.item_code, d.idx))
|
||||
|
||||
items.append(cstr(d.item_code))
|
||||
if items and len(items) != len(set(items)):
|
||||
frappe.msgprint(_("Warning: Same item has been entered multiple times."))
|
||||
|
||||
|
||||
|
||||
def check_for_stopped_status(self, doctype, docname):
|
||||
stopped = frappe.db.sql("""select name from `tab%s` where name = %s and
|
||||
|
@ -153,7 +153,7 @@ class PurchaseOrder(BuyingController):
|
||||
item_wh_list = []
|
||||
for d in self.get("items"):
|
||||
if (not po_item_rows or d.name in po_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") and d.warehouse:
|
||||
item_wh_list.append([d.item_code, d.warehouse])
|
||||
|
||||
for item_code, warehouse in item_wh_list:
|
||||
|
2
erpnext/change_log/current/item_cleanup.md
Normal file
2
erpnext/change_log/current/item_cleanup.md
Normal file
@ -0,0 +1,2 @@
|
||||
- **Item** form cleanups: "Yes" / "No" type fields changed to checkboxes.<br>
|
||||
**Warning**: This could break your 3rd party integrations with Item, if any.
|
@ -307,7 +307,7 @@ class AccountsController(TransactionBase):
|
||||
item_codes = list(set(item.item_code for item in self.get("items")))
|
||||
if item_codes:
|
||||
stock_items = [r[0] for r in frappe.db.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
|
||||
from `tabItem` where name in (%s) and is_stock_item=1""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return stock_items
|
||||
|
@ -238,8 +238,8 @@ class BuyingController(StockController):
|
||||
t2.rate, t2.stock_uom, t2.name, t2.description
|
||||
from `tabBOM` t1, `tabBOM Item` t2, tabItem t3
|
||||
where t2.parent = t1.name and t1.item = %s
|
||||
and t1.docstatus = 1 and t1.is_active = 1 and t1.name = %s
|
||||
and t2.item_code = t3.name and ifnull(t3.is_stock_item, 'No') = 'Yes'""", (item_code, bom), as_dict=1)
|
||||
and t1.docstatus = 1 and t1.is_active = 1 and t1.name = %s
|
||||
and t2.item_code = t3.name and t3.is_stock_item = 1""", (item_code, bom), as_dict=1)
|
||||
|
||||
if not bom_items:
|
||||
msgprint(_("Specified BOM {0} does not exist for Item {1}").format(bom, item_code), raise_exception=1)
|
||||
@ -254,7 +254,7 @@ class BuyingController(StockController):
|
||||
self.get("items")))
|
||||
if item_codes:
|
||||
self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \
|
||||
from `tabItem` where name in (%s) and is_sub_contracted_item=1""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return self._sub_contracted_items
|
||||
|
@ -248,7 +248,7 @@ def check_active_sales_items(obj):
|
||||
item = frappe.db.sql("""select docstatus, is_sales_item,
|
||||
is_service_item, income_account from tabItem where name = %s""",
|
||||
d.item_code, as_dict=True)[0]
|
||||
if item.is_sales_item == 'No' and item.is_service_item == 'No':
|
||||
if item.is_sales_item == 0 and item.is_service_item == 0:
|
||||
frappe.throw(_("Item {0} must be Sales or Service Item in {1}").format(d.item_code, d.idx))
|
||||
if getattr(d, "income_account", None) and not item.income_account:
|
||||
frappe.db.set_value("Item", d.item_code, "income_account",
|
||||
|
@ -212,7 +212,7 @@ class StockController(AccountsController):
|
||||
item_codes = list(set([d.item_code for d in self.get("items")]))
|
||||
if item_codes:
|
||||
serialized_items = frappe.db.sql_list("""select name from `tabItem`
|
||||
where has_serial_no='Yes' and name in ({})""".format(", ".join(["%s"]*len(item_codes))),
|
||||
where has_serial_no=1 and name in ({})""".format(", ".join(["%s"]*len(item_codes))),
|
||||
tuple(item_codes))
|
||||
|
||||
return serialized_items
|
||||
|
@ -48,7 +48,7 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: me.frm.doc.enquiry_type === "Maintenance" ?
|
||||
{"is_service_item": "Yes"} : {"is_sales_item": "Yes"}
|
||||
{"is_service_item": 1} : {"is_sales_item":1}
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -24,7 +24,7 @@ class HubSettings(Document):
|
||||
def publish_selling_items(self):
|
||||
"""Set `publish_in_hub`=1 for all Sales Items"""
|
||||
for item in frappe.get_all("Item", fields=["name"],
|
||||
filters={"is_sales_item": "Yes", "publish_in_hub": "0"}):
|
||||
filters={"is_sales_item": 1, "publish_in_hub": "0"}):
|
||||
frappe.db.set_value("Item", item.name, "publish_in_hub", 1)
|
||||
|
||||
def register(self):
|
||||
|
@ -107,7 +107,7 @@ class BOM(Document):
|
||||
rate = 0
|
||||
if arg['bom_no']:
|
||||
rate = self.get_bom_unitcost(arg['bom_no'])
|
||||
elif arg and (arg['is_purchase_item'] == 'Yes' or arg['is_sub_contracted_item'] == 'Yes'):
|
||||
elif arg and (arg['is_purchase_item'] == 1 or arg['is_sub_contracted_item'] == 1):
|
||||
if self.rm_cost_as_per == 'Valuation Rate':
|
||||
rate = self.get_valuation_rate(arg)
|
||||
elif self.rm_cost_as_per == 'Last Purchase Rate':
|
||||
@ -385,14 +385,14 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1):
|
||||
and bom_item.docstatus < 2
|
||||
and bom_item.parent = %(bom)s
|
||||
and item.name = bom_item.item_code
|
||||
and ifnull(item.is_stock_item, 'No') = 'Yes'
|
||||
and is_stock_item = 1
|
||||
{conditions}
|
||||
group by item_code, stock_uom"""
|
||||
|
||||
if fetch_exploded:
|
||||
query = query.format(table="BOM Explosion Item",
|
||||
conditions="""and ifnull(item.is_pro_applicable, 'No') = 'No'
|
||||
and ifnull(item.is_sub_contracted_item, 'No') = 'No' """)
|
||||
conditions="""and item.is_pro_applicable = 0
|
||||
and item.is_sub_contracted_item = 0 """)
|
||||
items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True)
|
||||
else:
|
||||
query = query.format(table="BOM Item", conditions="")
|
||||
|
@ -191,11 +191,10 @@ $.extend(cur_frm.cscript, {
|
||||
method: "set_production_order_operations"
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
qty: function() {
|
||||
frappe.ui.form.trigger("Production Order", 'bom_no')
|
||||
},
|
||||
|
||||
show_time_logs: function(doc, cdt, cdn) {
|
||||
var child = locals[cdt][cdn]
|
||||
frappe.route_options = {"operation_id": child.name};
|
||||
@ -250,8 +249,8 @@ cur_frm.cscript['Update Finished Goods'] = function() {
|
||||
cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
||||
return {
|
||||
filters:[
|
||||
['Item', 'is_pro_applicable', '=', 'Yes'],
|
||||
['Item', 'has_variants', '=', 'No'],
|
||||
['Item', 'is_pro_applicable', '=', 1],
|
||||
['Item', 'has_variants', '=', 0]
|
||||
['Item', 'end_of_life', '>=', frappe.datetime.nowdate()]
|
||||
]
|
||||
}
|
||||
@ -264,7 +263,3 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, dt, dn) {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ class ProductionOrder(Document):
|
||||
(self.sales_order, self.production_item))[0][0]
|
||||
# total qty in SO
|
||||
so_qty = flt(so_item_qty) + flt(dnpi_qty)
|
||||
|
||||
|
||||
allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings", "over_production_allowance_percentage"))
|
||||
if total_qty > so_qty + (allowance_percentage/100 * so_qty):
|
||||
frappe.throw(_("Cannot produce more Item {0} than Sales Order quantity {1}").format(self.production_item,
|
||||
@ -320,14 +320,14 @@ class ProductionOrder(Document):
|
||||
def delete_time_logs(self):
|
||||
for time_log in frappe.get_all("Time Log", ["name"], {"production_order": self.name}):
|
||||
frappe.delete_doc("Time Log", time_log.name)
|
||||
|
||||
|
||||
def validate_production_item(self):
|
||||
if frappe.db.get_value("Item", self.production_item, "is_pro_applicable")=='No':
|
||||
if not frappe.db.get_value("Item", self.production_item, "is_pro_applicable"):
|
||||
frappe.throw(_("Item is not allowed to have Production Order."), ProductionNotApplicableError)
|
||||
|
||||
|
||||
if frappe.db.get_value("Item", self.production_item, "has_variants"):
|
||||
frappe.throw(_("Production Order cannot be raised against a Item Template"), ItemHasVariantError)
|
||||
|
||||
|
||||
validate_end_of_life(self.production_item)
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -126,7 +126,7 @@ class TestProductionOrder(unittest.TestCase):
|
||||
"docstatus": 0
|
||||
})
|
||||
self.assertRaises(OverProductionLoggedError, time_log2.save)
|
||||
|
||||
|
||||
def test_planned_operating_cost(self):
|
||||
prod_order = make_prod_order_test_record(item="_Test FG Item 2",
|
||||
planned_start_date="2014-11-25 00:00:00", qty=1, do_not_save=True)
|
||||
@ -135,20 +135,20 @@ class TestProductionOrder(unittest.TestCase):
|
||||
prod_order.qty = 2
|
||||
prod_order.set_production_order_operations()
|
||||
self.assertEqual(prod_order.planned_operating_cost, cost*2)
|
||||
|
||||
|
||||
def test_production_item(self):
|
||||
frappe.db.set_value("Item", "_Test FG Item", "is_pro_applicable", "No")
|
||||
frappe.db.set_value("Item", "_Test FG Item", "is_pro_applicable", 0)
|
||||
|
||||
prod_order = make_prod_order_test_record(item="_Test FG Item", qty=1, do_not_save=True)
|
||||
self.assertRaises(ProductionNotApplicableError, prod_order.save)
|
||||
|
||||
frappe.db.set_value("Item", "_Test FG Item", "is_pro_applicable", "Yes")
|
||||
|
||||
frappe.db.set_value("Item", "_Test FG Item", "is_pro_applicable", 1)
|
||||
frappe.db.set_value("Item", "_Test FG Item", "end_of_life", "2000-1-1")
|
||||
|
||||
|
||||
self.assertRaises(frappe.ValidationError, prod_order.save)
|
||||
|
||||
|
||||
frappe.db.set_value("Item", "_Test FG Item", "end_of_life", None)
|
||||
|
||||
|
||||
prod_order = make_prod_order_test_record(item="_Test Variant Item", qty=1, do_not_save=True)
|
||||
self.assertRaises(ItemHasVariantError, prod_order.save)
|
||||
|
||||
|
@ -52,7 +52,7 @@ cur_frm.fields_dict['sales_orders'].grid.get_field('sales_order').get_query = fu
|
||||
|
||||
cur_frm.fields_dict['items'].grid.get_field('item_code').get_query = function(doc) {
|
||||
return erpnext.queries.item({
|
||||
'is_pro_applicable': 'Yes'
|
||||
'is_pro_applicable': 1
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -61,13 +61,13 @@ class ProductionPlanningTool(Document):
|
||||
and so.company = %s
|
||||
and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0) %s
|
||||
and (exists (select name from `tabItem` item where item.name=so_item.item_code
|
||||
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s)
|
||||
and (item.is_pro_applicable = 1
|
||||
or item.is_sub_contracted_item = 1 %s)
|
||||
or exists (select name from `tabPacked Item` pi
|
||||
where pi.parent = so.name and pi.parent_item = so_item.item_code
|
||||
and exists (select name from `tabItem` item where item.name=pi.item_code
|
||||
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s)))
|
||||
and (item.is_pro_applicable = 1
|
||||
or item.is_sub_contracted_item = 1) %s)))
|
||||
""" % ('%s', so_filter, item_filter, item_filter), self.company, as_dict=1)
|
||||
|
||||
self.add_so_in_table(open_so)
|
||||
@ -108,8 +108,8 @@ class ProductionPlanningTool(Document):
|
||||
from `tabSales Order Item` so_item
|
||||
where parent in (%s) and docstatus = 1 and ifnull(qty, 0) > ifnull(delivered_qty, 0)
|
||||
and exists (select * from `tabItem` item where item.name=so_item.item_code
|
||||
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes')) %s""" % \
|
||||
and (item.is_pro_applicable = 1
|
||||
or item.is_sub_contracted_item = 1)) %s""" % \
|
||||
(", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1)
|
||||
|
||||
if self.fg_item:
|
||||
@ -123,8 +123,8 @@ class ProductionPlanningTool(Document):
|
||||
and pi.parent_item = so_item.item_code
|
||||
and so_item.parent in (%s) and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0)
|
||||
and exists (select * from `tabItem` item where item.name=pi.item_code
|
||||
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes')) %s""" % \
|
||||
and (item.is_pro_applicable = 1
|
||||
or item.is_sub_contracted_item = 1)) %s""" % \
|
||||
(", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1)
|
||||
|
||||
return items + packed_items
|
||||
@ -178,7 +178,7 @@ class ProductionPlanningTool(Document):
|
||||
for d in self.get("items"):
|
||||
if d.bom_no:
|
||||
bom_dict.setdefault(d.bom_no, []).append([d.sales_order, flt(d.planned_qty)])
|
||||
if frappe.db.get_value("Item", d.item_code, "is_pro_applicable") == "Yes":
|
||||
if frappe.db.get_value("Item", d.item_code, "is_pro_applicable"):
|
||||
item_dict[(d.item_code, d.sales_order, d.warehouse)] = {
|
||||
"production_item" : d.item_code,
|
||||
"sales_order" : d.sales_order,
|
||||
@ -239,10 +239,10 @@ class ProductionPlanningTool(Document):
|
||||
ifnull(sum(ifnull(fb.qty, 0)/ifnull(bom.quantity, 1)), 0) as qty,
|
||||
fb.description, fb.stock_uom, it.min_order_qty
|
||||
from `tabBOM Explosion Item` fb, `tabBOM` bom, `tabItem` it
|
||||
where bom.name = fb.parent and it.name = fb.item_code
|
||||
and ifnull(it.is_pro_applicable, 'No') = 'No'
|
||||
and ifnull(it.is_sub_contracted_item, 'No') = 'No'
|
||||
and ifnull(it.is_stock_item, 'No') = 'Yes'
|
||||
where bom.name = fb.parent and it.name = fb.item_code
|
||||
and is_pro_applicable = 0
|
||||
and is_sub_contracted_item = 0
|
||||
and is_stock_item = 1
|
||||
and fb.docstatus<2 and bom.name=%s
|
||||
group by item_code, stock_uom""", bom, as_dict=1):
|
||||
bom_wise_item_details.setdefault(d.item_code, d)
|
||||
@ -255,7 +255,7 @@ class ProductionPlanningTool(Document):
|
||||
from `tabBOM Item` bom_item, `tabBOM` bom, tabItem item
|
||||
where bom.name = bom_item.parent and bom.name = %s and bom_item.docstatus < 2
|
||||
and bom_item.item_code = item.name
|
||||
and ifnull(item.is_stock_item, 'No') = 'Yes'
|
||||
and item.is_stock_item = 1
|
||||
group by item_code""", bom, as_dict=1):
|
||||
bom_wise_item_details.setdefault(d.item_code, d)
|
||||
|
||||
@ -350,7 +350,7 @@ class ProductionPlanningTool(Document):
|
||||
|
||||
def insert_purchase_request(self):
|
||||
items_to_be_requested = self.get_requested_items()
|
||||
|
||||
|
||||
purchase_request_list = []
|
||||
if items_to_be_requested:
|
||||
for item in items_to_be_requested:
|
||||
|
@ -24,6 +24,9 @@ erpnext.patches.v4_0.map_charge_to_taxes_and_charges
|
||||
execute:frappe.reload_doc('support', 'doctype', 'newsletter') # 2014-01-31
|
||||
execute:frappe.reload_doc('hr', 'doctype', 'employee') # 2014-02-03
|
||||
execute:frappe.db.sql("update tabPage set module='Core' where name='Setup'")
|
||||
|
||||
# inserted this patch here since Item types are being changed
|
||||
erpnext.patches.v5_2.change_item_selects_to_checks
|
||||
erpnext.patches.v4_0.fields_to_be_renamed
|
||||
erpnext.patches.v4_0.rename_sitemap_to_route
|
||||
erpnext.patches.v4_0.fix_contact_address
|
||||
@ -176,4 +179,4 @@ erpnext.patches.v5_1.fix_credit_days_based_on
|
||||
execute:frappe.rename_doc("DocType", "Salary Manager", "Process Payroll", force=True)
|
||||
erpnext.patches.v5_1.rename_roles
|
||||
erpnext.patches.v5_1.default_bom
|
||||
execute:frappe.delete_doc("DocType", "Party Type")
|
||||
execute:frappe.delete_doc("DocType", "Party Type")
|
||||
|
@ -5,61 +5,61 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.db.sql("update tabItem set has_batch_no = 'No' where ifnull(has_batch_no, '') = ''")
|
||||
frappe.db.sql("update tabItem set has_serial_no = 'No' where ifnull(has_serial_no, '') = ''")
|
||||
|
||||
item_list = frappe.db.sql("""select name, has_batch_no, has_serial_no from tabItem
|
||||
where ifnull(is_stock_item, 'No') = 'Yes'""", as_dict=1)
|
||||
|
||||
frappe.db.sql("update tabItem set has_batch_no = 0 where ifnull(has_batch_no, '') = ''")
|
||||
frappe.db.sql("update tabItem set has_serial_no = 0 where ifnull(has_serial_no, '') = ''")
|
||||
|
||||
item_list = frappe.db.sql("""select name, has_batch_no, has_serial_no from tabItem
|
||||
where is_stock_item = 1""", as_dict=1)
|
||||
|
||||
sle_count = get_sle_count()
|
||||
sle_with_batch = get_sle_with_batch()
|
||||
sle_with_serial = get_sle_with_serial()
|
||||
|
||||
|
||||
batch_items = get_items_with_batch()
|
||||
serialized_items = get_items_with_serial()
|
||||
|
||||
for d in item_list:
|
||||
if d.has_batch_no == 'Yes':
|
||||
|
||||
for d in item_list:
|
||||
if d.has_batch_no == 1:
|
||||
if d.name not in batch_items and sle_count.get(d.name) and sle_count.get(d.name) != sle_with_batch.get(d.name):
|
||||
frappe.db.set_value("Item", d.name, "has_batch_no", "No")
|
||||
frappe.db.set_value("Item", d.name, "has_batch_no", 0)
|
||||
else:
|
||||
if d.name in batch_items or (sle_count.get(d.name) and sle_count.get(d.name) == sle_with_batch.get(d.name)):
|
||||
frappe.db.set_value("Item", d.name, "has_batch_no", "Yes")
|
||||
|
||||
if d.has_serial_no == 'Yes':
|
||||
frappe.db.set_value("Item", d.name, "has_batch_no", 1)
|
||||
|
||||
if d.has_serial_no == 1:
|
||||
if d.name not in serialized_items and sle_count.get(d.name) and sle_count.get(d.name) != sle_with_serial.get(d.name):
|
||||
frappe.db.set_value("Item", d.name, "has_serial_no", "No")
|
||||
frappe.db.set_value("Item", d.name, "has_serial_no", 0)
|
||||
else:
|
||||
if d.name in serialized_items or (sle_count.get(d.name) and sle_count.get(d.name) == sle_with_serial.get(d.name)):
|
||||
frappe.db.set_value("Item", d.name, "has_serial_no", "Yes")
|
||||
|
||||
|
||||
frappe.db.set_value("Item", d.name, "has_serial_no", 1)
|
||||
|
||||
|
||||
def get_sle_count():
|
||||
sle_count = {}
|
||||
for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry` group by item_code""", as_dict=1):
|
||||
sle_count.setdefault(d.item_code, d.cnt)
|
||||
|
||||
|
||||
return sle_count
|
||||
|
||||
|
||||
def get_sle_with_batch():
|
||||
sle_with_batch = {}
|
||||
for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry`
|
||||
for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry`
|
||||
where ifnull(batch_no, '') != '' group by item_code""", as_dict=1):
|
||||
sle_with_batch.setdefault(d.item_code, d.cnt)
|
||||
|
||||
|
||||
return sle_with_batch
|
||||
|
||||
|
||||
|
||||
def get_sle_with_serial():
|
||||
sle_with_serial = {}
|
||||
for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry`
|
||||
for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry`
|
||||
where ifnull(serial_no, '') != '' group by item_code""", as_dict=1):
|
||||
sle_with_serial.setdefault(d.item_code, d.cnt)
|
||||
|
||||
|
||||
return sle_with_serial
|
||||
|
||||
|
||||
def get_items_with_batch():
|
||||
return frappe.db.sql_list("select item from tabBatch")
|
||||
|
||||
|
||||
def get_items_with_serial():
|
||||
return frappe.db.sql_list("select item_code from `tabSerial No`")
|
||||
return frappe.db.sql_list("select item_code from `tabSerial No`")
|
||||
|
1
erpnext/patches/v5_2/__init__.py
Normal file
1
erpnext/patches/v5_2/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
21
erpnext/patches/v5_2/change_item_selects_to_checks.py
Normal file
21
erpnext/patches/v5_2/change_item_selects_to_checks.py
Normal file
@ -0,0 +1,21 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
fields = ("is_stock_item", "is_asset_item", "has_batch_no", "has_serial_no",
|
||||
"is_purchase_item", "is_sales_item", "is_service_item", "inspection_required",
|
||||
"is_pro_applicable", "is_sub_contracted_item")
|
||||
|
||||
|
||||
# convert to 1 or 0
|
||||
update_str = ", ".join(["`{0}`=if(`{0}`='Yes',1,0)".format(f) for f in fields])
|
||||
frappe.db.sql("update tabItem set {0}".format(update_str))
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
# alter fields to int
|
||||
for f in fields:
|
||||
frappe.db.sql("alter table tabItem change {0} {0} int(1) default '0'".format(f, f))
|
||||
|
||||
frappe.reload_doctype("Item")
|
@ -39,10 +39,10 @@ class InstallationNote(TransactionBase):
|
||||
check_active_sales_items(self)
|
||||
|
||||
def is_serial_no_added(self, item_code, serial_no):
|
||||
ar_required = frappe.db.get_value("Item", item_code, "has_serial_no")
|
||||
if ar_required == 'Yes' and not serial_no:
|
||||
has_serial_no = frappe.db.get_value("Item", item_code, "has_serial_no")
|
||||
if has_serial_no == 1 and not serial_no:
|
||||
frappe.throw(_("Serial No is mandatory for Item {0}").format(item_code))
|
||||
elif ar_required != 'Yes' and cstr(serial_no).strip():
|
||||
elif has_serial_no != 1 and cstr(serial_no).strip():
|
||||
frappe.throw(_("Item {0} is not a serialized Item").format(item_code))
|
||||
|
||||
def is_serial_no_exist(self, item_code, serial_no):
|
||||
@ -69,7 +69,7 @@ class InstallationNote(TransactionBase):
|
||||
frappe.throw(_("Serial No {0} does not belong to Delivery Note {1}").format(sr, prevdoc_docname))
|
||||
|
||||
def validate_serial_no(self):
|
||||
cur_s_no, prevdoc_s_no, sr_list = [], [], []
|
||||
prevdoc_s_no, sr_list = [], []
|
||||
for d in self.get('items'):
|
||||
self.is_serial_no_added(d.item_code, d.serial_no)
|
||||
if d.serial_no:
|
||||
|
@ -21,7 +21,7 @@ class ProductBundle(Document):
|
||||
def validate_main_item(self):
|
||||
"""main item must have Is Stock Item as No and Is Sales Item as Yes"""
|
||||
if not frappe.db.sql("""select name from tabItem where name=%s and
|
||||
ifnull(is_stock_item,'')='No' and ifnull(is_sales_item,'')='Yes'""", self.new_item_code):
|
||||
is_stock_item = 0 and is_sales_item = 1""", self.new_item_code):
|
||||
frappe.throw(_("Parent Item {0} must be not Stock Item and must be a Sales Item").format(self.new_item_code))
|
||||
|
||||
def get_item_details(self, name):
|
||||
@ -36,7 +36,7 @@ def get_new_item_code(doctype, txt, searchfield, start, page_len, filters):
|
||||
from erpnext.controllers.queries import get_match_cond
|
||||
|
||||
return frappe.db.sql("""select name, item_name, description from tabItem
|
||||
where is_stock_item="No" and is_sales_item="Yes"
|
||||
where is_stock_item=0 and is_sales_item=1
|
||||
and name not in (select name from `tabProduct Bundle`) and %s like %s
|
||||
%s limit %s, %s""" % (searchfield, "%s",
|
||||
get_match_cond(doctype),"%s", "%s"),
|
||||
|
@ -28,17 +28,11 @@ class Quotation(SellingController):
|
||||
|
||||
if self.order_type in ['Maintenance', 'Service']:
|
||||
for d in self.get('items'):
|
||||
is_service_item = frappe.db.sql("select is_service_item from `tabItem` where name=%s", d.item_code)
|
||||
is_service_item = is_service_item and is_service_item[0][0] or 'No'
|
||||
|
||||
if is_service_item == 'No':
|
||||
if not frappe.db.get_value("Item", d.item_code, "is_service_item"):
|
||||
frappe.throw(_("Item {0} must be Service Item").format(d.item_code))
|
||||
else:
|
||||
for d in self.get('items'):
|
||||
is_sales_item = frappe.db.sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
|
||||
is_sales_item = is_sales_item and is_sales_item[0][0] or 'No'
|
||||
|
||||
if is_sales_item == 'No':
|
||||
if not frappe.db.get_value("Item", d.item_code, "is_sales_item"):
|
||||
frappe.throw(_("Item {0} must be Sales Item").format(d.item_code))
|
||||
|
||||
def validate_quotation_to(self):
|
||||
|
@ -39,7 +39,7 @@ class SalesOrder(SellingController):
|
||||
for d in self.get('items'):
|
||||
check_list.append(cstr(d.item_code))
|
||||
|
||||
if (frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
|
||||
if (frappe.db.get_value("Item", d.item_code, "is_stock_item")==1 or
|
||||
self.has_product_bundle(d.item_code)) and not d.warehouse:
|
||||
frappe.throw(_("Reserved warehouse required for stock item {0}").format(d.item_code))
|
||||
|
||||
@ -217,7 +217,7 @@ class SalesOrder(SellingController):
|
||||
def update_stock_ledger(self, update_stock):
|
||||
from erpnext.stock.utils import update_bin
|
||||
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:
|
||||
args = {
|
||||
"item_code": d['item_code'],
|
||||
"warehouse": d['reserved_warehouse'],
|
||||
@ -258,14 +258,14 @@ def stop_or_unstop_sales_orders(names, status):
|
||||
|
||||
def before_recurring(self):
|
||||
super(SalesOrder, self).before_recurring()
|
||||
|
||||
|
||||
for field in ("delivery_status", "per_delivered", "billing_status", "per_billed"):
|
||||
self.set(field, None)
|
||||
|
||||
for d in self.get("items"):
|
||||
for field in ("delivered_qty", "billed_amt", "planned_qty", "prevdoc_docname"):
|
||||
d.set(field, None)
|
||||
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_material_request(source_name, target_doc=None):
|
||||
@ -273,9 +273,9 @@ def make_material_request(source_name, target_doc=None):
|
||||
doc.material_request_type = "Purchase"
|
||||
|
||||
so = frappe.get_doc("Sales Order", source_name)
|
||||
|
||||
|
||||
item_table = "Packed Item" if so.packed_items else "Sales Order Item"
|
||||
|
||||
|
||||
doc = get_mapped_doc("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Material Request",
|
||||
|
@ -57,8 +57,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: (me.frm.doc.order_type === "Maintenance" ?
|
||||
{'is_service_item': 'Yes'}:
|
||||
{'is_sales_item': 'Yes' })
|
||||
{'is_service_item': 1}:
|
||||
{'is_sales_item': 1 })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ def make_sample_data():
|
||||
"""Create a few opportunities, quotes, material requests, issues, todos, projects
|
||||
to help the user get started"""
|
||||
|
||||
selling_items = frappe.get_all("Item", filters = {"is_sales_item": "Yes"})
|
||||
buying_items = frappe.get_all("Item", filters = {"is_sales_item": "No"})
|
||||
selling_items = frappe.get_all("Item", filters = {"is_sales_item": 1})
|
||||
buying_items = frappe.get_all("Item", filters = {"is_sales_item": 0})
|
||||
|
||||
if selling_items:
|
||||
for i in range(3):
|
||||
@ -37,7 +37,7 @@ def make_opportunity(selling_items):
|
||||
|
||||
add_random_children(b, "items", rows=len(selling_items), randomize = {
|
||||
"qty": (1, 5),
|
||||
"item_code": ("Item", {"is_sales_item": "Yes"})
|
||||
"item_code": ("Item", {"is_sales_item": 1})
|
||||
}, unique="item_code")
|
||||
|
||||
b.insert(ignore_permissions=True)
|
||||
@ -54,7 +54,7 @@ def make_quote(selling_items):
|
||||
|
||||
add_random_children(qtn, "items", rows=len(selling_items), randomize = {
|
||||
"qty": (1, 5),
|
||||
"item_code": ("Item", {"is_sales_item": "Yes"})
|
||||
"item_code": ("Item", {"is_sales_item": 1})
|
||||
}, unique="item_code")
|
||||
|
||||
qtn.insert(ignore_permissions=True)
|
||||
|
@ -368,10 +368,10 @@ def create_items(args):
|
||||
"item_code": item,
|
||||
"item_name": item,
|
||||
"description": item,
|
||||
"is_sales_item": "Yes" if is_sales_item else "No",
|
||||
"is_purchase_item": "Yes" if is_purchase_item else "No",
|
||||
"is_sales_item": 1 if is_sales_item else 0,
|
||||
"is_purchase_item": 1 if is_purchase_item else 0,
|
||||
"show_in_website": 1,
|
||||
"is_stock_item": is_stock_item and "Yes" or "No",
|
||||
"is_stock_item": is_stock_item and 1 or 0,
|
||||
"item_group": item_group,
|
||||
"stock_uom": args.get("item_uom_" + str(i)),
|
||||
"default_warehouse": default_warehouse
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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})
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -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)):
|
||||
|
@ -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 {
|
||||
|
@ -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"):
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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});
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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""")
|
||||
|
@ -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)
|
||||
|
||||
|
@ -102,7 +102,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.fields_dict['items'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
||||
return {
|
||||
filters:{ 'is_service_item': "Yes" }
|
||||
filters:{ 'is_service_item': 1 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.fields_dict['purposes'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
||||
return{
|
||||
filters:{ 'is_service_item': "Yes"}
|
||||
filters:{ 'is_service_item': 1}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin
|
||||
|
||||
bin = frappe.db.sql("""select bin.item_code, bin.warehouse, bin.actual_qty, item.stock_uom
|
||||
from `tabBin` bin, tabItem item
|
||||
where bin.item_code = item.name and item.has_serial_no = 'Yes' %s""" % condition)
|
||||
where bin.item_code = item.name and item.has_serial_no = 1 %s""" % condition)
|
||||
|
||||
for d in bin:
|
||||
serial_nos = frappe.db.sql("""select count(name) from `tabSerial No`
|
||||
|
Loading…
Reference in New Issue
Block a user