From d182137ed17bd288f76318fdfe1aeb443d5e5b2c Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 4 Jul 2022 18:38:26 +0530 Subject: [PATCH 1/7] fix: Incorrect provisional expense booking while reposting (cherry picked from commit 60aad31162aedb7be484cde53d7ca069065b2002) --- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index cca3f05270c..f859791de62 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -468,6 +468,7 @@ class PurchaseReceipt(BuyingController): and not d.is_fixed_asset and flt(d.qty) and provisional_accounting_for_non_stock_items + and d.get("provisional_expense_account") ): self.add_provisional_gl_entry( d, gl_entries, self.posting_date, d.get("provisional_expense_account") From 6bda2a086515c24c7d0593d1d419eb13aaa7fa5a Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Tue, 5 Jul 2022 21:20:51 +0530 Subject: [PATCH 2/7] chore: deprecation warning for remove-india --- erpnext/patches.txt | 1 + ...show_india_localisation_deprecation_warning.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f639dc7d380..bdc43dd094a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -368,3 +368,4 @@ erpnext.patches.v13_0.set_per_billed_in_return_delivery_note erpnext.patches.v13_0.update_employee_advance_status erpnext.patches.v13_0.job_card_status_on_hold erpnext.patches.v13_0.add_cost_center_in_loans +erpnext.patches.v13_0.show_india_localisation_deprecation_warning \ No newline at end of file diff --git a/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py b/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py new file mode 100644 index 00000000000..1d76b252192 --- /dev/null +++ b/erpnext/patches/v13_0/show_india_localisation_deprecation_warning.py @@ -0,0 +1,15 @@ +import click +import frappe + + +def execute(): + if not frappe.db.exists("Company", {"country": "India"}): + return + + click.secho( + "India-specific regional features have been moved to a separate app" + " and will be removed from ERPNext in Version 14." + " Please install India Compliance after upgrading to Version 14:\n" + "https://github.com/resilient-tech/india-compliance", + fg="yellow", + ) From 2a432c22d4c1891518cfd23a1a3028ccfc21fcfc Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 5 Jul 2022 19:43:02 +0530 Subject: [PATCH 3/7] fix: Use fallback conversion factor while setting incoming rate for petty purchase - PIs for petty items (that do not need an Item record) are allowed using Item Name field - If a different UOM is used in this case, conversion factor stays 0 and causes an error - Fallback to 1 in `set_incoming_rate` for buying - Selling will need a proper item, so this change is not needed there (cherry picked from commit aa043fe9617e15ff6f6999e968ca09ec2c68e66f) --- erpnext/controllers/buying_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 0a605345662..64e70b1aef5 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -299,7 +299,7 @@ class BuyingController(StockController, Subcontracting): raise_error_if_no_rate=False, ) - rate = flt(outgoing_rate * d.conversion_factor, d.precision("rate")) + rate = flt(outgoing_rate * (d.conversion_factor or 1), d.precision("rate")) else: rate = frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), "rate") From 07b80c295d4f81143b48a0a666b38c45f7e41be3 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 4 Jul 2022 20:24:18 +0530 Subject: [PATCH 4/7] fix: timeout error while reposting (cherry picked from commit 78c8bb251eff8450ece23a312bae3e82962a2beb) # Conflicts: # erpnext/stock/doctype/stock_entry/test_stock_entry.py --- .../doctype/stock_entry/test_stock_entry.py | 136 ++++++++++++++++++ erpnext/stock/stock_ledger.py | 19 +-- 2 files changed, 142 insertions(+), 13 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 8703aefdda7..686c914652b 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -5,8 +5,12 @@ import frappe from frappe.permissions import add_user_permission, remove_user_permission from frappe.tests.utils import FrappeTestCase, change_settings +<<<<<<< HEAD from frappe.utils import flt, nowdate, nowtime from six import iteritems +======= +from frappe.utils import add_days, flt, nowdate, nowtime +>>>>>>> 78c8bb251e (fix: timeout error while reposting) from erpnext.accounts.doctype.account.test_account import get_inventory_account from erpnext.stock.doctype.item.test_item import ( @@ -1414,6 +1418,138 @@ class TestStockEntry(FrappeTestCase): self.assertEqual(se.items[0].item_name, item.item_name) self.assertEqual(se.items[0].stock_uom, item.stock_uom) + def test_reposting_for_depedent_warehouse(self): + from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import repost_sl_entries + from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse + + # Inward at WH1 warehouse (Component) + # 1st Repack (Component (WH1) - Subcomponent (WH2)) + # 2nd Repack (Subcomponent (WH2) - FG Item (WH3)) + # Material Transfer of FG Item -> WH 3 -> WH2 -> Wh1 (Two transfer entries) + # Backdated transction which should update valuation rate in repack as well trasfer entries + + for item_code in ["FG Item 1", "Sub Component 1", "Component 1"]: + create_item(item_code) + + for warehouse in ["WH 1", "WH 2", "WH 3"]: + create_warehouse(warehouse) + + make_stock_entry( + item_code="Component 1", + rate=100, + purpose="Material Receipt", + qty=10, + to_warehouse="WH 1 - _TC", + posting_date=add_days(nowdate(), -10), + ) + + repack1 = make_stock_entry( + item_code="Component 1", + purpose="Repack", + do_not_save=True, + qty=10, + from_warehouse="WH 1 - _TC", + posting_date=add_days(nowdate(), -9), + ) + + repack1.append( + "items", + { + "item_code": "Sub Component 1", + "qty": 10, + "t_warehouse": "WH 2 - _TC", + "transfer_qty": 10, + "uom": "Nos", + "stock_uom": "Nos", + "conversion_factor": 1.0, + }, + ) + + repack1.save() + repack1.submit() + + self.assertEqual(repack1.items[1].basic_rate, 100) + self.assertEqual(repack1.items[1].amount, 1000) + + repack2 = make_stock_entry( + item_code="Sub Component 1", + purpose="Repack", + do_not_save=True, + qty=10, + from_warehouse="WH 2 - _TC", + posting_date=add_days(nowdate(), -8), + ) + + repack2.append( + "items", + { + "item_code": "FG Item 1", + "qty": 10, + "t_warehouse": "WH 3 - _TC", + "transfer_qty": 10, + "uom": "Nos", + "stock_uom": "Nos", + "conversion_factor": 1.0, + }, + ) + + repack2.save() + repack2.submit() + + self.assertEqual(repack2.items[1].basic_rate, 100) + self.assertEqual(repack2.items[1].amount, 1000) + + transfer1 = make_stock_entry( + item_code="FG Item 1", + purpose="Material Transfer", + qty=10, + from_warehouse="WH 3 - _TC", + to_warehouse="WH 2 - _TC", + posting_date=add_days(nowdate(), -7), + ) + + self.assertEqual(transfer1.items[0].basic_rate, 100) + self.assertEqual(transfer1.items[0].amount, 1000) + + transfer2 = make_stock_entry( + item_code="FG Item 1", + purpose="Material Transfer", + qty=10, + from_warehouse="WH 2 - _TC", + to_warehouse="WH 1 - _TC", + posting_date=add_days(nowdate(), -6), + ) + + self.assertEqual(transfer2.items[0].basic_rate, 100) + self.assertEqual(transfer2.items[0].amount, 1000) + + # Backdated transaction + receipt2 = make_stock_entry( + item_code="Component 1", + rate=200, + purpose="Material Receipt", + qty=10, + to_warehouse="WH 1 - _TC", + posting_date=add_days(nowdate(), -15), + ) + + self.assertEqual(receipt2.items[0].basic_rate, 200) + self.assertEqual(receipt2.items[0].amount, 2000) + + repost_name = frappe.db.get_value( + "Repost Item Valuation", {"voucher_no": receipt2.name, "docstatus": 1}, "name" + ) + + doc = frappe.get_doc("Repost Item Valuation", repost_name) + repost_sl_entries(doc) + + for obj in [repack1, repack2, transfer1, transfer2]: + obj.load_from_db() + + index = 1 if obj.purpose == "Repack" else 0 + self.assertEqual(obj.items[index].basic_rate, 200) + self.assertEqual(obj.items[index].basic_amount, 2000) + def make_serialized_item(**args): args = frappe._dict(args) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index da57ba054dc..068cc12ed91 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -247,16 +247,11 @@ def repost_future_sle( data.sle_changed = False i += 1 - if doc and i % 2 == 0: + if doc: update_args_in_repost_item_valuation( doc, i, args, distinct_item_warehouses, affected_transactions ) - if doc and args: - update_args_in_repost_item_valuation( - doc, i, args, distinct_item_warehouses, affected_transactions - ) - def update_args_in_repost_item_valuation( doc, index, args, distinct_item_warehouses, affected_transactions @@ -491,7 +486,8 @@ class update_entries_after(object): elif dependant_sle.item_code == self.item_code and dependant_sle.warehouse in self.data: return entries_to_fix else: - return self.append_future_sle_for_dependant(dependant_sle, entries_to_fix) + self.append_future_sle_for_dependant(dependant_sle, entries_to_fix) + return entries_to_fix def update_distinct_item_warehouses(self, dependant_sle): key = (dependant_sle.item_code, dependant_sle.warehouse) @@ -510,14 +506,11 @@ class update_entries_after(object): def append_future_sle_for_dependant(self, dependant_sle, entries_to_fix): self.initialize_previous_data(dependant_sle) - - args = self.data[dependant_sle.warehouse].previous_sle or frappe._dict( - {"item_code": self.item_code, "warehouse": dependant_sle.warehouse} + self.distinct_item_warehouses[(self.item_code, dependant_sle.warehouse)] = frappe._dict( + {"sle": dependant_sle} ) - future_sle_for_dependant = list(self.get_sle_after_datetime(args)) - entries_to_fix.extend(future_sle_for_dependant) - return sorted(entries_to_fix, key=lambda k: k["timestamp"]) + self.new_items_found = True def process_sle(self, sle): from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos From 2045df19f99eb7886b20645fac9a210223d663b0 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Wed, 6 Jul 2022 12:34:10 +0530 Subject: [PATCH 5/7] fix: conflicts --- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 686c914652b..6156a6458b6 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -5,12 +5,8 @@ import frappe from frappe.permissions import add_user_permission, remove_user_permission from frappe.tests.utils import FrappeTestCase, change_settings -<<<<<<< HEAD -from frappe.utils import flt, nowdate, nowtime -from six import iteritems -======= from frappe.utils import add_days, flt, nowdate, nowtime ->>>>>>> 78c8bb251e (fix: timeout error while reposting) +from six import iteritems from erpnext.accounts.doctype.account.test_account import get_inventory_account from erpnext.stock.doctype.item.test_item import ( From b0e17dea2aa9abb1e57f03680b7799011ef9eb55 Mon Sep 17 00:00:00 2001 From: marination Date: Thu, 7 Jul 2022 16:59:23 +0530 Subject: [PATCH 6/7] fix: Use Contact Name instead of Supplier in RFQ Email (cherry picked from commit 88ac519b2439603a65b720f935887fd7287005be) --- .../request_for_quotation/request_for_quotation.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 1122e7fc573..8b5bf6f660f 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -181,12 +181,19 @@ class RequestforQuotation(BuyingController): doc_args = self.as_dict() doc_args.update({"supplier": data.get("supplier"), "supplier_name": data.get("supplier_name")}) + # Get Contact Full Name + if data.get("contact"): + contact_name = frappe.db.get_value( + "Contact", data.get("contact"), ["first_name", "middle_name", "last_name"] + ) + supplier_name = (" ").join(x for x in contact_name if x) # remove any blank values + args = { "update_password_link": update_password_link, "message": frappe.render_template(self.message_for_supplier, doc_args), "rfq_link": rfq_link, "user_fullname": full_name, - "supplier_name": data.get("supplier_name"), + "supplier_name": supplier_name or data.get("supplier_name"), "supplier_salutation": self.salutation or "Dear Mx.", } From b331c462efcb62e9558b00cb5ab1447f744f55bf Mon Sep 17 00:00:00 2001 From: marination Date: Fri, 8 Jul 2022 15:38:44 +0530 Subject: [PATCH 7/7] chore: Instantiate variable unconditionally (cherry picked from commit 300e812a1f2b8752a66c009560ec99e34a07abd1) --- .../doctype/request_for_quotation/request_for_quotation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 8b5bf6f660f..bc32b1d1971 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -182,6 +182,7 @@ class RequestforQuotation(BuyingController): doc_args.update({"supplier": data.get("supplier"), "supplier_name": data.get("supplier_name")}) # Get Contact Full Name + supplier_name = None if data.get("contact"): contact_name = frappe.db.get_value( "Contact", data.get("contact"), ["first_name", "middle_name", "last_name"]