mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-30 17:42:32 +02:00
fix: make LCV button not working for PI and PR (#43592)
(cherry picked from commit 48a12e7213)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -561,11 +561,12 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
frm.custom_make_buttons = {
|
frm.custom_make_buttons = {
|
||||||
"Purchase Invoice": "Return / Debit Note",
|
"Purchase Invoice": "Return / Debit Note",
|
||||||
"Payment Entry": "Payment",
|
"Payment Entry": "Payment",
|
||||||
"Landed Cost Voucher": function () {
|
|
||||||
frm.trigger("create_landed_cost_voucher");
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (frm.doc.update_stock) {
|
||||||
|
frm.custom_make_buttons["Landed Cost Voucher"] = "Landed Cost Voucher";
|
||||||
|
}
|
||||||
|
|
||||||
frm.set_query("additional_discount_account", function () {
|
frm.set_query("additional_discount_account", function () {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -607,20 +608,6 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
create_landed_cost_voucher: function (frm) {
|
|
||||||
let lcv = frappe.model.get_new_doc("Landed Cost Voucher");
|
|
||||||
lcv.company = frm.doc.company;
|
|
||||||
|
|
||||||
let lcv_receipt = frappe.model.get_new_doc("Landed Cost Purchase Invoice");
|
|
||||||
lcv_receipt.receipt_document_type = "Purchase Invoice";
|
|
||||||
lcv_receipt.receipt_document = frm.doc.name;
|
|
||||||
lcv_receipt.supplier = frm.doc.supplier;
|
|
||||||
lcv_receipt.grand_total = frm.doc.grand_total;
|
|
||||||
lcv.purchase_receipts = [lcv_receipt];
|
|
||||||
|
|
||||||
frappe.set_route("Form", lcv.doctype, lcv.name);
|
|
||||||
},
|
|
||||||
|
|
||||||
add_custom_buttons: function (frm) {
|
add_custom_buttons: function (frm) {
|
||||||
if (frm.doc.docstatus == 1 && frm.doc.per_received < 100) {
|
if (frm.doc.docstatus == 1 && frm.doc.per_received < 100) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
@@ -645,6 +632,32 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
__("View")
|
__("View")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frm.doc.docstatus === 1 && frm.doc.update_stock) {
|
||||||
|
frm.add_custom_button(
|
||||||
|
__("Landed Cost Voucher"),
|
||||||
|
() => {
|
||||||
|
frm.events.make_lcv(frm);
|
||||||
|
},
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_lcv(frm) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_lcv",
|
||||||
|
args: {
|
||||||
|
doctype: frm.doc.doctype,
|
||||||
|
docname: frm.doc.name,
|
||||||
|
},
|
||||||
|
callback: (r) => {
|
||||||
|
if (r.message) {
|
||||||
|
var doc = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
|
|||||||
@@ -11,25 +11,10 @@ erpnext.buying.setup_buying_controller();
|
|||||||
|
|
||||||
frappe.ui.form.on("Purchase Receipt", {
|
frappe.ui.form.on("Purchase Receipt", {
|
||||||
setup: (frm) => {
|
setup: (frm) => {
|
||||||
frm.make_methods = {
|
|
||||||
"Landed Cost Voucher": () => {
|
|
||||||
let lcv = frappe.model.get_new_doc("Landed Cost Voucher");
|
|
||||||
lcv.company = frm.doc.company;
|
|
||||||
|
|
||||||
let lcv_receipt = frappe.model.get_new_doc("Landed Cost Purchase Receipt");
|
|
||||||
lcv_receipt.receipt_document_type = "Purchase Receipt";
|
|
||||||
lcv_receipt.receipt_document = frm.doc.name;
|
|
||||||
lcv_receipt.supplier = frm.doc.supplier;
|
|
||||||
lcv_receipt.grand_total = frm.doc.grand_total;
|
|
||||||
lcv.purchase_receipts = [lcv_receipt];
|
|
||||||
|
|
||||||
frappe.set_route("Form", lcv.doctype, lcv.name);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
frm.custom_make_buttons = {
|
frm.custom_make_buttons = {
|
||||||
"Stock Entry": "Return",
|
"Stock Entry": "Return",
|
||||||
"Purchase Invoice": "Purchase Invoice",
|
"Purchase Invoice": "Purchase Invoice",
|
||||||
|
"Landed Cost Voucher": "Landed Cost Voucher",
|
||||||
};
|
};
|
||||||
|
|
||||||
frm.set_query("expense_account", "items", function () {
|
frm.set_query("expense_account", "items", function () {
|
||||||
@@ -114,9 +99,35 @@ frappe.ui.form.on("Purchase Receipt", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frm.doc.docstatus === 1) {
|
||||||
|
frm.add_custom_button(
|
||||||
|
__("Landed Cost Voucher"),
|
||||||
|
() => {
|
||||||
|
frm.events.make_lcv(frm);
|
||||||
|
},
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
frm.events.add_custom_buttons(frm);
|
frm.events.add_custom_buttons(frm);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_lcv(frm) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_lcv",
|
||||||
|
args: {
|
||||||
|
doctype: frm.doc.doctype,
|
||||||
|
docname: frm.doc.name,
|
||||||
|
},
|
||||||
|
callback: (r) => {
|
||||||
|
if (r.message) {
|
||||||
|
var doc = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
add_custom_buttons: function (frm) {
|
add_custom_buttons: function (frm) {
|
||||||
if (frm.doc.docstatus == 0) {
|
if (frm.doc.docstatus == 0) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
|
|||||||
@@ -1370,3 +1370,26 @@ def get_item_account_wise_additional_cost(purchase_document):
|
|||||||
@erpnext.allow_regional
|
@erpnext.allow_regional
|
||||||
def update_regional_gl_entries(gl_list, doc):
|
def update_regional_gl_entries(gl_list, doc):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_lcv(doctype, docname):
|
||||||
|
landed_cost_voucher = frappe.new_doc("Landed Cost Voucher")
|
||||||
|
|
||||||
|
details = frappe.db.get_value(doctype, docname, ["supplier", "company", "base_grand_total"], as_dict=1)
|
||||||
|
|
||||||
|
landed_cost_voucher.company = details.company
|
||||||
|
|
||||||
|
landed_cost_voucher.append(
|
||||||
|
"purchase_receipts",
|
||||||
|
{
|
||||||
|
"receipt_document_type": doctype,
|
||||||
|
"receipt_document": docname,
|
||||||
|
"grand_total": details.base_grand_total,
|
||||||
|
"supplier": details.supplier,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
landed_cost_voucher.get_items_from_purchase_receipts()
|
||||||
|
|
||||||
|
return landed_cost_voucher.as_dict()
|
||||||
|
|||||||
Reference in New Issue
Block a user