Merge branch 'develop' into more_asset_bug_fixes
This commit is contained in:
commit
ef56060166
@ -4,7 +4,7 @@
|
||||
# the repo. Unless a later match takes precedence,
|
||||
|
||||
erpnext/accounts/ @nextchamp-saqib @deepeshgarg007 @ruthra-kumar
|
||||
erpnext/assets/ @nextchamp-saqib @deepeshgarg007 @ruthra-kumar
|
||||
erpnext/assets/ @anandbaburajan @deepeshgarg007
|
||||
erpnext/loan_management/ @nextchamp-saqib @deepeshgarg007
|
||||
erpnext/regional @nextchamp-saqib @deepeshgarg007 @ruthra-kumar
|
||||
erpnext/selling @nextchamp-saqib @deepeshgarg007 @ruthra-kumar
|
||||
|
@ -124,12 +124,11 @@ frappe.ui.form.on("Request for Quotation",{
|
||||
frappe.urllib.get_full_url(
|
||||
"/api/method/erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_pdf?" +
|
||||
new URLSearchParams({
|
||||
doctype: frm.doc.doctype,
|
||||
name: frm.doc.name,
|
||||
supplier: data.supplier,
|
||||
print_format: data.print_format || "Standard",
|
||||
language: data.language || frappe.boot.lang,
|
||||
letter_head: data.letter_head || frm.doc.letter_head || "",
|
||||
letterhead: data.letter_head || frm.doc.letter_head || "",
|
||||
}).toString()
|
||||
)
|
||||
);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
import json
|
||||
from typing import Optional
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
@ -388,24 +389,26 @@ def create_rfq_items(sq_doc, supplier, data):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_pdf(doctype, name, supplier, print_format=None, language=None, letter_head=None):
|
||||
# permissions get checked in `download_pdf`
|
||||
if doc := get_rfq_doc(doctype, name, supplier):
|
||||
download_pdf(
|
||||
doctype,
|
||||
name,
|
||||
print_format,
|
||||
doc=doc,
|
||||
language=language,
|
||||
letter_head=letter_head or None,
|
||||
)
|
||||
|
||||
|
||||
def get_rfq_doc(doctype, name, supplier):
|
||||
def get_pdf(
|
||||
name: str,
|
||||
supplier: str,
|
||||
print_format: Optional[str] = None,
|
||||
language: Optional[str] = None,
|
||||
letterhead: Optional[str] = None,
|
||||
):
|
||||
doc = frappe.get_doc("Request for Quotation", name)
|
||||
if supplier:
|
||||
doc = frappe.get_doc(doctype, name)
|
||||
doc.update_supplier_part_no(supplier)
|
||||
return doc
|
||||
|
||||
# permissions get checked in `download_pdf`
|
||||
download_pdf(
|
||||
doc.doctype,
|
||||
doc.name,
|
||||
print_format,
|
||||
doc=doc,
|
||||
language=language,
|
||||
letterhead=letterhead or None,
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -8,6 +8,7 @@ from frappe.utils import nowdate
|
||||
|
||||
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import (
|
||||
create_supplier_quotation,
|
||||
get_pdf,
|
||||
make_supplier_quotation_from_rfq,
|
||||
)
|
||||
from erpnext.crm.doctype.opportunity.opportunity import make_request_for_quotation as make_rfq
|
||||
@ -124,6 +125,11 @@ class TestRequestforQuotation(FrappeTestCase):
|
||||
rfq.status = "Draft"
|
||||
rfq.submit()
|
||||
|
||||
def test_get_pdf(self):
|
||||
rfq = make_request_for_quotation()
|
||||
get_pdf(rfq.name, rfq.get("suppliers")[0].supplier)
|
||||
self.assertEqual(frappe.local.response.type, "pdf")
|
||||
|
||||
|
||||
def make_request_for_quotation(**args):
|
||||
"""
|
||||
|
@ -110,8 +110,11 @@ frappe.ui.form.on('Material Request', {
|
||||
|
||||
if (frm.doc.material_request_type === "Material Transfer") {
|
||||
add_create_pick_list_button();
|
||||
frm.add_custom_button(__("Transfer Material"),
|
||||
frm.add_custom_button(__("Material Transfer"),
|
||||
() => frm.events.make_stock_entry(frm), __('Create'));
|
||||
|
||||
frm.add_custom_button(__("Material Transfer (In Transit)"),
|
||||
() => frm.events.make_in_transit_stock_entry(frm), __('Create'));
|
||||
}
|
||||
|
||||
if (frm.doc.material_request_type === "Material Issue") {
|
||||
@ -333,6 +336,46 @@ frappe.ui.form.on('Material Request', {
|
||||
});
|
||||
},
|
||||
|
||||
make_in_transit_stock_entry(frm) {
|
||||
frappe.prompt(
|
||||
[
|
||||
{
|
||||
label: __('In Transit Warehouse'),
|
||||
fieldname: 'in_transit_warehouse',
|
||||
fieldtype: 'Link',
|
||||
options: 'Warehouse',
|
||||
reqd: 1,
|
||||
get_query: () => {
|
||||
return{
|
||||
filters: {
|
||||
'company': frm.doc.company,
|
||||
'is_group': 0,
|
||||
'warehouse_type': 'Transit'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
(values) => {
|
||||
frappe.call({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_in_transit_stock_entry",
|
||||
args: {
|
||||
source_name: frm.doc.name,
|
||||
in_transit_warehouse: values.in_transit_warehouse
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r.message) {
|
||||
let doc = frappe.model.sync(r.message);
|
||||
frappe.set_route('Form', doc[0].doctype, doc[0].name);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
__('In Transit Transfer'),
|
||||
__("Create Stock Entry")
|
||||
)
|
||||
},
|
||||
|
||||
create_pick_list: (frm) => {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.create_pick_list",
|
||||
|
@ -716,3 +716,14 @@ def create_pick_list(source_name, target_doc=None):
|
||||
doc.set_item_locations()
|
||||
|
||||
return doc
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_in_transit_stock_entry(source_name, in_transit_warehouse):
|
||||
ste_doc = make_stock_entry(source_name)
|
||||
ste_doc.add_to_transit = 1
|
||||
|
||||
for row in ste_doc.items:
|
||||
row.t_warehouse = in_transit_warehouse
|
||||
|
||||
return ste_doc
|
||||
|
@ -11,6 +11,7 @@ from frappe.utils import flt, today
|
||||
|
||||
from erpnext.stock.doctype.item.test_item import create_item
|
||||
from erpnext.stock.doctype.material_request.material_request import (
|
||||
make_in_transit_stock_entry,
|
||||
make_purchase_order,
|
||||
make_stock_entry,
|
||||
make_supplier_quotation,
|
||||
@ -56,6 +57,22 @@ class TestMaterialRequest(FrappeTestCase):
|
||||
self.assertEqual(se.doctype, "Stock Entry")
|
||||
self.assertEqual(len(se.get("items")), len(mr.get("items")))
|
||||
|
||||
def test_in_transit_make_stock_entry(self):
|
||||
mr = frappe.copy_doc(test_records[0]).insert()
|
||||
|
||||
self.assertRaises(frappe.ValidationError, make_stock_entry, mr.name)
|
||||
|
||||
mr = frappe.get_doc("Material Request", mr.name)
|
||||
mr.material_request_type = "Material Transfer"
|
||||
mr.submit()
|
||||
|
||||
in_transit_warehouse = get_in_transit_warehouse(mr.company)
|
||||
se = make_in_transit_stock_entry(mr.name, in_transit_warehouse)
|
||||
|
||||
self.assertEqual(se.doctype, "Stock Entry")
|
||||
for row in se.get("items"):
|
||||
self.assertEqual(row.t_warehouse, in_transit_warehouse)
|
||||
|
||||
def _insert_stock_entry(self, qty1, qty2, warehouse=None):
|
||||
se = frappe.get_doc(
|
||||
{
|
||||
@ -742,6 +759,36 @@ class TestMaterialRequest(FrappeTestCase):
|
||||
self.assertEqual(existing_requested_qty, current_requested_qty)
|
||||
|
||||
|
||||
def get_in_transit_warehouse(company):
|
||||
if not frappe.db.exists("Warehouse Type", "Transit"):
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Warehouse Type",
|
||||
"name": "Transit",
|
||||
}
|
||||
).insert()
|
||||
|
||||
in_transit_warehouse = frappe.db.exists(
|
||||
"Warehouse", {"warehouse_type": "Transit", "company": company}
|
||||
)
|
||||
|
||||
if not in_transit_warehouse:
|
||||
in_transit_warehouse = (
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Warehouse",
|
||||
"warehouse_name": "Transit",
|
||||
"warehouse_type": "Transit",
|
||||
"company": company,
|
||||
}
|
||||
)
|
||||
.insert()
|
||||
.name
|
||||
)
|
||||
|
||||
return in_transit_warehouse
|
||||
|
||||
|
||||
def make_material_request(**args):
|
||||
args = frappe._dict(args)
|
||||
mr = frappe.new_doc("Material Request")
|
||||
|
Loading…
x
Reference in New Issue
Block a user