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

Conflicts:
	patches/december_2012/deprecate_tds.py
	patches/june_2012/reports_list_permission.py
	selling/doctype/sales_bom/locale/_messages_doc.json
	selling/doctype/sales_bom/locale/ar-doc.json
	selling/doctype/sales_bom/locale/de-doc.json
	selling/doctype/sales_bom/locale/es-doc.json
	selling/doctype/sales_bom/locale/fr-doc.json
	selling/doctype/sales_bom/locale/hi-doc.json
	selling/doctype/sales_bom/locale/hr-doc.json
	selling/doctype/sales_bom/locale/nl-doc.json
	selling/doctype/sales_bom/locale/pt-BR-doc.json
	selling/doctype/sales_bom/locale/pt-doc.json
	selling/doctype/sales_bom/locale/sr-doc.json
	selling/doctype/sales_bom/locale/ta-doc.json
	selling/doctype/sales_bom/locale/th-doc.json
	selling/doctype/sales_bom_item/locale/_messages_doc.json
	selling/doctype/sales_bom_item/locale/ar-doc.json
	selling/doctype/sales_bom_item/locale/de-doc.json
	selling/doctype/sales_bom_item/locale/es-doc.json
	selling/doctype/sales_bom_item/locale/fr-doc.json
	selling/doctype/sales_bom_item/locale/hi-doc.json
	selling/doctype/sales_bom_item/locale/hr-doc.json
	selling/doctype/sales_bom_item/locale/nl-doc.json
	selling/doctype/sales_bom_item/locale/pt-BR-doc.json
	selling/doctype/sales_bom_item/locale/pt-doc.json
	selling/doctype/sales_bom_item/locale/sr-doc.json
	selling/doctype/sales_bom_item/locale/ta-doc.json
	selling/doctype/sales_bom_item/locale/th-doc.json
This commit is contained in:
Anand Doshi
2013-06-26 14:07:29 +05:30
30 changed files with 273 additions and 214 deletions

View File

@@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@@ -1,39 +0,0 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_enable('new_item_code', doc.__islocal);
if(!doc.__islocal) {
cur_frm.add_custom_button("Check for Duplicates", function() {
cur_frm.call_server('check_duplicate', 1)
}, 'icon-search')
}
}
cur_frm.fields_dict.new_item_code.get_query = function() {
return 'select name, description from tabItem where is_stock_item="No" and is_sales_item="Yes"\
and name not in (select name from `tabSales BOM`)\
and `%(key)s` like "%s"'
}
cur_frm.fields_dict.new_item_code.query_description = 'Select Item where "Is Stock Item" is "No" \
and "Is Sales Item" is "Yes" and there is no other Sales BOM';
cur_frm.cscript.item_code = function(doc, dt, dn) {
var d = locals[dt][dn];
if (d.item_code){
get_server_fields('get_item_details', d.item_code, 'sales_bom_items', doc ,dt, dn, 1);
}
}

View File

@@ -1,85 +0,0 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
from webnotes.model.utils import getlist
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
def autoname(self):
self.doc.name = self.doc.new_item_code
def validate(self):
# check for duplicate
self.check_duplicate()
self.validate_main_item()
def validate_main_item(self):
"""main item must have Is Stock Item as No and Is Sales Item as Yes"""
if not webnotes.conn.sql("""select name from tabItem where name=%s and
ifnull(is_stock_item,'')='No' and ifnull(is_sales_item,'')='Yes'""", self.doc.new_item_code):
webnotes.msgprint("""Parent Item %s is either a Stock Item or a not a Sales Item""",
raise_exception=1)
def get_item_details(self, name):
det = webnotes.conn.sql("""select description, stock_uom from `tabItem`
where name = %s""", name)
rate = webnotes.conn.sql("""select ref_rate from `tabItem Price`
where price_list_name = %s and parent = %s
and ref_currency = %s""", (self.doc.price_list, name, self.doc.currency))
return {
'description' : det and det[0][0] or '',
'uom': det and det[0][1] or '',
'rate': rate and flt(rate[0][0]) or 0.00
}
def check_duplicate(self, finder=0):
il = getlist(self.doclist, "sales_bom_items")
if not il:
webnotes.msgprint("Add atleast one item")
return
# get all Sales BOM that have the first item
sbl = webnotes.conn.sql("""select distinct parent from `tabSales BOM Item` where item_code=%s
and parent != %s and docstatus != 2""", (il[0].item_code, self.doc.name))
# check all siblings
sub_items = [[d.item_code, flt(d.qty)] for d in il]
for s in sbl:
t = webnotes.conn.sql("""select item_code, qty from `tabSales BOM Item` where parent=%s and
docstatus != 2""", s[0])
t = [[d[0], flt(d[1])] for d in t]
if self.has_same_items(sub_items, t):
webnotes.msgprint("%s has the same Sales BOM details" % s[0])
raise Exception
if finder:
webnotes.msgprint("There is no Sales BOM present with the following Combination.")
def has_same_items(self, l1, l2):
if len(l1)!=len(l2): return 0
for l in l2:
if l not in l1:
return 0
for l in l1:
if l not in l2:
return 0
return 1

