Skip to content

Commit

Permalink
feat: get items from Transit Stock Entry
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure committed Jan 23, 2023
1 parent 6b31c27 commit 62141b0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
24 changes: 24 additions & 0 deletions erpnext/stock/doctype/stock_entry/stock_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ frappe.ui.form.on('Stock Entry', {
},

refresh: function(frm) {
frm.trigger("get_items_from_transit_entry");

if(!frm.doc.docstatus) {
frm.trigger('validate_purpose_consumption');
frm.add_custom_button(__('Material Request'), function() {
Expand Down Expand Up @@ -337,6 +339,28 @@ frappe.ui.form.on('Stock Entry', {
}
},

get_items_from_transit_entry: function(frm) {
if (frm.doc.docstatus===0) {
frm.add_custom_button(__('Transit Entry'), function() {
erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.stock_entry.stock_entry.make_stock_in_entry",
source_doctype: "Stock Entry",
target: frm,
date_field: "posting_date",
setters: {
stock_entry_type: "Material Transfer",
purpose: "Material Transfer",
},
get_query_filters: {
docstatus: 1,
purpose: "Material Transfer",
add_to_transit: 1,
}
})
}, __("Get Items From"));
}
},

before_save: function(frm) {
frm.doc.items.forEach((item) => {
item.uom = item.uom || item.stock_uom;
Expand Down
1 change: 1 addition & 0 deletions erpnext/stock/doctype/stock_entry/stock_entry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def process_serial_numbers(serial_nos_list):
args.item = "_Test Item"

s.company = args.company or erpnext.get_default_company()
s.add_to_transit = args.add_to_transit or 0
s.purchase_receipt_no = args.purchase_receipt_no
s.delivery_note_no = args.delivery_note_no
s.sales_invoice_no = args.sales_invoice_no
Expand Down
48 changes: 48 additions & 0 deletions erpnext/stock/doctype/stock_entry/test_stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from erpnext.stock.doctype.serial_no.serial_no import * # noqa
from erpnext.stock.doctype.stock_entry.stock_entry import (
FinishedGoodError,
make_stock_in_entry,
move_sample_to_retention_warehouse,
)
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
Expand Down Expand Up @@ -160,6 +161,53 @@ def _test_auto_material_request(

self.assertTrue(item_code in items)

def test_add_to_transit_entry(self):
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse

item_code = "_Test Transit Item"
company = "_Test Company"

create_warehouse("Test From Warehouse")
create_warehouse("Test Transit Warehouse")
create_warehouse("Test To Warehouse")

create_item(
item_code=item_code,
is_stock_item=1,
is_purchase_item=1,
company=company,
)

# create inward stock entry
make_stock_entry(
item_code=item_code,
target="Test From Warehouse - _TC",
qty=10,
basic_rate=100,
expense_account="Stock Adjustment - _TC",
cost_center="Main - _TC",
)

transit_entry = make_stock_entry(
item_code=item_code,
source="Test From Warehouse - _TC",
target="Test Transit Warehouse - _TC",
add_to_transit=1,
stock_entry_type="Material Transfer",
purpose="Material Transfer",
qty=10,
basic_rate=100,
expense_account="Stock Adjustment - _TC",
cost_center="Main - _TC",
)

end_transit_entry = make_stock_in_entry(transit_entry.name)
self.assertEqual(transit_entry.name, end_transit_entry.outgoing_stock_entry)
self.assertEqual(transit_entry.name, end_transit_entry.items[0].against_stock_entry)
self.assertEqual(transit_entry.items[0].name, end_transit_entry.items[0].ste_detail)

# create add to transit

def test_material_receipt_gl_entry(self):
company = frappe.db.get_value("Warehouse", "Stores - TCP1", "company")

Expand Down

0 comments on commit 62141b0

Please sign in to comment.