diff --git a/.github/helper/install.sh b/.github/helper/install.sh index 1abcd7683e7..d9e5d8d400e 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -188,7 +188,7 @@ restore_warm_bench() { # Phase 1 already fetched ~/frappe to the exact live develop SHA. Fetch that commit # straight from it (bench init names the remote 'upstream', not 'origin', and points # it at this local clone — so a plain `git fetch origin` does not work). - git fetch --no-tags "$HOME/frappe" HEAD || exit 1 + git fetch --no-tags --update-shallow "$HOME/frappe" HEAD || exit 1 git checkout --force FETCH_HEAD || exit 1 ); then echo "Fast-forward to ${frappe_sha} failed; falling back to full init" diff --git a/erpnext/controllers/subcontracting_inward_controller.py b/erpnext/controllers/subcontracting_inward_controller.py index 7cf6ca5e40f..10dafae806e 100644 --- a/erpnext/controllers/subcontracting_inward_controller.py +++ b/erpnext/controllers/subcontracting_inward_controller.py @@ -4,7 +4,6 @@ import frappe from frappe import _, bold from frappe.query_builder import Case from frappe.utils import flt, get_link_to_form -from pypika.terms import ValueWrapper from erpnext.stock.serial_batch_bundle import get_serial_batch_list_from_item @@ -509,21 +508,13 @@ class SubcontractingInwardController: ) table = frappe.qb.DocType("Subcontracting Inward Order Item") + allowed_qty = table.produced_qty + if not allow_delivery_of_overproduced_qty: + allowed_qty = Case().when(table.produced_qty < table.qty, table.produced_qty).else_(table.qty) + query = ( frappe.qb.from_(table) - .select( - ( - Case() - .when( - # bool() so the literal renders as true/false; postgres rejects `OR ` - (table.produced_qty < table.qty) - | ValueWrapper(bool(allow_delivery_of_overproduced_qty)), - table.produced_qty, - ) - .else_(table.qty) - - table.delivered_qty - ).as_("max_allowed_qty") - ) + .select((allowed_qty - table.delivered_qty).as_("max_allowed_qty")) .where((table.name == item.scio_detail) & (table.docstatus == 1)) ) max_allowed_qty = query.run(pluck="max_allowed_qty")