View File

@@ -1,97 +0,0 @@
[
{
"creation": "2013-01-10 16:34:29",
"docstatus": 0,
"modified": "2013-01-22 14:57:23",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"description": "Aggregate group of **Items** into another **Item**. This is useful if you are bundling a certain **Items** into a package and you maintain stock of the packed **Items** and not the aggregate **Item**. \n\nThe package **Item** will have \"Is Stock Item\" as \"No\" and \"Is Sales Item\" as \"Yes\".\n\nFor Example: If you are selling Laptops and Backpacks separately and have a special price if the customer buys both, then the Laptop + Backpack will be a new Sales BOM Item.\n\nNote: BOM = Bill of Materials",
"doctype": "DocType",
"document_type": "Master",
"is_submittable": 0,
"module": "Stock",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Sales BOM",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"amend": 0,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Sales BOM",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"submit": 0
},
{
"doctype": "DocType",
"name": "Sales BOM"
},
{
"doctype": "DocField",
"fieldname": "basic_section",
"fieldtype": "Section Break",
"label": "Sales BOM Item"
},
{
"description": "The Item that represents the Package. This Item must have \"Is Stock Item\" as \"No\" and \"Is Sales Item\" as \"Yes\"",
"doctype": "DocField",
"fieldname": "new_item_code",
"fieldtype": "Link",
"label": "Parent Item",
"no_copy": 1,
"oldfieldname": "new_item_code",
"oldfieldtype": "Data",
"options": "Item",
"reqd": 1
},
{
"description": "List items that form the package.",
"doctype": "DocField",
"fieldname": "item_section",
"fieldtype": "Section Break",
"label": "Package Items"
},
{
"doctype": "DocField",
"fieldname": "sales_bom_items",
"fieldtype": "Table",
"label": "Sales BOM Items",
"oldfieldname": "sales_bom_items",
"oldfieldtype": "Table",
"options": "Sales BOM Item",
"reqd": 1
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Material Manager",
"write": 1
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Material User",
"write": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales User",
"write": 1
}
]

View File

@@ -1,20 +0,0 @@
test_records = [
[
{
"doctype": "Sales BOM",
"new_item_code": "_Test Sales BOM Item"
},
{
"doctype": "Sales BOM Item",
"item_code": "_Test Item",
"parentfield": "sales_bom_items",
"qty": 5.0
},
{
"doctype": "Sales BOM Item",
"item_code": "_Test Item Home Desktop 100",
"parentfield": "sales_bom_items",
"qty": 2.0
}
],
]

View File

@@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@@ -1,22 +0,0 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl

View File

@@ -1,75 +0,0 @@
[
{
"creation": "2013-02-22 01:28:03",
"docstatus": 0,
"modified": "2013-03-07 07:03:30",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "DocType",
"istable": 1,
"module": "Stock",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Sales BOM Item",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"doctype": "DocType",
"name": "Sales BOM Item"
},
{
"doctype": "DocField",
"fieldname": "item_code",
"fieldtype": "Link",
"label": "Item",
"oldfieldname": "item_code",
"oldfieldtype": "Link",
"options": "Item",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "qty",
"fieldtype": "Float",
"label": "Qty",
"oldfieldname": "qty",
"oldfieldtype": "Currency",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "description",
"fieldtype": "Text",
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Text",
"print_width": "300px",
"width": "300px"
},
{
"doctype": "DocField",
"fieldname": "rate",
"fieldtype": "Float",
"label": "Rate",
"oldfieldname": "rate",
"oldfieldtype": "Currency"
},
{
"doctype": "DocField",
"fieldname": "uom",
"fieldtype": "Link",
"label": "UOM",
"oldfieldname": "uom",
"oldfieldtype": "Link",
"options": "UOM",
"read_only": 1,
"search_index": 0
}
]

