Merge pull request #23407 from deepeshgarg007/stock_entry_conversion_factor
fix: Conversion factor fixes in Stock Entry
This commit is contained in:
commit
e3ad5f0bc3
@ -205,7 +205,9 @@ class StockEntry(StockController):
|
||||
|
||||
for f in ("uom", "stock_uom", "description", "item_name", "expense_account",
|
||||
"cost_center", "conversion_factor"):
|
||||
if f in ["stock_uom", "conversion_factor"] or not item.get(f):
|
||||
if f == "stock_uom" or not item.get(f):
|
||||
item.set(f, item_details.get(f))
|
||||
if f == 'conversion_factor' and item.uom == item_details.get('stock_uom'):
|
||||
item.set(f, item_details.get(f))
|
||||
|
||||
if not item.transfer_qty and item.qty:
|
||||
|
@ -795,6 +795,32 @@ class TestStockEntry(unittest.TestCase):
|
||||
])
|
||||
)
|
||||
|
||||
def test_conversion_factor_change(self):
|
||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
||||
repack_entry = frappe.copy_doc(test_records[3])
|
||||
repack_entry.posting_date = nowdate()
|
||||
repack_entry.posting_time = nowtime()
|
||||
repack_entry.set_stock_entry_type()
|
||||
repack_entry.insert()
|
||||
|
||||
# check current uom and conversion factor
|
||||
self.assertTrue(repack_entry.items[0].uom, "_Test UOM")
|
||||
self.assertTrue(repack_entry.items[0].conversion_factor, 1)
|
||||
|
||||
# change conversion factor
|
||||
repack_entry.items[0].uom = "_Test UOM 1"
|
||||
repack_entry.items[0].stock_uom = "_Test UOM 1"
|
||||
repack_entry.items[0].conversion_factor = 2
|
||||
repack_entry.save()
|
||||
repack_entry.submit()
|
||||
|
||||
self.assertEqual(repack_entry.items[0].conversion_factor, 2)
|
||||
self.assertEqual(repack_entry.items[0].uom, "_Test UOM 1")
|
||||
self.assertEqual(repack_entry.items[0].qty, 50)
|
||||
self.assertEqual(repack_entry.items[0].transfer_qty, 100)
|
||||
|
||||
frappe.db.set_default("allow_negative_stock", 0)
|
||||
|
||||
def make_serialized_item(**args):
|
||||
args = frappe._dict(args)
|
||||
se = frappe.copy_doc(test_records[0])
|
||||
|
@ -238,7 +238,6 @@
|
||||
"oldfieldname": "conversion_factor",
|
||||
"oldfieldtype": "Currency",
|
||||
"print_hide": 1,
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@ -498,15 +497,14 @@
|
||||
"depends_on": "eval:parent.purpose===\"Repack\" && doc.t_warehouse",
|
||||
"fieldname": "set_basic_rate_manually",
|
||||
"fieldtype": "Check",
|
||||
"label": "Set Basic Rate Manually",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
"label": "Set Basic Rate Manually"
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-06-08 12:57:03.172887",
|
||||
"modified": "2020-09-22 17:55:03.384138",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Entry Detail",
|
||||
|
Loading…
Reference in New Issue
Block a user