mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-12 03:15:07 +00:00
* fix: transactions where update stock is 0 should not create SLEs (#54035)
(cherry picked from commit 66780543bd)
# Conflicts:
# erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
* chore: resolve conflicts
* chore: resolve conflicts
---------
Co-authored-by: Nishka Gosalia <58264710+nishkagosalia@users.noreply.github.com>
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
@@ -74,6 +74,7 @@ class RepostItemValuation(Document):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_company()
|
self.set_company()
|
||||||
|
self.validate_update_stock()
|
||||||
self.validate_period_closing_voucher()
|
self.validate_period_closing_voucher()
|
||||||
self.set_status(write=False)
|
self.set_status(write=False)
|
||||||
self.reset_field_values()
|
self.reset_field_values()
|
||||||
@@ -81,6 +82,15 @@ class RepostItemValuation(Document):
|
|||||||
self.reset_recreate_stock_ledgers()
|
self.reset_recreate_stock_ledgers()
|
||||||
self.validate_recreate_stock_ledgers()
|
self.validate_recreate_stock_ledgers()
|
||||||
|
|
||||||
|
def validate_update_stock(self):
|
||||||
|
if self.voucher_type in ["Sales Invoice", "Purchase Invoice"]:
|
||||||
|
update_stock = frappe.get_value(self.voucher_type, self.voucher_no, "update_stock")
|
||||||
|
if not update_stock:
|
||||||
|
msg = _(
|
||||||
|
"Since {0} has 'Update Stock' disabled, you cannot create repost item valuation against it"
|
||||||
|
).format(get_link_to_form(self.voucher_type, self.voucher_no))
|
||||||
|
frappe.throw(msg)
|
||||||
|
|
||||||
def validate_recreate_stock_ledgers(self):
|
def validate_recreate_stock_ledgers(self):
|
||||||
if not self.recreate_stock_ledgers:
|
if not self.recreate_stock_ledgers:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -137,19 +137,14 @@ class TestRepostItemValuation(FrappeTestCase, StockTestMixin):
|
|||||||
item_code="_Test Item",
|
item_code="_Test Item",
|
||||||
warehouse="_Test Warehouse - _TC",
|
warehouse="_Test Warehouse - _TC",
|
||||||
based_on="Item and Warehouse",
|
based_on="Item and Warehouse",
|
||||||
voucher_type="Sales Invoice",
|
|
||||||
voucher_no="SI-1",
|
|
||||||
posting_date="2021-01-02",
|
posting_date="2021-01-02",
|
||||||
posting_time="00:01:00",
|
posting_time="00:01:00",
|
||||||
)
|
)
|
||||||
|
|
||||||
# new repost without any duplicates
|
# new repost without any duplicates
|
||||||
riv1 = frappe.get_doc(riv_args)
|
riv1 = frappe.get_doc(riv_args)
|
||||||
riv1.flags.dont_run_in_test = True
|
riv1.flags.dont_run_in_test = True
|
||||||
riv1.submit()
|
riv1.submit()
|
||||||
_assert_status(riv1, "Queued")
|
_assert_status(riv1, "Queued")
|
||||||
self.assertEqual(riv1.voucher_type, "Sales Invoice") # traceability
|
|
||||||
self.assertEqual(riv1.voucher_no, "SI-1")
|
|
||||||
|
|
||||||
# newer than existing duplicate - riv1
|
# newer than existing duplicate - riv1
|
||||||
riv2 = frappe.get_doc(riv_args.update({"posting_date": "2021-01-03"}))
|
riv2 = frappe.get_doc(riv_args.update({"posting_date": "2021-01-03"}))
|
||||||
|
|||||||
Reference in New Issue
Block a user