From 022893391b92f8eb771ec97162be72cd0bbc906b Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 16 May 2023 16:23:52 +0530 Subject: [PATCH 1/2] fix: force to do reposting for cancelled document (cherry picked from commit 6e661e7c0e8251f458d699254423cfb76dc3b5dd) # Conflicts: # erpnext/controllers/stock_controller.py --- erpnext/controllers/stock_controller.py | 7 +++++++ .../test_repost_item_valuation.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 3a08051b2f38..8f698b679f24 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -689,7 +689,14 @@ def repost_future_sle_and_gle(self): } ) +<<<<<<< HEAD if future_sle_exists(args) or repost_required_for_queue(self): +======= + if self.docstatus == 2: + force = True + + if force or future_sle_exists(args) or repost_required_for_queue(self): +>>>>>>> 6e661e7c0e (fix: force to do reposting for cancelled document) item_based_reposting = cint( frappe.db.get_single_value("Stock Reposting Settings", "item_based_reposting") ) diff --git a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py index b9e2ed1beb96..78d6417bfa89 100644 --- a/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/test_repost_item_valuation.py @@ -294,3 +294,19 @@ def test_account_freeze_validation(self): self.assertRaises(frappe.ValidationError, riv.save) accounts_settings.acc_frozen_upto = "" accounts_settings.save() + + def test_create_repost_entry_for_cancelled_document(self): + pr = make_purchase_receipt( + company="_Test Company with perpetual inventory", + warehouse="Stores - TCP1", + get_multiple_items=True, + ) + + self.assertTrue(pr.docstatus == 1) + self.assertFalse(frappe.db.exists("Repost Item Valuation", {"voucher_no": pr.name})) + + pr.load_from_db() + + pr.cancel() + self.assertTrue(pr.docstatus == 2) + self.assertTrue(frappe.db.exists("Repost Item Valuation", {"voucher_no": pr.name})) From 44cb62824dc170b0346ed3f6ecd360d6c3de6cd4 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 29 May 2023 15:15:51 +0530 Subject: [PATCH 2/2] chore: `conflicts` --- erpnext/controllers/stock_controller.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 8f698b679f24..cd947a8a564e 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -678,7 +678,7 @@ def prepare_over_receipt_message(self, rule, values): message += _("Please adjust the qty or edit {0} to proceed.").format(rule_link) return message - def repost_future_sle_and_gle(self): + def repost_future_sle_and_gle(self, force=False): args = frappe._dict( { "posting_date": self.posting_date, @@ -689,14 +689,10 @@ def repost_future_sle_and_gle(self): } ) -<<<<<<< HEAD - if future_sle_exists(args) or repost_required_for_queue(self): -======= if self.docstatus == 2: force = True if force or future_sle_exists(args) or repost_required_for_queue(self): ->>>>>>> 6e661e7c0e (fix: force to do reposting for cancelled document) item_based_reposting = cint( frappe.db.get_single_value("Stock Reposting Settings", "item_based_reposting") )