Merge branch 'develop' into purchase-order/internal-supplier

This commit is contained in:
Sagar Sharma 2022-11-17 14:08:07 +05:30 committed by GitHub
commit 1349d24514
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 72 deletions

View File

@ -478,7 +478,7 @@ def get_rfq_containing_supplier(doctype, txt, searchfield, start, page_len, filt
conditions += "and rfq.transaction_date = '{0}'".format(filters.get("transaction_date")) conditions += "and rfq.transaction_date = '{0}'".format(filters.get("transaction_date"))
rfq_data = frappe.db.sql( rfq_data = frappe.db.sql(
""" f"""
select select
distinct rfq.name, rfq.transaction_date, distinct rfq.name, rfq.transaction_date,
rfq.company rfq.company
@ -486,15 +486,18 @@ def get_rfq_containing_supplier(doctype, txt, searchfield, start, page_len, filt
`tabRequest for Quotation` rfq, `tabRequest for Quotation Supplier` rfq_supplier `tabRequest for Quotation` rfq, `tabRequest for Quotation Supplier` rfq_supplier
where where
rfq.name = rfq_supplier.parent rfq.name = rfq_supplier.parent
and rfq_supplier.supplier = '{0}' and rfq_supplier.supplier = %(supplier)s
and rfq.docstatus = 1 and rfq.docstatus = 1
and rfq.company = '{1}' and rfq.company = %(company)s
{2} {conditions}
order by rfq.transaction_date ASC order by rfq.transaction_date ASC
limit %(page_len)s offset %(start)s """.format( limit %(page_len)s offset %(start)s """,
filters.get("supplier"), filters.get("company"), conditions {
), "page_len": page_len,
{"page_len": page_len, "start": start}, "start": start,
"company": filters.get("company"),
"supplier": filters.get("supplier"),
},
as_dict=1, as_dict=1,
) )

View File

@ -10,7 +10,7 @@ import json
import frappe import frappe
from frappe import _, msgprint from frappe import _, msgprint
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe.utils import cstr, flt, get_link_to_form, getdate, new_line_sep, nowdate from frappe.utils import cint, cstr, flt, get_link_to_form, getdate, new_line_sep, nowdate
from erpnext.buying.utils import check_on_hold_or_closed_status, validate_for_items from erpnext.buying.utils import check_on_hold_or_closed_status, validate_for_items
from erpnext.controllers.buying_controller import BuyingController from erpnext.controllers.buying_controller import BuyingController
@ -500,13 +500,13 @@ def get_material_requests_based_on_supplier(doctype, txt, searchfield, start, pa
and mr.per_ordered < 99.99 and mr.per_ordered < 99.99
and mr.docstatus = 1 and mr.docstatus = 1
and mr.status != 'Stopped' and mr.status != 'Stopped'
and mr.company = '{1}' and mr.company = %s
{2} {1}
order by mr_item.item_code ASC order by mr_item.item_code ASC
limit {3} offset {4} """.format( limit {2} offset {3} """.format(
", ".join(["%s"] * len(supplier_items)), filters.get("company"), conditions, page_len, start ", ".join(["%s"] * len(supplier_items)), conditions, cint(page_len), cint(start)
), ),
tuple(supplier_items), tuple(supplier_items) + (filters.get("company"),),
as_dict=1, as_dict=1,
) )

View File

@ -6,7 +6,7 @@ import frappe
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe.utils import cint, flt from frappe.utils import cint, cstr, flt
from erpnext.stock.doctype.quality_inspection_template.quality_inspection_template import ( from erpnext.stock.doctype.quality_inspection_template.quality_inspection_template import (
get_template_details, get_template_details,
@ -219,29 +219,32 @@ class QualityInspection(Document):
@frappe.whitelist() @frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs @frappe.validate_and_sanitize_search_inputs
def item_query(doctype, txt, searchfield, start, page_len, filters): def item_query(doctype, txt, searchfield, start, page_len, filters):
if filters.get("from"):
from frappe.desk.reportview import get_match_cond from frappe.desk.reportview import get_match_cond
mcond = get_match_cond(filters["from"]) from_doctype = cstr(filters.get("doctype"))
if not from_doctype or not frappe.db.exist("DocType", from_doctype):
return []
mcond = get_match_cond(from_doctype)
cond, qi_condition = "", "and (quality_inspection is null or quality_inspection = '')" cond, qi_condition = "", "and (quality_inspection is null or quality_inspection = '')"
if filters.get("parent"): if filters.get("parent"):
if ( if (
filters.get("from") in ["Purchase Invoice Item", "Purchase Receipt Item"] from_doctype in ["Purchase Invoice Item", "Purchase Receipt Item"]
and filters.get("inspection_type") != "In Process" and filters.get("inspection_type") != "In Process"
): ):
cond = """and item_code in (select name from `tabItem` where cond = """and item_code in (select name from `tabItem` where
inspection_required_before_purchase = 1)""" inspection_required_before_purchase = 1)"""
elif ( elif (
filters.get("from") in ["Sales Invoice Item", "Delivery Note Item"] from_doctype in ["Sales Invoice Item", "Delivery Note Item"]
and filters.get("inspection_type") != "In Process" and filters.get("inspection_type") != "In Process"
): ):
cond = """and item_code in (select name from `tabItem` where cond = """and item_code in (select name from `tabItem` where
inspection_required_before_delivery = 1)""" inspection_required_before_delivery = 1)"""
elif filters.get("from") == "Stock Entry Detail": elif from_doctype == "Stock Entry Detail":
cond = """and s_warehouse is null""" cond = """and s_warehouse is null"""
if filters.get("from") in ["Supplier Quotation Item"]: if from_doctype in ["Supplier Quotation Item"]:
qi_condition = "" qi_condition = ""
return frappe.db.sql( return frappe.db.sql(
@ -252,11 +255,11 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
{qi_condition} {cond} {mcond} {qi_condition} {cond} {mcond}
ORDER BY item_code limit {page_len} offset {start} ORDER BY item_code limit {page_len} offset {start}
""".format( """.format(
doc=filters.get("from"), doc=from_doctype,
cond=cond, cond=cond,
mcond=mcond, mcond=mcond,
start=start, start=cint(start),
page_len=page_len, page_len=cint(page_len),
qi_condition=qi_condition, qi_condition=qi_condition,
), ),
{"parent": filters.get("parent"), "txt": "%%%s%%" % txt}, {"parent": filters.get("parent"), "txt": "%%%s%%" % txt},
@ -272,11 +275,11 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
ORDER BY production_item ORDER BY production_item
limit {page_len} offset {start} limit {page_len} offset {start}
""".format( """.format(
doc=filters.get("from"), doc=from_doctype,
cond=cond, cond=cond,
mcond=mcond, mcond=mcond,
start=start, start=cint(start),
page_len=page_len, page_len=cint(page_len),
qi_condition=qi_condition, qi_condition=qi_condition,
), ),
{"reference_name": filters.get("reference_name"), "txt": "%%%s%%" % txt}, {"reference_name": filters.get("reference_name"), "txt": "%%%s%%" % txt},