mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-19 19:37:56 +00:00
Merge branch 'develop' into procurement-tracker
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -964,7 +964,7 @@ def invalidate_item_variants_cache_for_website(doc):
|
||||
|
||||
if item_code:
|
||||
item_cache = ItemVariantsCacheManager(item_code)
|
||||
item_cache.clear_cache()
|
||||
item_cache.rebuild_cache()
|
||||
|
||||
|
||||
def check_stock_uom_with_bin(item, stock_uom):
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1116,7 +1116,7 @@ class StockEntry(StockController):
|
||||
frappe.MappingMismatchError)
|
||||
|
||||
def validate_batch(self):
|
||||
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Send to Subcontractor", "Material Issue"]:
|
||||
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Send to Subcontractor"]:
|
||||
for item in self.get("items"):
|
||||
if item.batch_no:
|
||||
disabled = frappe.db.get_value("Batch", item.batch_no, "disabled")
|
||||
|
||||
@@ -492,7 +492,7 @@ def insert_item_price(args):
|
||||
def get_item_price(args, item_code, ignore_party=False):
|
||||
"""
|
||||
Get name, price_list_rate from Item Price based on conditions
|
||||
Check if the Derised qty is within the increment of the packing list.
|
||||
Check if the desired qty is within the increment of the packing list.
|
||||
:param args: dict (or frappe._dict) with mandatory fields price_list, uom
|
||||
optional fields min_qty, transaction_date, customer, supplier
|
||||
:param item_code: str, Item Doctype field item_code
|
||||
@@ -530,11 +530,11 @@ def get_price_list_rate_for(args, item_code):
|
||||
for min_qty 9 and min_qty 20. It returns Item Price Rate for qty 9 as
|
||||
the best fit in the range of avaliable min_qtyies
|
||||
|
||||
:param customer: link to Customer DocType
|
||||
:param supplier: link to Supplier DocType
|
||||
:param customer: link to Customer DocType
|
||||
:param supplier: link to Supplier DocType
|
||||
:param price_list: str (Standard Buying or Standard Selling)
|
||||
:param item_code: str, Item Doctype field item_code
|
||||
:param qty: Derised Qty
|
||||
:param qty: Desired Qty
|
||||
:param transaction_date: Date of the price
|
||||
"""
|
||||
item_price_args = {
|
||||
@@ -559,7 +559,7 @@ def get_price_list_rate_for(args, item_code):
|
||||
|
||||
general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party"))
|
||||
if not general_price_list_rate and args.get("uom") != args.get("stock_uom"):
|
||||
item_price_args["args"] = args.get("stock_uom")
|
||||
item_price_args["uom"] = args.get("stock_uom")
|
||||
general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party"))
|
||||
|
||||
if general_price_list_rate:
|
||||
@@ -575,11 +575,11 @@ def get_price_list_rate_for(args, item_code):
|
||||
|
||||
def check_packing_list(price_list_rate_name, desired_qty, item_code):
|
||||
"""
|
||||
Check if the Derised qty is within the increment of the packing list.
|
||||
Check if the desired qty is within the increment of the packing list.
|
||||
:param price_list_rate_name: Name of Item Price
|
||||
:param desired_qty: Derised Qt
|
||||
:param desired_qty: Desired Qt
|
||||
:param item_code: str, Item Doctype field item_code
|
||||
:param qty: Derised Qt
|
||||
:param qty: Desired Qt
|
||||
"""
|
||||
|
||||
flag = True
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
/* eslint-disable */
|
||||
|
||||
frappe.query_reports["Inactive Items"] = {
|
||||
"filters": [
|
||||
{
|
||||
fieldname: "item",
|
||||
label: __("Item"),
|
||||
fieldtype: "Link",
|
||||
options: "Item"
|
||||
},
|
||||
{
|
||||
fieldname: "item_group",
|
||||
label: __("Item Group"),
|
||||
fieldtype: "Link",
|
||||
options: "Item Group"
|
||||
},
|
||||
{
|
||||
fieldname: "based_on",
|
||||
label: __("Based On"),
|
||||
fieldtype: "Select",
|
||||
options: "Sales Order\nSales Invoice",
|
||||
default: "Sales Order"
|
||||
},
|
||||
{
|
||||
fieldname: "days",
|
||||
label: __("Days Since Last order"),
|
||||
fieldtype: "Select",
|
||||
options: [30, 60, 90],
|
||||
default: 30
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"creation": "2019-04-16 16:05:00.647308",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"letter_head": "Test Letter Head 1",
|
||||
"modified": "2019-04-16 16:06:33.630043",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Inactive Items",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 0,
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Inactive Items",
|
||||
"report_type": "Script Report",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Accounts User"
|
||||
},
|
||||
{
|
||||
"role": "Accounts Manager"
|
||||
},
|
||||
{
|
||||
"role": "Auditor"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import getdate, add_days, today, cint
|
||||
from frappe import _
|
||||
|
||||
def execute(filters=None):
|
||||
|
||||
columns = get_columns()
|
||||
data = get_data(filters)
|
||||
return columns, data
|
||||
|
||||
def get_columns():
|
||||
|
||||
columns = [
|
||||
{
|
||||
"fieldname": "territory",
|
||||
"fieldtype": "Link",
|
||||
"label": _("Territory"),
|
||||
"options": "Territory",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"fieldname": "item_group",
|
||||
"fieldtype": "Link",
|
||||
"label": _("Item Group"),
|
||||
"options": "Item Group",
|
||||
"width": 150
|
||||
},
|
||||
{
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Link",
|
||||
"options": "Item",
|
||||
"label": "Item",
|
||||
"width": 150
|
||||
},
|
||||
{
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
"label": _("Item Name"),
|
||||
"width": 150
|
||||
},
|
||||
|
||||
{
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"label": _("Customer"),
|
||||
"options": "Customer",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"fieldname": "last_order_date",
|
||||
"fieldtype": "Date",
|
||||
"label": _("Last Order Date"),
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"fieldname": "qty",
|
||||
"fieldtype": "Float",
|
||||
"label": _("Quantity"),
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"fieldname": "days_since_last_order",
|
||||
"fieldtype": "Int",
|
||||
"label": _("Days Since Last Order"),
|
||||
"width": 100
|
||||
},
|
||||
]
|
||||
|
||||
return columns
|
||||
|
||||
|
||||
def get_data(filters):
|
||||
|
||||
data = []
|
||||
items = get_items(filters)
|
||||
sales_invoice_data = get_sales_details(filters)
|
||||
|
||||
for item in items:
|
||||
if sales_invoice_data.get(item.name):
|
||||
item_obj = sales_invoice_data[item.name]
|
||||
if item_obj.days_since_last_order > cint(filters['days']):
|
||||
row = {
|
||||
"territory": item_obj.territory,
|
||||
"item_group": item_obj.item_group,
|
||||
"item": item_obj.name,
|
||||
"item_name": item_obj.item_name,
|
||||
"customer": item_obj.customer,
|
||||
"last_order_date": item_obj.last_order_date,
|
||||
"qty": item_obj.qty,
|
||||
"days_since_last_order": item_obj.days_since_last_order
|
||||
}
|
||||
data.append(row)
|
||||
else:
|
||||
row = {
|
||||
"item_group": item.item_group,
|
||||
"item": item.name,
|
||||
"item_name": item.item_name
|
||||
}
|
||||
data.append(row)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def get_sales_details(filters):
|
||||
|
||||
data = []
|
||||
item_details_map = {}
|
||||
|
||||
date_field = "s.transaction_date" if filters["based_on"] == "Sales Order" else "s.posting_date"
|
||||
|
||||
sales_data = frappe.db.sql("""
|
||||
select s.territory, s.customer, si.item_group, si.item_name, si.qty, {date_field} as last_order_date,
|
||||
DATEDIFF(CURDATE(), {date_field}) as days_since_last_order
|
||||
from `tab{doctype}` s, `tab{doctype} Item` si
|
||||
where s.name = si.parent and s.docstatus = 1
|
||||
group by si.name order by days_since_last_order """ #nosec
|
||||
.format(date_field = date_field, doctype = filters['based_on']), as_dict=1)
|
||||
|
||||
for d in sales_data:
|
||||
item_details_map.setdefault(d.item_name, d)
|
||||
|
||||
return item_details_map
|
||||
|
||||
def get_items(filters):
|
||||
|
||||
filters_dict = {
|
||||
"disabled": 0,
|
||||
"is_stock_item": 1
|
||||
}
|
||||
|
||||
if filters.get("item_group"):
|
||||
filters_dict.update({
|
||||
"item_group": filters["item_group"]
|
||||
})
|
||||
|
||||
if filters.get("item"):
|
||||
filters_dict.update({
|
||||
"name": filters["item"]
|
||||
})
|
||||
|
||||
items = frappe.get_all("Item", fields=["name", "item_group", "item_name"], filters=filters_dict, order_by="name")
|
||||
|
||||
return items
|
||||
|
||||
Reference in New Issue
Block a user