View File

@@ -119,7 +119,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
var qty_diff = sl.qty;
var value_diff = me.get_value_diff(wh, sl, is_fifo);
if(sl_posting_date < from_date) {
item.opening_qty += qty_diff;
item.opening_value += value_diff;
@@ -146,6 +146,8 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
} else {
break;
}
me.round_item_values(item);
}
}

View File

@@ -24,16 +24,22 @@ def execute(filters=None):
columns = get_columns(filters)
item_map = get_item_details()
pl = get_price_list()
last_purchase_rate = get_last_purchase_rate()
bom_rate = get_item_bom_rate()
val_rate_map = get_valuation_rate()
precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
data = []
for item in sorted(item_map):
data.append([item, item_map[item]["item_name"],
item_map[item]["description"], item_map[item]["stock_uom"],
flt(item_map[item]["last_purchase_rate"]), val_rate_map.get(item, 0),
pl.get(item, {}).get("selling"), pl.get(item, {}).get("buying"),
bom_rate.get(item, 0), flt(item_map[item]["standard_rate"])
flt(last_purchase_rate.get(item, 0), precision),
flt(val_rate_map.get(item, 0), precision),
pl.get(item, {}).get("selling"),
pl.get(item, {}).get("buying"),
flt(bom_rate.get(item, 0), precision),
flt(item_map[item]["standard_rate"], precision)
])
return columns, data
@@ -53,7 +59,7 @@ def get_item_details():
item_map = {}
for i in webnotes.conn.sql("select name, item_name, description, \
stock_uom, standard_rate, last_purchase_rate from tabItem \
stock_uom, standard_rate from tabItem \
order by item_code", as_dict=1):
item_map.setdefault(i.name, i)
@@ -84,25 +90,61 @@ def get_price_list():
return item_rate_map
def get_last_purchase_rate():
item_last_purchase_rate_map = {}
query = """select * from (select
result.item_code,
result.purchase_rate
from (
(select
po_item.item_code,
po_item.item_name,
po.transaction_date as posting_date,
po_item.purchase_ref_rate,
po_item.discount_rate,
po_item.purchase_rate
from `tabPurchase Order` po, `tabPurchase Order Item` po_item
where po.name = po_item.parent and po.docstatus = 1)
union
(select
pr_item.item_code,
pr_item.item_name,
pr.posting_date,
pr_item.purchase_ref_rate,
pr_item.discount_rate,
pr_item.purchase_rate
from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
where pr.name = pr_item.parent and pr.docstatus = 1)
) result
order by result.item_code asc, result.posting_date desc) result_wrapper
group by item_code"""
for d in webnotes.conn.sql(query, as_dict=1):
item_last_purchase_rate_map.setdefault(d.item_code, d.purchase_rate)
return item_last_purchase_rate_map
def get_item_bom_rate():
"""Get BOM rate of an item from BOM"""
bom_map = {}
item_bom_map = {}
for b in webnotes.conn.sql("""select item, (total_cost/quantity) as bom_rate
from `tabBOM` where is_active=1 and is_default=1""", as_dict=1):
bom_map.setdefault(b.item, flt(b.bom_rate))
item_bom_map.setdefault(b.item, flt(b.bom_rate))
return bom_map
return item_bom_map
def get_valuation_rate():
"""Get an average valuation rate of an item from all warehouses"""
val_rate_map = {}
item_val_rate_map = {}
for d in webnotes.conn.sql("""select item_code,
sum(actual_qty*valuation_rate)/sum(actual_qty) as val_rate
from tabBin where actual_qty > 0 group by item_code""", as_dict=1):
val_rate_map.setdefault(d.item_code, d.val_rate)
item_val_rate_map.setdefault(d.item_code, d.val_rate)
return val_rate_map
return item_val_rate_map