Standard Rate field removed from item. Fixes #1688

This commit is contained in:
Nabin Hait 2014-05-29 16:18:49 +05:30
parent 732a7e81a0
commit e71159d6ea
4 changed files with 41 additions and 50 deletions

View File

@ -54,7 +54,7 @@ class BOM(Document):
def get_item_det(self, item_code): def get_item_det(self, item_code):
item = frappe.db.sql("""select name, is_asset_item, is_purchase_item, item = frappe.db.sql("""select name, is_asset_item, is_purchase_item,
docstatus, description, is_sub_contracted_item, stock_uom, default_bom, docstatus, description, is_sub_contracted_item, stock_uom, default_bom,
last_purchase_rate, standard_rate, is_manufactured_item last_purchase_rate, is_manufactured_item
from `tabItem` where name=%s""", item_code, as_dict = 1) from `tabItem` where name=%s""", item_code, as_dict = 1)
return item return item
@ -111,8 +111,6 @@ class BOM(Document):
frappe.throw(_("Please select Price List")) frappe.throw(_("Please select Price List"))
rate = frappe.db.get_value("Item Price", {"price_list": self.buying_price_list, rate = frappe.db.get_value("Item Price", {"price_list": self.buying_price_list,
"item_code": arg["item_code"]}, "price_list_rate") or 0 "item_code": arg["item_code"]}, "price_list_rate") or 0
elif self.rm_cost_as_per == 'Standard Rate':
rate = arg['standard_rate']
return rate return rate

View File

@ -1,5 +1,5 @@
{ {
"creation": "2013-02-22 01:27:49.000000", "creation": "2013-02-22 01:27:49",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"fields": [ "fields": [
@ -79,7 +79,8 @@
"fieldtype": "Float", "fieldtype": "Float",
"in_list_view": 1, "in_list_view": 1,
"label": "Rate", "label": "Rate",
"permlevel": 0 "permlevel": 0,
"reqd": 1
}, },
{ {
"fieldname": "col_break2", "fieldname": "col_break2",
@ -133,9 +134,12 @@
], ],
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"modified": "2014-02-03 12:47:39.000000", "modified": "2014-05-29 15:56:31.859868",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "BOM Item", "name": "BOM Item",
"owner": "Administrator" "owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
} }

View File

