[merge] merged with master

This commit is contained in:
Nabin Hait
2013-10-24 11:21:11 +05:30
61 changed files with 974 additions and 705 deletions

View File

@@ -13,6 +13,7 @@ cur_frm.cscript.refresh = function(doc) {
window.open(doc.page_name);
}, "icon-globe");
}
cur_frm.cscript.edit_prices_button();
if (!doc.__islocal && doc.is_stock_item == 'Yes') {
cur_frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method'],
@@ -26,6 +27,15 @@ cur_frm.cscript.make_dashboard = function() {
return;
}
cur_frm.cscript.edit_prices_button = function() {
cur_frm.add_custom_button("Add / Edit Prices", function() {
wn.route_options = {
"item_code": cur_frm.doc.name
};
wn.set_route("Report", "Item Price");
}, "icon-money");
}
cur_frm.cscript.item_code = function(doc) {
if(!doc.item_name) cur_frm.set_value("item_name", doc.item_code);
if(!doc.description) cur_frm.set_value("description", doc.item_code);

View File

@@ -144,11 +144,18 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
production_order: function() {
var me = this;
this.toggle_enable_bom();
return this.frm.call({
method: "get_production_order_details",
args: {production_order: this.frm.doc.production_order}
args: {production_order: this.frm.doc.production_order},
callback: function(r) {
if (!r.exc) {
if (me.frm.doc.purpose == "Material Transfer" && !me.frm.doc.to_warehouse)
me.frm.set_value("to_warehouse", r.message["wip_warehouse"]);
}
}
});
},

View File

@@ -469,11 +469,12 @@ class DocType(StockController):
if self.doc.purpose=="Material Receipt":
self.doc.from_warehouse = ""
item = webnotes.conn.sql("""select item, description, uom from `tabBOM`
where name=%s""", (self.doc.bom_no,), as_dict=1)
item = webnotes.conn.sql("""select name, item_name, description, uom
from `tabItem` where name=%s""", (self.doc.bom_no), as_dict=1)
self.add_to_stock_entry_detail({
item[0]["item"] : {
"qty": self.doc.fg_completed_qty,
"item_name": item[0].item_name,
"description": item[0]["description"],
"stock_uom": item[0]["uom"],
"from_warehouse": ""
@@ -481,7 +482,6 @@ class DocType(StockController):
}, bom_no=self.doc.bom_no)
self.get_stock_and_rate()
def get_bom_raw_materials(self, qty):
from manufacturing.doctype.bom.bom import get_bom_items_as_dict
@@ -544,16 +544,24 @@ class DocType(StockController):
return issued_item_qty
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
idx = 1
expense_account, cost_center = webnotes.conn.get_values("Company", self.doc.company, \
["default_expense_account", "cost_center"])[0]
for d in item_dict:
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail',
self.doclist)
se_child.idx = idx
se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse)
se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse)
se_child.item_code = cstr(d)
se_child.item_name = item_dict[d]["item_name"]
se_child.description = item_dict[d]["description"]
se_child.uom = item_dict[d]["stock_uom"]
se_child.stock_uom = item_dict[d]["stock_uom"]
se_child.qty = flt(item_dict[d]["qty"])
se_child.expense_account = item_dict[d]["expense_account"] or expense_account
se_child.cost_center = item_dict[d]["cost_center"] or cost_center
# in stock uom
se_child.transfer_qty = flt(item_dict[d]["qty"])
@@ -562,6 +570,9 @@ class DocType(StockController):
# to be assigned for finished item
se_child.bom_no = bom_no
# increment idx by 1
idx += 1
def get_cust_values(self):
"""fetches customer details"""
if self.doc.delivery_note_no:
@@ -627,8 +638,8 @@ class DocType(StockController):
@webnotes.whitelist()
def get_production_order_details(production_order):
result = webnotes.conn.sql("""select bom_no,
ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom
from `tabProduction Order` where name = %s""", production_order, as_dict=1)
ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom,
wip_warehouse from `tabProduction Order` where name = %s""", production_order, as_dict=1)
return result and result[0] or {}
def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters):

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-03-29 18:22:12",
"docstatus": 0,
"modified": "2013-10-15 14:58:09",
"modified": "2013-10-23 14:35:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -65,6 +65,14 @@
"reqd": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "item_name",
"fieldtype": "Data",
"label": "Item Name",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "description",

View File

@@ -3,11 +3,9 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, flt, validate_email_add
from webnotes.utils import cint, validate_email_add
from webnotes import msgprint, _
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
@@ -30,8 +28,8 @@ class DocType:
if not webnotes.conn.get_value("Account", {"account_type": "Warehouse",
"master_name": self.doc.name}) and not webnotes.conn.get_value("Account",
{"account_name": self.doc.warehouse_name}):
if self.doc.fields.get("__islocal") or not webnotes.conn.get_value("Stock Ledger Entry",
{"warehouse": self.doc.name}):
if self.doc.fields.get("__islocal") or not webnotes.conn.get_value(
"Stock Ledger Entry", {"warehouse": self.doc.name}):
self.validate_parent_account()
ac_bean = webnotes.bean({
"doctype": "Account",
@@ -101,7 +99,8 @@ class DocType:
def on_trash(self):
# delete bin
bins = webnotes.conn.sql("select * from `tabBin` where warehouse = %s", self.doc.name, as_dict=1)
bins = webnotes.conn.sql("select * from `tabBin` where warehouse = %s",
self.doc.name, as_dict=1)
for d in bins:
if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \
d['indented_qty'] or d['projected_qty'] or d['planned_qty']:
@@ -116,8 +115,10 @@ class DocType:
webnotes.delete_doc("Account", warehouse_account)
# delete cancelled sle
if webnotes.conn.sql("""select name from `tabStock Ledger Entry` where warehouse = %s""", self.doc.name):
if webnotes.conn.sql("""select name from `tabStock Ledger Entry` where warehouse = %s""",
self.doc.name):
msgprint("""Warehosue can not be deleted as stock ledger entry
exists for this warehouse.""", raise_exception=1)
else:
webnotes.conn.sql("delete from `tabStock Ledger Entry` where warehouse = %s", self.doc.name)
webnotes.conn.sql("delete from `tabStock Ledger Entry` where warehouse = %s",
self.doc.name)

View File

@@ -77,7 +77,12 @@ wn.module_page["Stock"] = [
{
"doctype":"Price List",
"label": wn._("Price List"),
"description": wn._("Multiple Item Prices")
"description": wn._("Multiple Price list.")
},
{
"doctype":"Item Price",
"label": wn._("Item Price"),
"description": wn._("Multiple Item prices.")
},
{
"doctype":"Quality Inspection",
@@ -202,8 +207,8 @@ wn.module_page["Stock"] = [
},
{
"label":wn._("Item-wise Price List Rate"),
route: "Report/Price List/Item-Wise Price List",
doctype: "Price List"
route: "Report/Item Price/Item-wise Price List Rate",
doctype: "Item Price"
},
{
"label":wn._("Purchase In Transit"),

View File

@@ -57,10 +57,9 @@ def get_price_list():
rate = {}
price_list = webnotes.conn.sql("""select ip.item_code, pl.buying_or_selling,
concat(pl.name, " - ", pl.currency, " ", ip.ref_rate) as price
from `tabItem Price` ip, `tabPrice List` pl where
ip.parent = pl.name and pl.docstatus<2""", as_dict=1)
price_list = webnotes.conn.sql("""select item_code, buying_or_selling,
concat(price_list, " - ", currency, " ", ref_rate) as price
from `tabItem Price`""", as_dict=1)
for j in price_list:
if j.price: