fix(ux): hide Create Purchase Receipt button for Subcontract Return
This commit is contained in:
parent
874766a82f
commit
7145b040f1
@ -52,6 +52,7 @@ frappe.ui.form.on('Subcontracting Receipt', {
|
||||
frappe.set_route('query-report', 'General Ledger');
|
||||
}, __('View'));
|
||||
|
||||
if (frm.doc.is_return === 0) {
|
||||
frm.add_custom_button(__('Purchase Receipt'), () => {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: 'erpnext.subcontracting.doctype.subcontracting_receipt.subcontracting_receipt.make_purchase_receipt',
|
||||
@ -61,6 +62,7 @@ frappe.ui.form.on('Subcontracting Receipt', {
|
||||
});
|
||||
}, __('Create'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!frm.doc.is_return && frm.doc.docstatus === 1 && frm.doc.per_returned < 100) {
|
||||
frm.add_custom_button(__('Subcontract Return'), () => {
|
||||
|
||||
@ -545,9 +545,11 @@ def make_subcontract_return(source_name, target_doc=None):
|
||||
@frappe.whitelist()
|
||||
def make_purchase_receipt(source_name, target_doc=None, save=False, submit=False, notify=False):
|
||||
if isinstance(source_name, str):
|
||||
source_name = frappe.get_doc("Subcontracting Receipt", source_name)
|
||||
source_doc = frappe.get_doc("Subcontracting Receipt", source_name)
|
||||
else:
|
||||
source_doc = source_name
|
||||
|
||||
if not source_name.is_return:
|
||||
if not source_doc.is_return:
|
||||
if not target_doc:
|
||||
target_doc = frappe.new_doc("Purchase Receipt")
|
||||
target_doc.is_subcontracted = 1
|
||||
@ -555,7 +557,7 @@ def make_purchase_receipt(source_name, target_doc=None, save=False, submit=False
|
||||
|
||||
target_doc = get_mapped_doc(
|
||||
"Subcontracting Receipt",
|
||||
source_name.name,
|
||||
source_doc.name,
|
||||
{
|
||||
"Subcontracting Receipt": {
|
||||
"doctype": "Purchase Receipt",
|
||||
@ -573,7 +575,7 @@ def make_purchase_receipt(source_name, target_doc=None, save=False, submit=False
|
||||
)
|
||||
|
||||
po_items_details = {}
|
||||
for item in source_name.items:
|
||||
for item in source_doc.items:
|
||||
if item.purchase_order and item.purchase_order_item:
|
||||
if item.purchase_order not in po_items_details:
|
||||
po_doc = frappe.get_doc("Purchase Order", item.purchase_order)
|
||||
@ -599,7 +601,7 @@ def make_purchase_receipt(source_name, target_doc=None, save=False, submit=False
|
||||
if not target_doc.items:
|
||||
frappe.throw(
|
||||
_("Purchase Order Item reference is missing in Subcontracting Receipt {0}").format(
|
||||
source_name.name
|
||||
source_doc.name
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user