From c574494ddd0d78f0ccddc38d38996a11001a19a0 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:15:24 +0530 Subject: [PATCH 1/4] fix: removed "fetch_from" (backport #36365) (#36387) fix: removed "fetch_from" * fix: removed ("fetch_from": "goal.objective") The field ended up being disabled because of this. (cherry picked from commit 1c687a4afd43591e561cde29672a4d680c37d888) Co-authored-by: xdlumertz --- .../quality_goal_objective/quality_goal_objective.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/quality_management/doctype/quality_goal_objective/quality_goal_objective.json b/erpnext/quality_management/doctype/quality_goal_objective/quality_goal_objective.json index e3dbd660b543..010888dd31fc 100644 --- a/erpnext/quality_management/doctype/quality_goal_objective/quality_goal_objective.json +++ b/erpnext/quality_management/doctype/quality_goal_objective/quality_goal_objective.json @@ -1,4 +1,5 @@ { + "actions": [], "autoname": "format:{####}", "creation": "2019-05-26 15:03:43.996455", "doctype": "DocType", @@ -12,7 +13,6 @@ ], "fields": [ { - "fetch_from": "goal.objective", "fieldname": "objective", "fieldtype": "Text", "in_list_view": 1, @@ -38,14 +38,17 @@ } ], "istable": 1, - "modified": "2019-05-26 16:12:54.832058", + "links": [], + "modified": "2023-07-28 18:10:23.351246", "modified_by": "Administrator", "module": "Quality Management", "name": "Quality Goal Objective", + "naming_rule": "Expression", "owner": "Administrator", "permissions": [], "quick_entry": 1, "sort_field": "modified", "sort_order": "DESC", + "states": [], "track_changes": 1 } \ No newline at end of file From e9df06406f63824ceb101d59641254484bf1a84c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 29 Jul 2023 18:14:26 +0530 Subject: [PATCH 2/4] fix: only publish repost progress to doc subscriber (backport #36400) (#36403) * fix: only publish repost progress to doc subscriber (#36400) Huge size of string gets blasted to everyone on site. Due to some memory leak (cause unknown) till sockets are open the strings are also in process' memory. related https://github.com/frappe/frappe/issues/21863 (cherry picked from commit c0642cf528e2054192f5d16dd9d5c1a8162069cf) # Conflicts: # erpnext/stock/stock_ledger.py * chore: conflicts --------- Co-authored-by: Ankush Menat --- erpnext/stock/stock_ledger.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index e1aa01906b3c..a3f0032b8ac0 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -278,6 +278,8 @@ def update_args_in_repost_item_valuation( frappe.publish_realtime( "item_reposting_progress", {"name": doc.name, "items_to_be_repost": json.dumps(args, default=str), "current_index": index}, + doctype=doc.doctype, + docname=doc.name, ) From cdc86bd76c5e3f3db8cae9c6abcb5ad2522cb4f9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:39:31 +0530 Subject: [PATCH 3/4] perf: use `LEFT JOIN` instead of `NOT EXISTS` (backport #36221) (#36384) * perf: use `LEFT JOIN` instead of `NOT EXISTS` (cherry picked from commit 58d867503b38fb72c850a2008ec5f33455e643d0) # Conflicts: # erpnext/manufacturing/doctype/bom_update_log/bom_updation_utils.py * fix: long queue `process_boms_cost_level_wise` (cherry picked from commit 148d466ae53b4754b5ea7209d9d67f6731f6a2d3) * chore: `conflicts` * fix: failing test case --------- Co-authored-by: s-aga-r --- .../doctype/bom_update_log/bom_update_log.py | 1 + .../bom_update_log/bom_updation_utils.py | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py b/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py index 9c35e49b20b4..9365424b5a7c 100644 --- a/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py +++ b/erpnext/manufacturing/doctype/bom_update_log/bom_update_log.py @@ -79,6 +79,7 @@ def on_submit(self): else: frappe.enqueue( method="erpnext.manufacturing.doctype.bom_update_log.bom_update_log.process_boms_cost_level_wise", + queue="long", update_doc=self, now=frappe.flags.in_test, ) diff --git a/erpnext/manufacturing/doctype/bom_update_log/bom_updation_utils.py b/erpnext/manufacturing/doctype/bom_update_log/bom_updation_utils.py index 3d52cd811bb8..d0eaa37b06be 100644 --- a/erpnext/manufacturing/doctype/bom_update_log/bom_updation_utils.py +++ b/erpnext/manufacturing/doctype/bom_update_log/bom_updation_utils.py @@ -157,12 +157,21 @@ def _all_children_are_processed(parent_bom): def get_leaf_boms() -> List[str]: "Get BOMs that have no dependencies." - return frappe.db.sql_list( - """select name from `tabBOM` bom - where docstatus=1 and is_active=1 - and not exists(select bom_no from `tabBOM Item` - where parent=bom.name and ifnull(bom_no, '')!='')""" - ) + bom = frappe.qb.DocType("BOM") + bom_item = frappe.qb.DocType("BOM Item") + + boms = ( + frappe.qb.from_(bom) + .left_join(bom_item) + .on((bom.name == bom_item.parent) & (bom_item.bom_no != "")) + .select(bom.name) + .where((bom.docstatus == 1) & (bom.is_active == 1) & (bom_item.bom_no.isnull())) + .distinct() + ).run(as_list=True) + + boms = [bom[0] for bom in boms] + + return boms def _generate_dependence_map() -> defaultdict: From a165b37fd73f6b68f17c19f7e537e08ba035bb2f Mon Sep 17 00:00:00 2001 From: RitvikSardana <65544983+RitvikSardana@users.noreply.github.com> Date: Mon, 31 Jul 2023 23:28:10 +0530 Subject: [PATCH 4/4] fix: added validation for unique serial numbers in pos invoice (#36302) * fix: added validation for unique serial numbers in pos invoice * fix: updated title of validation * fix: removed extra whitespace * fix: added validation for duplicate batch numbers --------- Co-authored-by: Ritvik Sardana --- .../doctype/pos_invoice/pos_invoice.py | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py index 7f84cdbb15bf..a4a4338e0862 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py @@ -1,6 +1,6 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and contributors # For license information, please see license.txt - +import collections import frappe from frappe import _ @@ -44,6 +44,7 @@ def validate(self): self.validate_debit_to_acc() self.validate_write_off_account() self.validate_change_amount() + self.validate_duplicate_serial_and_batch_no() self.validate_change_account() self.validate_item_cost_centers() self.validate_warehouse() @@ -154,6 +155,27 @@ def validate_pos_reserved_serial_nos(self, item): title=_("Item Unavailable"), ) + def validate_duplicate_serial_and_batch_no(self): + serial_nos = [] + batch_nos = [] + + for row in self.get("items"): + if row.serial_no: + serial_nos = row.serial_no.split("\n") + + if row.batch_no and not row.serial_no: + batch_nos.append(row.batch_no) + + if serial_nos: + for key, value in collections.Counter(serial_nos).items(): + if value > 1: + frappe.throw(_("Duplicate Serial No {0} found").format("key")) + + if batch_nos: + for key, value in collections.Counter(batch_nos).items(): + if value > 1: + frappe.throw(_("Duplicate Batch No {0} found").format("key")) + def validate_pos_reserved_batch_qty(self, item): filters = {"item_code": item.item_code, "warehouse": item.warehouse, "batch_no": item.batch_no}