From d727c52421c8a6da97f9688abe1cece3e330a441 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 17:53:52 +0530 Subject: [PATCH 01/11] =?UTF-8?q?fix:=20added=20brand=20column=20in=20Ware?= =?UTF-8?q?house=20wise=20Item=20Balance=20Age=20and=20Value=20=E2=80=A6?= =?UTF-8?q?=20(backport=20#41280)=20(#41281)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: added brand column in Warehouse wise Item Balance Age and Value … (#41280) fix: added brand coulmn in Warehouse wise Item Balance Age and Value report (cherry picked from commit 1cbc200770d2955f9d638c0047e0e58a514a5d23) Co-authored-by: rohitwaghchaure --- .../warehouse_wise_item_balance_age_and_value.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py index e1cce31329e..f5a059a7f61 100644 --- a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py +++ b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py @@ -56,13 +56,14 @@ def execute(filters=None): item_value.setdefault((item, item_map[item]["item_group"]), []) item_value[(item, item_map[item]["item_group"])].append(total_stock_value) + itemwise_brand = frappe._dict(get_itemwise_brand(items)) # sum bal_qty by item for (item, item_group), wh_balance in item_balance.items(): if not item_ageing.get(item): continue total_stock_value = sum(item_value[(item, item_group)]) - row = [item, item_map[item]["item_name"], item_group, total_stock_value] + row = [item, item_map[item]["item_name"], item_group, itemwise_brand.get(item), total_stock_value] fifo_queue = item_ageing[item]["fifo_queue"] average_age = 0.00 @@ -85,6 +86,10 @@ def execute(filters=None): return columns, data +def get_itemwise_brand(items): + return frappe.get_all("Item", filters={"name": ("in", items)}, fields=["name", "brand"], as_list=1) + + def get_columns(filters): """return columns""" @@ -92,6 +97,7 @@ def get_columns(filters): _("Item") + ":Link/Item:150", _("Item Name") + ":Link/Item:150", _("Item Group") + "::120", + _("Brand") + ":Link/Brand:120", _("Value") + ":Currency:120", _("Age") + ":Float:120", ] From e82ea12cbc19f52491b4fdc3922abd829ab07f40 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 3 May 2024 18:34:27 +0530 Subject: [PATCH 02/11] fix: Cost center not getting saved in PSOA (cherry picked from commit 58f70396307846ac014398f3016cc94c0318d656) # Conflicts: # erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json # erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py --- .../psoa_cost_center/psoa_cost_center.json | 8 +++++++- .../psoa_cost_center/psoa_cost_center.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json index e292b60d68d..9a19ff9ad90 100644 --- a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json +++ b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json @@ -11,13 +11,19 @@ { "fieldname": "cost_center_name", "fieldtype": "Link", + "in_list_view": 1, "label": "Cost Center", - "options": "Cost Center" + "options": "Cost Center", + "reqd": 1 } ], "istable": 1, "links": [], +<<<<<<< HEAD "modified": "2020-08-03 16:56:45.744905", +======= + "modified": "2024-05-03 17:16:51.666461", +>>>>>>> 58f7039630 (fix: Cost center not getting saved in PSOA) "modified_by": "Administrator", "module": "Accounts", "name": "PSOA Cost Center", diff --git a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py index 877998a187c..275d57a336f 100644 --- a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py +++ b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py @@ -7,4 +7,21 @@ from frappe.model.document import Document class PSOACostCenter(Document): +<<<<<<< HEAD +======= + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + cost_center_name: DF.Link + parent: DF.Data + parentfield: DF.Data + parenttype: DF.Data + # end: auto-generated types + +>>>>>>> 58f7039630 (fix: Cost center not getting saved in PSOA) pass From 6aa8d5fb4b1bb44350dc72f04f48f55950941d2b Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 6 May 2024 11:29:53 +0530 Subject: [PATCH 03/11] chore: resolve conflicts --- .../accounts/doctype/psoa_cost_center/psoa_cost_center.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json index 9a19ff9ad90..ef4a55861fb 100644 --- a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json +++ b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json @@ -19,11 +19,7 @@ ], "istable": 1, "links": [], -<<<<<<< HEAD - "modified": "2020-08-03 16:56:45.744905", -======= "modified": "2024-05-03 17:16:51.666461", ->>>>>>> 58f7039630 (fix: Cost center not getting saved in PSOA) "modified_by": "Administrator", "module": "Accounts", "name": "PSOA Cost Center", @@ -33,4 +29,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1 -} \ No newline at end of file +} From 7b9c22775c08740d50680a091be226aee92d2a69 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 6 May 2024 11:52:26 +0530 Subject: [PATCH 04/11] chore: resolve conflicts --- .../psoa_cost_center/psoa_cost_center.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py index 275d57a336f..877998a187c 100644 --- a/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py +++ b/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.py @@ -7,21 +7,4 @@ from frappe.model.document import Document class PSOACostCenter(Document): -<<<<<<< HEAD -======= - # begin: auto-generated types - # This code is auto-generated. Do not modify anything in this block. - - from typing import TYPE_CHECKING - - if TYPE_CHECKING: - from frappe.types import DF - - cost_center_name: DF.Link - parent: DF.Data - parentfield: DF.Data - parenttype: DF.Data - # end: auto-generated types - ->>>>>>> 58f7039630 (fix: Cost center not getting saved in PSOA) pass From 93b30d9f1176ee4bf45906c73ea2cb266621dc65 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 6 May 2024 12:07:33 +0530 Subject: [PATCH 05/11] fix: incorrect query for Purchase Invoice rate in GP (cherry picked from commit bd8382c59259a9115fdd2c04ccfc297c89946d5d) --- erpnext/accounts/report/gross_profit/gross_profit.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index f4d4772901c..5d656bb0a79 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -717,20 +717,22 @@ class GrossProfitGenerator: frappe.qb.from_(purchase_invoice_item) .inner_join(purchase_invoice) .on(purchase_invoice.name == purchase_invoice_item.parent) - .select(purchase_invoice_item.base_rate / purchase_invoice_item.conversion_factor) + .select( + purchase_invoice.name, + purchase_invoice_item.base_rate / purchase_invoice_item.conversion_factor, + ) .where(purchase_invoice.docstatus == 1) .where(purchase_invoice.posting_date <= self.filters.to_date) .where(purchase_invoice_item.item_code == item_code) ) if row.project: - query.where(purchase_invoice_item.project == row.project) + query = query.where(purchase_invoice_item.project == row.project) if row.cost_center: - query.where(purchase_invoice_item.cost_center == row.cost_center) + query = query.where(purchase_invoice_item.cost_center == row.cost_center) - query.orderby(purchase_invoice.posting_date, order=frappe.qb.desc) - query.limit(1) + query = query.orderby(purchase_invoice.posting_date, order=frappe.qb.desc).limit(1) last_purchase_rate = query.run() return flt(last_purchase_rate[0][0]) if last_purchase_rate else 0 From cd33199da29b252a1fe54b5465fa19bf539cba78 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 6 May 2024 21:37:27 +0530 Subject: [PATCH 06/11] fix: reset rate for serial batch supplied items (#41293) --- .../subcontracting_receipt.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py index c0235f9b85c..aeae7c84679 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py @@ -8,6 +8,7 @@ from frappe.utils import cint, flt, getdate, nowdate import erpnext from erpnext.accounts.utils import get_account_currency from erpnext.controllers.subcontracting_controller import SubcontractingController +from erpnext.stock.utils import get_incoming_rate class SubcontractingReceipt(SubcontractingController): @@ -67,6 +68,7 @@ class SubcontractingReceipt(SubcontractingController): self.set_items_bom() self.set_items_cost_center() self.set_items_expense_account() + self.reset_rate_for_serial_batch_supplied_items() def validate(self): if ( @@ -124,6 +126,26 @@ class SubcontractingReceipt(SubcontractingController): self.calculate_supplied_items_qty_and_amount() self.calculate_items_qty_and_amount() + def reset_rate_for_serial_batch_supplied_items(self): + for item in self.supplied_items: + if item.serial_no or item.batch_no: + args = frappe._dict( + { + "item_code": item.rm_item_code, + "warehouse": self.supplier_warehouse, + "posting_date": self.posting_date, + "posting_time": self.posting_time, + "qty": flt(item.consumed_qty), + "serial_no": item.serial_no, + "batch_no": item.batch_no, + "voucher_type": self.doctype, + "voucher_no": self.name, + "company": self.company, + "allow_zero_valuation": 1, + } + ) + item.rate = get_incoming_rate(args) + def has_serial_batch_items(self): if not self.get("supplied_items"): return False From a26ae64385d65e1c20151c30cae2c6fd66a8699a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 21:46:18 +0530 Subject: [PATCH 07/11] fix: missing Item Name on Save for Quotation created from Item (backport #41233) (#41303) fix: missing Item Name on Save for Quotation created from Item (#41233) * fix: missing Item Name on Save for Quotation created from Item * fix: missing Item Name on Save for Quotation created from Item (cherry picked from commit c8e92cb1b2a5f9c0a116e2deb53eea440577cdb6) Co-authored-by: HENRY Florian --- erpnext/stock/doctype/item/item.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 29d41fe7625..a7972790b1a 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -15,6 +15,9 @@ frappe.ui.form.on("Item", { frm.add_fetch("tax_type", "tax_rate", "tax_rate"); frm.make_methods = { + Quotation: () => { + open_form(frm, "Quotation", "Quotation Item", "items"); + }, "Sales Order": () => { open_form(frm, "Sales Order", "Sales Order Item", "items"); }, From d2ce9278915f86fa4f553de3ff6de1163f09b8c3 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 2 May 2024 09:37:24 +0530 Subject: [PATCH 08/11] fix: pricing rule rounding Consider a pricing rule of 20:1 with recursion enabled, free items should follow the below progression | Qty | Free item qty | |-------+---------------| | 0-19 | 0 | | 20-39 | 1 | | 40-59 | 2 | (cherry picked from commit 9bf37426c13d6a92db46a49d58b4d36faef048f2) --- erpnext/accounts/doctype/pricing_rule/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index ce96a3d1240..2a78bebd103 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -6,6 +6,7 @@ import copy import json +import math import frappe from frappe import _, bold @@ -638,7 +639,7 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None): if transaction_qty: qty = flt(transaction_qty) * qty / pricing_rule.recurse_for if pricing_rule.round_free_qty: - qty = round(qty) + qty = math.floor(qty) free_item_data_args = { "item_code": free_item, From e068bec212c03fd05966f6ca7a9afbaab349d785 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 7 May 2024 09:44:10 +0530 Subject: [PATCH 09/11] refactor(test): test floor based rounding (cherry picked from commit c41a037174c6f6136086de8b3c822ffff2bb9f60) --- erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py index cb0c223bffa..18658e6e4a6 100644 --- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py @@ -976,7 +976,7 @@ class TestPricingRule(unittest.TestCase): so.load_from_db() self.assertEqual(so.items[1].is_free_item, 1) self.assertEqual(so.items[1].item_code, "_Test Item") - self.assertEqual(so.items[1].qty, 4) + self.assertEqual(so.items[1].qty, 3) def test_apply_multiple_pricing_rules_for_discount_percentage_and_amount(self): frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1") From 339256bc71edae761d11faf771d75db987446de5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 00:15:33 +0530 Subject: [PATCH 10/11] fix: filter validation for batch-wise balance history report (backport #41356) (#41360) fix: filter validation for batch-wise balance history report (#41356) fix: filter validation for batchwise balance history report (cherry picked from commit 544fc60093cfdc1a92c4ccced7ab5794626fd87c) Co-authored-by: rohitwaghchaure --- .../batch_wise_balance_history.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py index 8e27b8c4f69..7c23e4c8f1e 100644 --- a/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py +++ b/erpnext/stock/report/batch_wise_balance_history/batch_wise_balance_history.py @@ -29,8 +29,15 @@ def execute(filters=None): sle_count = _estimate_table_row_count("Stock Ledger Entry") - if sle_count > SLE_COUNT_LIMIT and not filters.get("item_code") and not filters.get("warehouse"): - frappe.throw(_("Please select either the Item or Warehouse filter to generate the report.")) + if ( + sle_count > SLE_COUNT_LIMIT + and not filters.get("item_code") + and not filters.get("warehouse") + and not filters.get("warehouse_type") + ): + frappe.throw( + _("Please select either the Item or Warehouse or Warehouse Type filter to generate the report.") + ) if filters.from_date > filters.to_date: frappe.throw(_("From Date must be before To Date")) From 4647ec88929a29303aa3933165a54e555fc8043b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 11:38:02 +0530 Subject: [PATCH 11/11] perf: index on item code for the Pick List Item doctype (backport #41357) (#41362) * perf: index on item code for the Pick List Item doctype (#41357) (cherry picked from commit 0887161f2afcb76d88edb8d5c568b5c766568f71) # Conflicts: # erpnext/stock/doctype/pick_list_item/pick_list_item.json * chore: fix conflicts --------- Co-authored-by: rohitwaghchaure --- erpnext/stock/doctype/pick_list_item/pick_list_item.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/pick_list_item/pick_list_item.json b/erpnext/stock/doctype/pick_list_item/pick_list_item.json index 883cdd19e7c..bad79a02907 100644 --- a/erpnext/stock/doctype/pick_list_item/pick_list_item.json +++ b/erpnext/stock/doctype/pick_list_item/pick_list_item.json @@ -126,7 +126,8 @@ "in_list_view": 1, "label": "Item", "options": "Item", - "reqd": 1 + "reqd": 1, + "search_index": 1 }, { "fieldname": "quantity_section", @@ -193,7 +194,7 @@ ], "istable": 1, "links": [], - "modified": "2023-07-25 11:56:23.361867", + "modified": "2024-05-07 15:32:42.905446", "modified_by": "Administrator", "module": "Stock", "name": "Pick List Item", @@ -204,4 +205,4 @@ "sort_order": "DESC", "states": [], "track_changes": 1 -} \ No newline at end of file +}