@ -439,16 +439,6 @@
"permlevel": 0, "permlevel": 0,
"read_only": 1 "read_only": 1
}, },
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"fieldname": "standard_rate",
"fieldtype": "Float",
"label": "Standard Rate",
"oldfieldname": "standard_rate",
"oldfieldtype": "Currency",
"permlevel": 0,
"read_only": 0
},
{ {
"depends_on": "eval:doc.is_purchase_item==\"Yes\"", "depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"fieldname": "column_break2", "fieldname": "column_break2",
@ -835,7 +825,7 @@
"icon": "icon-tag", "icon": "icon-tag",
"idx": 1, "idx": 1,
"max_attachments": 1, "max_attachments": 1,
"modified": "2014-05-21 15:37:30.124881", "modified": "2014-05-29 16:05:53.126214",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Item", "name": "Item",

View File

@ -7,7 +7,7 @@ from frappe.utils import flt
def execute(filters=None): def execute(filters=None):
if not filters: filters = {} if not filters: filters = {}
columns = get_columns(filters) columns = get_columns(filters)
item_map = get_item_details() item_map = get_item_details()
pl = get_price_list() pl = get_price_list()
@ -19,34 +19,33 @@ def execute(filters=None):
precision = get_currency_precision() or 2 precision = get_currency_precision() or 2
data = [] data = []
for item in sorted(item_map): for item in sorted(item_map):
data.append([item, item_map[item]["item_name"], data.append([item, item_map[item]["item_name"],
item_map[item]["description"], item_map[item]["stock_uom"], item_map[item]["description"], item_map[item]["stock_uom"],
flt(last_purchase_rate.get(item, 0), precision), flt(last_purchase_rate.get(item, 0), precision),
flt(val_rate_map.get(item, 0), precision), flt(val_rate_map.get(item, 0), precision),
pl.get(item, {}).get("Selling"), pl.get(item, {}).get("Selling"),
pl.get(item, {}).get("Buying"), pl.get(item, {}).get("Buying"),
flt(bom_rate.get(item, 0), precision), flt(bom_rate.get(item, 0), precision)
flt(item_map[item]["standard_rate"], precision)
]) ])
return columns, data return columns, data
def get_columns(filters): def get_columns(filters):
"""return columns based on filters""" """return columns based on filters"""
columns = ["Item:Link/Item:100", "Item Name::150", "Description::150", "UOM:Link/UOM:80", columns = ["Item:Link/Item:100", "Item Name::150", "Description::150", "UOM:Link/UOM:80",
"Last Purchase Rate:Currency:90", "Valuation Rate:Currency:80", "Sales Price List::80", "Last Purchase Rate:Currency:90", "Valuation Rate:Currency:80", "Sales Price List::80",
"Purchase Price List::80", "BOM Rate:Currency:90", "Standard Rate:Currency:100"] "Purchase Price List::80", "BOM Rate:Currency:90"]
return columns return columns
def get_item_details(): def get_item_details():
"""returns all items details""" """returns all items details"""
item_map = {} item_map = {}
for i in frappe.db.sql("select name, item_name, description, \ for i in frappe.db.sql("select name, item_name, description, \
stock_uom, standard_rate from tabItem \ stock_uom from tabItem \
order by item_code", as_dict=1): order by item_code", as_dict=1):
item_map.setdefault(i.name, i) item_map.setdefault(i.name, i)
@ -57,42 +56,42 @@ def get_price_list():
rate = {} rate = {}
price_list = frappe.db.sql("""select ip.item_code, ip.buying, ip.selling, price_list = frappe.db.sql("""select ip.item_code, ip.buying, ip.selling,
concat(ip.price_list, " - ", ip.currency, " ", ip.price_list_rate) as price concat(ip.price_list, " - ", ip.currency, " ", ip.price_list_rate) as price
from `tabItem Price` ip, `tabPrice List` pl from `tabItem Price` ip, `tabPrice List` pl
where ip.price_list=pl.name and pl.enabled=1""", as_dict=1) where ip.price_list=pl.name and pl.enabled=1""", as_dict=1)
for j in price_list: for j in price_list:
if j.price: if j.price:
rate.setdefault(j.item_code, {}).setdefault("Buying" if j.buying else "Selling", []).append(j.price) rate.setdefault(j.item_code, {}).setdefault("Buying" if j.buying else "Selling", []).append(j.price)
item_rate_map = {} item_rate_map = {}
for item in rate: for item in rate:
for buying_or_selling in rate[item]: for buying_or_selling in rate[item]:
item_rate_map.setdefault(item, {}).setdefault(buying_or_selling, item_rate_map.setdefault(item, {}).setdefault(buying_or_selling,
", ".join(rate[item].get(buying_or_selling, []))) ", ".join(rate[item].get(buying_or_selling, [])))
return item_rate_map return item_rate_map
def get_last_purchase_rate(): def get_last_purchase_rate():
item_last_purchase_rate_map = {} item_last_purchase_rate_map = {}
query = """select * from (select query = """select * from (select
result.item_code, result.item_code,
result.base_rate result.base_rate
from ( from (
(select (select
po_item.item_code, po_item.item_code,
po_item.item_name, po_item.item_name,
po.transaction_date as posting_date, po.transaction_date as posting_date,
po_item.base_price_list_rate, po_item.base_price_list_rate,
po_item.discount_percentage, po_item.discount_percentage,
po_item.base_rate po_item.base_rate
from `tabPurchase Order` po, `tabPurchase Order Item` po_item from `tabPurchase Order` po, `tabPurchase Order Item` po_item
where po.name = po_item.parent and po.docstatus = 1) where po.name = po_item.parent and po.docstatus = 1)
union union
(select (select
pr_item.item_code, pr_item.item_code,
pr_item.item_name, pr_item.item_name,
pr.posting_date, pr.posting_date,
@ -114,8 +113,8 @@ def get_item_bom_rate():
"""Get BOM rate of an item from BOM""" """Get BOM rate of an item from BOM"""
item_bom_map = {} item_bom_map = {}
for b in frappe.db.sql("""select item, (total_cost/quantity) as bom_rate for b in frappe.db.sql("""select item, (total_cost/quantity) as bom_rate
from `tabBOM` where is_active=1 and is_default=1""", as_dict=1): from `tabBOM` where is_active=1 and is_default=1""", as_dict=1):
item_bom_map.setdefault(b.item, flt(b.bom_rate)) item_bom_map.setdefault(b.item, flt(b.bom_rate))
@ -125,8 +124,8 @@ def get_valuation_rate():
"""Get an average valuation rate of an item from all warehouses""" """Get an average valuation rate of an item from all warehouses"""
item_val_rate_map = {} item_val_rate_map = {}
for d in frappe.db.sql("""select item_code, for d in frappe.db.sql("""select item_code,
sum(actual_qty*valuation_rate)/sum(actual_qty) as val_rate sum(actual_qty*valuation_rate)/sum(actual_qty) as val_rate
from tabBin where actual_qty > 0 group by item_code""", as_dict=1): from tabBin where actual_qty > 0 group by item_code""", as_dict=1):
item_val_rate_map.setdefault(d.item_code, d.val_rate) item_val_rate_map.setdefault(d.item_code, d.val_rate)