Merge pull request #23233 from ruchamahabal/fix-rfq-conv-factor
fix: set conversion factor while creating RFQ from Opportunity
This commit is contained in:
commit
6ffe809c66
@ -11,6 +11,8 @@ from erpnext.stock.doctype.item.test_item import make_item
|
|||||||
from erpnext.templates.pages.rfq import check_supplier_has_docname_access
|
from erpnext.templates.pages.rfq import check_supplier_has_docname_access
|
||||||
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation
|
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation
|
||||||
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import create_supplier_quotation
|
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import create_supplier_quotation
|
||||||
|
from erpnext.crm.doctype.opportunity.test_opportunity import make_opportunity
|
||||||
|
from erpnext.crm.doctype.opportunity.opportunity import make_request_for_quotation as make_rfq
|
||||||
|
|
||||||
class TestRequestforQuotation(unittest.TestCase):
|
class TestRequestforQuotation(unittest.TestCase):
|
||||||
def test_quote_status(self):
|
def test_quote_status(self):
|
||||||
@ -110,6 +112,23 @@ class TestRequestforQuotation(unittest.TestCase):
|
|||||||
self.assertEqual(supplier_quotation.items[0].qty, 5)
|
self.assertEqual(supplier_quotation.items[0].qty, 5)
|
||||||
self.assertEqual(supplier_quotation.items[0].stock_qty, 10)
|
self.assertEqual(supplier_quotation.items[0].stock_qty, 10)
|
||||||
|
|
||||||
|
def test_make_rfq_from_opportunity(self):
|
||||||
|
opportunity = make_opportunity(with_items=1)
|
||||||
|
supplier_data = get_supplier_data()
|
||||||
|
rfq = make_rfq(opportunity.name)
|
||||||
|
|
||||||
|
self.assertEqual(len(rfq.get("items")), len(opportunity.get("items")))
|
||||||
|
rfq.message_for_supplier = 'Please supply the specified items at the best possible rates.'
|
||||||
|
|
||||||
|
for item in rfq.items:
|
||||||
|
item.warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
|
for data in supplier_data:
|
||||||
|
rfq.append('suppliers', data)
|
||||||
|
|
||||||
|
rfq.status = 'Draft'
|
||||||
|
rfq.submit()
|
||||||
|
|
||||||
def make_request_for_quotation(**args):
|
def make_request_for_quotation(**args):
|
||||||
"""
|
"""
|
||||||
:param supplier_data: List containing supplier data
|
:param supplier_data: List containing supplier data
|
||||||
|
@ -267,6 +267,9 @@ def make_quotation(source_name, target_doc=None):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_request_for_quotation(source_name, target_doc=None):
|
def make_request_for_quotation(source_name, target_doc=None):
|
||||||
|
def update_item(obj, target, source_parent):
|
||||||
|
target.conversion_factor = 1.0
|
||||||
|
|
||||||
doclist = get_mapped_doc("Opportunity", source_name, {
|
doclist = get_mapped_doc("Opportunity", source_name, {
|
||||||
"Opportunity": {
|
"Opportunity": {
|
||||||
"doctype": "Request for Quotation"
|
"doctype": "Request for Quotation"
|
||||||
@ -277,7 +280,8 @@ def make_request_for_quotation(source_name, target_doc=None):
|
|||||||
["name", "opportunity_item"],
|
["name", "opportunity_item"],
|
||||||
["parent", "opportunity"],
|
["parent", "opportunity"],
|
||||||
["uom", "uom"]
|
["uom", "uom"]
|
||||||
]
|
],
|
||||||
|
"postprocess": update_item
|
||||||
}
|
}
|
||||||
}, target_doc)
|
}, target_doc)
|
||||||
|
|
||||||
|
@ -82,7 +82,8 @@ def make_opportunity(**args):
|
|||||||
if args.with_items:
|
if args.with_items:
|
||||||
opp_doc.append('items', {
|
opp_doc.append('items', {
|
||||||
"item_code": args.item_code or "_Test Item",
|
"item_code": args.item_code or "_Test Item",
|
||||||
"qty": args.qty or 1
|
"qty": args.qty or 1,
|
||||||
|
"uom": "_Test UOM"
|
||||||
})
|
})
|
||||||
|
|
||||||
opp_doc.insert()
|
opp_doc.insert()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user