mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 19:19:17 +00:00
Opportunity Items fetching into Request for quotation
This commit is contained in:
@@ -84,19 +84,11 @@ class Opportunity(TransactionBase):
|
|||||||
self.delete_events()
|
self.delete_events()
|
||||||
|
|
||||||
def has_active_quotation(self):
|
def has_active_quotation(self):
|
||||||
if not self.with_items:
|
return frappe.db.sql("""
|
||||||
return frappe.get_all('Quotation',
|
select q.name
|
||||||
{
|
from `tabQuotation` q, `tabQuotation Item` qi
|
||||||
'opportunity': self.name,
|
where q.name = qi.parent and q.docstatus=1 and qi.prevdoc_docname =%s
|
||||||
'status': ("not in", ['Lost', 'Closed']),
|
and q.status not in ('Lost', 'Closed')""", self.name)
|
||||||
'docstatus': 1
|
|
||||||
}, 'name')
|
|
||||||
else:
|
|
||||||
return frappe.db.sql("""
|
|
||||||
select q.name
|
|
||||||
from `tabQuotation` q, `tabQuotation Item` qi
|
|
||||||
where q.name = qi.parent and q.docstatus=1 and qi.prevdoc_docname =%s
|
|
||||||
and q.status not in ('Lost', 'Closed')""", self.name)
|
|
||||||
|
|
||||||
def has_ordered_quotation(self):
|
def has_ordered_quotation(self):
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
@@ -193,6 +185,27 @@ def get_item_details(item_code):
|
|||||||
'brand': item and item[0]['brand'] or ''
|
'brand': item and item[0]['brand'] or ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_request_for_quotation(source_name, target_doc=None):
|
||||||
|
doclist = get_mapped_doc("Opportunity", source_name, {
|
||||||
|
"Opportunity": {
|
||||||
|
"doctype": "Request for Quotation",
|
||||||
|
"validation": {
|
||||||
|
"enquiry_type": ["=", "Sales"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Opportunity Item": {
|
||||||
|
"doctype": "Request for Quotation Item",
|
||||||
|
"field_map": [
|
||||||
|
["name", "opportunity_item"],
|
||||||
|
["parent", "opportunity"],
|
||||||
|
["uom", "uom"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, target_doc)
|
||||||
|
|
||||||
|
return doclist
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_quotation(source_name, target_doc=None):
|
def make_quotation(source_name, target_doc=None):
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
@@ -220,8 +233,6 @@ def make_quotation(source_name, target_doc=None):
|
|||||||
|
|
||||||
quotation.run_method("set_missing_values")
|
quotation.run_method("set_missing_values")
|
||||||
quotation.run_method("calculate_taxes_and_totals")
|
quotation.run_method("calculate_taxes_and_totals")
|
||||||
if not source.with_items:
|
|
||||||
quotation.opportunity = source.name
|
|
||||||
|
|
||||||
doclist = get_mapped_doc("Opportunity", source_name, {
|
doclist = get_mapped_doc("Opportunity", source_name, {
|
||||||
"Opportunity": {
|
"Opportunity": {
|
||||||
@@ -247,6 +258,7 @@ def make_quotation(source_name, target_doc=None):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_supplier_quotation(source_name, target_doc=None):
|
def make_supplier_quotation(source_name, target_doc=None):
|
||||||
|
frappe.msgprint("python");
|
||||||
doclist = get_mapped_doc("Opportunity", source_name, {
|
doclist = get_mapped_doc("Opportunity", source_name, {
|
||||||
"Opportunity": {
|
"Opportunity": {
|
||||||
"doctype": "Supplier Quotation",
|
"doctype": "Supplier Quotation",
|
||||||
@@ -261,9 +273,11 @@ def make_supplier_quotation(source_name, target_doc=None):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, target_doc)
|
}, target_doc)
|
||||||
|
|
||||||
return doclist
|
return doclist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def set_multiple_status(names, status):
|
def set_multiple_status(names, status):
|
||||||
names = json.loads(names)
|
names = json.loads(names)
|
||||||
@@ -284,4 +298,4 @@ def auto_close_opportunity():
|
|||||||
doc.status = "Closed"
|
doc.status = "Closed"
|
||||||
doc.flags.ignore_permissions = True
|
doc.flags.ignore_permissions = True
|
||||||
doc.flags.ignore_mandatory = True
|
doc.flags.ignore_mandatory = True
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user