Merge pull request #7771 from rmehta/item-name

[minor] item name not mandatory and item price with quick edit
This commit is contained in:
Nabin Hait 2017-02-17 15:17:24 +05:30 committed by GitHub
commit a6eb1434b3
4 changed files with 99 additions and 113 deletions

View File

@ -4,6 +4,13 @@
frappe.provide("erpnext.item");
frappe.ui.form.on("Item", {
setup: function(frm) {
frm.add_fetch('attribute', 'numeric_values', 'numeric_values');
frm.add_fetch('attribute', 'from_range', 'from_range');
frm.add_fetch('attribute', 'to_range', 'to_range');
frm.add_fetch('attribute', 'increment', 'increment');
frm.add_fetch('tax_type', 'tax_rate', 'tax_rate');
},
onload: function(frm) {
erpnext.item.setup_queries(frm);
if (frm.doc.variant_of){
@ -16,7 +23,6 @@ frappe.ui.form.on("Item", {
},
refresh: function(frm) {
if(frm.doc.is_stock_item) {
frm.add_custom_button(__("Balance"), function() {
frappe.route_options = {
@ -54,9 +60,9 @@ frappe.ui.form.on("Item", {
}, __("View"));
frm.add_custom_button(__("Variant"), function() {
erpnext.item.make_variant()
erpnext.item.make_variant(frm);
}, __("Make"));
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
frm.page.set_inner_btn_group_as_primary(__("Make"));
}
if (frm.doc.variant_of) {
frm.set_intro(__("This Item is a Variant of {0} (Template). Attributes will be copied over from the template unless 'No Copy' is set", [frm.doc.variant_of]), true);
@ -79,6 +85,17 @@ frappe.ui.form.on("Item", {
frm.toggle_enable("is_fixed_asset", (frm.doc.__islocal || (!frm.doc.is_stock_item &&
((frm.doc.__onload && frm.doc.__onload.asset_exists) ? false : true))));
frm.add_custom_button(__('Duplicate'), function() {
var new_item = frappe.model.copy_doc(frm.doc);
if(new_item.item_name===new_item.item_code) {
new_item.item_name = null;
}
if(new_item.description===new_item.description) {
new_item.description = null;
}
frappe.set_route('Form', 'Item', new_item.name);
});
},
validate: function(frm){
@ -88,13 +105,13 @@ frappe.ui.form.on("Item", {
image: function(frm) {
refresh_field("image_view");
},
is_fixed_asset: function(frm) {
if (frm.doc.is_fixed_asset) {
frm.set_value("is_stock_item", 0);
}
},
page_name: frappe.utils.warn_page_name_change,
item_code: function(frm) {
@ -191,15 +208,15 @@ $.extend(erpnext.item, {
frm.fields_dict.reorder_levels.grid.get_field("warehouse").get_query = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
var filters = {
"is_group": 0
}
if (d.parent_warehouse) {
filters.extend({"parent_warehouse": d.warehouse_group})
}
return {
filters: filters
}
@ -212,7 +229,8 @@ $.extend(erpnext.item, {
return;
frappe.require('assets/js/item-dashboard.min.js', function() {
var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;"><a href="#stock-balance">Stock Levels</a></h5>');
var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;">\
<a href="#stock-balance">Stock Levels</a></h5>');
erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({
parent: section,
item_code: frm.doc.name
@ -234,12 +252,12 @@ $.extend(erpnext.item, {
}
},
make_variant: function(doc) {
make_variant: function(frm) {
var fields = []
for(var i=0;i< cur_frm.doc.attributes.length;i++){
for(var i=0;i< frm.doc.attributes.length;i++){
var fieldtype, desc;
var row = cur_frm.doc.attributes[i];
var row = frm.doc.attributes[i];
if (row.numeric_values){
fieldtype = "Float";
desc = "Min Value: "+ row.from_range +" , Max Value: "+ row.to_range +", in Increments of: "+ row.increment
@ -268,7 +286,7 @@ $.extend(erpnext.item, {
frappe.call({
method:"erpnext.controllers.item_variant.get_variant",
args: {
"template": cur_frm.doc.name,
"template": frm.doc.name,
"args": d.get_values()
},
callback: function(r) {
@ -290,7 +308,7 @@ $.extend(erpnext.item, {
frappe.call({
method:"erpnext.controllers.item_variant.create_variant",
args: {
"item": cur_frm.doc.name,
"item": frm.doc.name,
"args": d.get_values()
},
callback: function(r) {
@ -358,10 +376,3 @@ $.extend(erpnext.item, {
frm.fields_dict.attributes.grid.toggle_enable("attribute_value", !frm.doc.variant_of);
}
});
cur_frm.add_fetch('attribute', 'numeric_values', 'numeric_values');
cur_frm.add_fetch('attribute', 'from_range', 'from_range');
cur_frm.add_fetch('attribute', 'to_range', 'to_range');
cur_frm.add_fetch('attribute', 'increment', 'increment');
cur_frm.add_fetch('tax_type', 'tax_rate', 'tax_rate');

View File

@ -87,7 +87,7 @@
"in_standard_filter": 0,
"label": "Item Code",
"length": 0,
"no_copy": 1,
"no_copy": 0,
"oldfieldname": "item_code",
"oldfieldtype": "Data",
"permlevel": 0,
@ -134,7 +134,7 @@
},
{
"allow_on_submit": 0,
"bold": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "item_name",
@ -156,7 +156,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
@ -2713,7 +2713,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
"modified": "2017-01-18 17:43:20.262925",
"modified": "2017-02-17 04:00:38.825621",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",

View File

@ -63,6 +63,9 @@ class Item(WebsiteGenerator):
def validate(self):
super(Item, self).validate()
if not self.item_name:
self.item_name = self.item_code
if not self.description:
self.description = self.item_name
@ -470,12 +473,12 @@ class Item(WebsiteGenerator):
def check_if_linked_document_exists(self, key):
linked_doctypes = ["Delivery Note Item", "Sales Invoice Item", "Purchase Receipt Item",
"Purchase Invoice Item", "Stock Entry Detail", "Stock Reconciliation Item"]
# For "Is Stock Item", following doctypes is important
# For "Is Stock Item", following doctypes is important
# because reserved_qty, ordered_qty and requested_qty updated from these doctypes
if key == "is_stock_item":
linked_doctypes += ["Sales Order Item", "Purchase Order Item", "Material Request Item"]
for doctype in linked_doctypes:
if frappe.db.get_value(doctype, filters={"item_code": self.name, "docstatus": 1}) or \
frappe.db.get_value("Production Order",

View File

@ -69,6 +69,33 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -151,6 +178,34 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "currency",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Currency",
"length": 0,
"no_copy": 0,
"options": "Currency",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -211,34 +266,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "currency",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Currency",
"length": 0,
"no_copy": 0,
"options": "Currency",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -318,61 +345,6 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_12",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "bulk_import_help",
"fieldtype": "HTML",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Bulk Import Help",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
@ -386,7 +358,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-12-15 14:52:09.842544",
"modified": "2017-02-17 04:24:30.453863",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Price",
@ -435,7 +407,7 @@
"write": 1
}
],
"quick_entry": 0,
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC",