Skip to content

Commit

Permalink
fix: Required Changes to Support e-Waybill Generation for Material Tr…
Browse files Browse the repository at this point in the history
…ansfer Return (#43061)

(cherry picked from commit 004c4e2)
  • Loading branch information
Ninad1306 authored and mergify[bot] committed Oct 22, 2024
1 parent 29fe23b commit 2205ae8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
18 changes: 12 additions & 6 deletions erpnext/controllers/subcontracting_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,17 @@ def add_items_in_ste(ste_doc, row, qty, rm_details, rm_detail_field="sco_rm_deta
def make_return_stock_entry_for_subcontract(
available_materials, order_doc, rm_details, order_doctype="Subcontracting Order"
):
def post_process(source_doc, target_doc):
target_doc.purpose = "Material Transfer"

if source_doc.doctype == "Purchase Order":
target_doc.purchase_order = source_doc.name
else:
target_doc.subcontracting_order = source_doc.name

target_doc.company = source_doc.company
target_doc.is_return = 1

ste_doc = get_mapped_doc(
order_doctype,
order_doc.name,
Expand All @@ -1245,18 +1256,13 @@ def make_return_stock_entry_for_subcontract(
},
},
ignore_child_tables=True,
postprocess=post_process,
)

ste_doc.purpose = "Material Transfer"

if order_doctype == "Purchase Order":
ste_doc.purchase_order = order_doc.name
rm_detail_field = "po_detail"
else:
ste_doc.subcontracting_order = order_doc.name
rm_detail_field = "sco_rm_detail"
ste_doc.company = order_doc.company
ste_doc.is_return = 1

for _key, value in available_materials.items():
if not value.qty:
Expand Down
6 changes: 5 additions & 1 deletion erpnext/stock/doctype/stock_entry/stock_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ erpnext.stock.StockEntry = class StockEntry extends erpnext.stock.StockControlle

this.frm.cscript.toggle_enable_bom();

if (doc.purpose == "Send to Subcontractor") {
if (erpnext.stock.is_subcontracting_or_return_transfer(doc)) {
doc.customer =
doc.customer_name =
doc.customer_address =
Expand Down Expand Up @@ -1364,6 +1364,10 @@ erpnext.stock.select_batch_and_serial_no = (frm, item) => {
});
};

erpnext.stock.is_subcontracting_or_return_transfer = (doc) => {
return doc.purpose == "Send to Subcontractor" || (doc.purpose == "Material Transfer" && doc.is_return);
};

function attach_bom_items(bom_no) {
if (!bom_no) {
return;
Expand Down
12 changes: 6 additions & 6 deletions erpnext/stock/doctype/stock_entry/stock_entry.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@
"search_index": 1
},
{
"depends_on": "eval:doc.purpose==\"Send to Subcontractor\"",
"depends_on": "eval: erpnext.stock.is_subcontracting_or_return_transfer(doc)",
"fieldname": "purchase_order",
"fieldtype": "Link",
"label": "Purchase Order",
"options": "Purchase Order"
},
{
"depends_on": "eval:doc.purpose==\"Send to Subcontractor\"",
"depends_on": "eval: erpnext.stock.is_subcontracting_or_return_transfer(doc)",
"fieldname": "subcontracting_order",
"fieldtype": "Link",
"label": "Subcontracting Order",
Expand Down Expand Up @@ -427,13 +427,13 @@
},
{
"collapsible": 1,
"depends_on": "eval:doc.purpose === \"Send to Subcontractor\"",
"depends_on": "eval: erpnext.stock.is_subcontracting_or_return_transfer(doc)",
"fieldname": "contact_section",
"fieldtype": "Section Break",
"label": "Supplier Details"
},
{
"depends_on": "eval:doc.purpose === \"Send to Subcontractor\"",
"depends_on": "eval: erpnext.stock.is_subcontracting_or_return_transfer(doc)",
"fieldname": "supplier",
"fieldtype": "Link",
"label": "Supplier",
Expand All @@ -445,7 +445,7 @@
},
{
"bold": 1,
"depends_on": "eval:doc.purpose === \"Send to Subcontractor\"",
"depends_on": "eval: erpnext.stock.is_subcontracting_or_return_transfer(doc)",
"fieldname": "supplier_name",
"fieldtype": "Data",
"label": "Supplier Name",
Expand All @@ -455,7 +455,7 @@
"read_only": 1
},
{
"depends_on": "eval:doc.purpose === \"Send to Subcontractor\"",
"depends_on": "eval: erpnext.stock.is_subcontracting_or_return_transfer(doc)",
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Supplier Address",
Expand Down

0 comments on commit 2205ae8

Please sign in to comment.