Added brand in item price doctype, item prices report (#13900)
This commit is contained in:
parent
c4323cb6ba
commit
125c0caf12
@ -525,3 +525,4 @@ erpnext.patches.v11_0.set_default_email_template_in_hr
|
|||||||
erpnext.patches.v10_0.taxes_issue_with_pos
|
erpnext.patches.v10_0.taxes_issue_with_pos
|
||||||
erpnext.patches.v10_1.transfer_subscription_to_auto_repeat
|
erpnext.patches.v10_1.transfer_subscription_to_auto_repeat
|
||||||
erpnext.patches.v10_1.drop_old_subscription_records
|
erpnext.patches.v10_1.drop_old_subscription_records
|
||||||
|
erpnext.patches.v11_0.update_brand_in_item_price
|
||||||
14
erpnext/patches/v11_0/update_brand_in_item_price.py
Normal file
14
erpnext/patches/v11_0/update_brand_in_item_price.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc('stock', 'doctype', 'item_price')
|
||||||
|
|
||||||
|
frappe.db.sql(""" update `tabItem Price`, `tabItem`
|
||||||
|
set
|
||||||
|
`tabItem Price`.brand = `tabItem`.brand
|
||||||
|
where
|
||||||
|
`tabItem Price`.item_code = `tabItem`.name
|
||||||
|
and `tabItem`.brand is not null and `tabItem`.brand != ''""")
|
||||||
@ -527,8 +527,8 @@ class Item(WebsiteGenerator):
|
|||||||
|
|
||||||
def update_item_price(self):
|
def update_item_price(self):
|
||||||
frappe.db.sql("""update `tabItem Price` set item_name=%s,
|
frappe.db.sql("""update `tabItem Price` set item_name=%s,
|
||||||
item_description=%s, modified=NOW() where item_code=%s""",
|
item_description=%s, brand=%s, modified=NOW() where item_code=%s""",
|
||||||
(self.item_name, self.description, self.name))
|
(self.item_name, self.description, self.brand, self.name))
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
super(Item, self).on_trash()
|
super(Item, self).on_trash()
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -72,6 +73,7 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -101,6 +103,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -130,6 +133,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -159,6 +163,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -189,6 +194,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -219,6 +225,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -251,6 +258,7 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1,
|
"search_index": 1,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -283,6 +291,7 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -311,6 +320,39 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "brand",
|
||||||
|
"fieldtype": "Read Only",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Brand",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "item_code.brand",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"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,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -340,6 +382,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -369,6 +412,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -383,7 +427,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-12-01 13:03:53.397382",
|
"modified": "2018-05-03 12:50:14.207842",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Item Price",
|
"name": "Item Price",
|
||||||
@ -391,7 +435,6 @@
|
|||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
"amend": 0,
|
||||||
"apply_user_permissions": 0,
|
|
||||||
"cancel": 0,
|
"cancel": 0,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
@ -411,7 +454,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
"amend": 0,
|
||||||
"apply_user_permissions": 0,
|
|
||||||
"cancel": 0,
|
"cancel": 0,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
|
|||||||
@ -19,6 +19,12 @@ def get_columns():
|
|||||||
"options": "Item",
|
"options": "Item",
|
||||||
"width": 120
|
"width": 120
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": _("Brand"),
|
||||||
|
"fieldname": "brand",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": _("Warehouse"),
|
"label": _("Warehouse"),
|
||||||
"fieldname": "warehouse",
|
"fieldname": "warehouse",
|
||||||
@ -71,7 +77,7 @@ def get_item_price_qty_data(filters):
|
|||||||
conditions += "where a.item_code=%(item_code)s"
|
conditions += "where a.item_code=%(item_code)s"
|
||||||
|
|
||||||
item_results = frappe.db.sql("""select a.item_code as item_name, a.name as price_list_name,
|
item_results = frappe.db.sql("""select a.item_code as item_name, a.name as price_list_name,
|
||||||
b.warehouse as warehouse, b.actual_qty as actual_qty
|
a.brand as brand, b.warehouse as warehouse, b.actual_qty as actual_qty
|
||||||
from `tabItem Price` a left join `tabBin` b
|
from `tabItem Price` a left join `tabBin` b
|
||||||
ON a.item_code = b.item_code
|
ON a.item_code = b.item_code
|
||||||
{conditions}"""
|
{conditions}"""
|
||||||
@ -87,6 +93,7 @@ def get_item_price_qty_data(filters):
|
|||||||
for item_dict in item_results:
|
for item_dict in item_results:
|
||||||
data = {
|
data = {
|
||||||
'item_name': item_dict.item_name,
|
'item_name': item_dict.item_name,
|
||||||
|
'brand': item_dict.brand,
|
||||||
'warehouse': item_dict.warehouse,
|
'warehouse': item_dict.warehouse,
|
||||||
'stock_available': item_dict.actual_qty or 0,
|
'stock_available': item_dict.actual_qty or 0,
|
||||||
'buying_price_list': "",
|
'buying_price_list': "",
|
||||||
|
|||||||
@ -21,7 +21,7 @@ def execute(filters=None):
|
|||||||
data = []
|
data = []
|
||||||
for item in sorted(item_map):
|
for item in sorted(item_map):
|
||||||
data.append([item, item_map[item]["item_name"],item_map[item]["item_group"],
|
data.append([item, item_map[item]["item_name"],item_map[item]["item_group"],
|
||||||
item_map[item]["description"], item_map[item]["stock_uom"],
|
item_map[item]["brand"], 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"),
|
||||||
@ -34,7 +34,8 @@ def execute(filters=None):
|
|||||||
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",_("Item Group") + ":Link/Item Group:125", _("Description") + "::150", _("UOM") + ":Link/UOM:80",
|
columns = [_("Item") + ":Link/Item:100", _("Item Name") + "::150",_("Item Group") + ":Link/Item Group:125",
|
||||||
|
_("Brand") + "::100", _("Description") + "::150", _("UOM") + ":Link/UOM:80",
|
||||||
_("Last Purchase Rate") + ":Currency:90", _("Valuation Rate") + ":Currency:80", _("Sales Price List") + "::180",
|
_("Last Purchase Rate") + ":Currency:90", _("Valuation Rate") + ":Currency:80", _("Sales Price List") + "::180",
|
||||||
_("Purchase Price List") + "::180", _("BOM Rate") + ":Currency:90"]
|
_("Purchase Price List") + "::180", _("BOM Rate") + ":Currency:90"]
|
||||||
|
|
||||||
@ -45,9 +46,9 @@ def get_item_details():
|
|||||||
|
|
||||||
item_map = {}
|
item_map = {}
|
||||||
|
|
||||||
for i in frappe.db.sql("select name, item_group, item_name, description, \
|
for i in frappe.db.sql("""select name, item_group, item_name, description,
|
||||||
stock_uom from tabItem \
|
brand, stock_uom from tabItem
|
||||||
order by item_code, item_group", as_dict=1):
|
order by item_code, item_group""", as_dict=1):
|
||||||
item_map.setdefault(i.name, i)
|
item_map.setdefault(i.name, i)
|
||||||
|
|
||||||
return item_map
|
return item_map
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
{
|
{
|
||||||
"add_total_row": 0,
|
"add_total_row": 0,
|
||||||
"apply_user_permissions": 1,
|
|
||||||
"creation": "2013-09-25 10:21:15",
|
"creation": "2013-09-25 10:21:15",
|
||||||
"disabled": 0,
|
"disabled": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"idx": 3,
|
"idx": 3,
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"json": "{\"add_total_row\": 0, \"sort_by\": \"Item Price.modified\", \"sort_order\": \"desc\", \"sort_by_next\": null, \"filters\": [], \"sort_order_next\": \"desc\", \"columns\": [[\"name\", \"Item Price\"], [\"price_list\", \"Item Price\"], [\"item_code\", \"Item Price\"], [\"item_name\", \"Item Price\"], [\"item_description\", \"Item Price\"], [\"price_list_rate\", \"Item Price\"], [\"buying\", \"Item Price\"], [\"selling\", \"Item Price\"], [\"currency\", \"Item Price\"]]}",
|
"json": "{\"fields\": [[\"name\", \"Item Price\"], [\"price_list\", \"Item Price\"], [\"currency\", \"Item Price\"], [\"item_code\", \"Item Price\"], [\"brand\", \"Item Price\"], [\"price_list_rate\", \"Item Price\"], [\"docstatus\", \"Item Price\"]], \"order_by\": \"`tabItem Price`.`modified` asc\", \"add_total_row\": 0, \"filters\": []}",
|
||||||
"modified": "2017-02-24 20:02:09.364303",
|
"modified": "2018-05-03 12:48:39.802088",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Item-wise Price List Rate",
|
"name": "Item-wise Price List Rate",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user