mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-18 06:15:10 +00:00
* fix: TypeError: 'float' object is not iterable (#41758)
(cherry picked from commit cf508ce1ed)
# Conflicts:
# erpnext/manufacturing/doctype/bom_creator/bom_creator.py
# erpnext/public/js/bom_configurator/bom_configurator.bundle.js
* chore: fix conflicts
* chore: fix conflicts
---------
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from collections import defaultdict
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.query_builder.functions import CombineDatetime
|
from frappe.query_builder.functions import CombineDatetime, Sum
|
||||||
from frappe.utils import cint, flt
|
from frappe.utils import cint, flt
|
||||||
|
|
||||||
from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions
|
from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions
|
||||||
@@ -69,12 +69,12 @@ def execute(filters=None):
|
|||||||
stock_value += sle.stock_value_difference
|
stock_value += sle.stock_value_difference
|
||||||
if sle.batch_no:
|
if sle.batch_no:
|
||||||
if not batch_balance_dict.get(sle.batch_no):
|
if not batch_balance_dict.get(sle.batch_no):
|
||||||
batch_balance_dict[sle.batch_no] = 0
|
batch_balance_dict[sle.batch_no] = [0, 0]
|
||||||
|
|
||||||
batch_balance_dict[sle.batch_no] += sle.actual_qty
|
batch_balance_dict[sle.batch_no][0] += sle.actual_qty
|
||||||
|
|
||||||
if filters.get("segregate_serial_batch_bundle"):
|
if filters.get("segregate_serial_batch_bundle"):
|
||||||
actual_qty = batch_balance_dict[sle.batch_no]
|
actual_qty = batch_balance_dict[sle.batch_no][0]
|
||||||
|
|
||||||
if sle.voucher_type == "Stock Reconciliation" and not sle.actual_qty:
|
if sle.voucher_type == "Stock Reconciliation" and not sle.actual_qty:
|
||||||
actual_qty = sle.qty_after_transaction
|
actual_qty = sle.qty_after_transaction
|
||||||
@@ -530,7 +530,9 @@ def get_opening_balance_from_batch(filters, columns, sl_entries):
|
|||||||
query_filters = {
|
query_filters = {
|
||||||
"batch_no": filters.batch_no,
|
"batch_no": filters.batch_no,
|
||||||
"docstatus": 1,
|
"docstatus": 1,
|
||||||
|
"is_cancelled": 0,
|
||||||
"posting_date": ("<", filters.from_date),
|
"posting_date": ("<", filters.from_date),
|
||||||
|
"company": filters.company,
|
||||||
}
|
}
|
||||||
|
|
||||||
for fields in ["item_code", "warehouse"]:
|
for fields in ["item_code", "warehouse"]:
|
||||||
@@ -547,25 +549,30 @@ def get_opening_balance_from_batch(filters, columns, sl_entries):
|
|||||||
if opening_data.get(field) is None:
|
if opening_data.get(field) is None:
|
||||||
opening_data[field] = 0.0
|
opening_data[field] = 0.0
|
||||||
|
|
||||||
query_filters = [
|
table = frappe.qb.DocType("Stock Ledger Entry")
|
||||||
["Serial and Batch Entry", "batch_no", "=", filters.batch_no],
|
sabb_table = frappe.qb.DocType("Serial and Batch Entry")
|
||||||
["Serial and Batch Bundle", "docstatus", "=", 1],
|
query = (
|
||||||
["Serial and Batch Bundle", "posting_date", "<", filters.from_date],
|
frappe.qb.from_(table)
|
||||||
]
|
.inner_join(sabb_table)
|
||||||
|
.on(table.serial_and_batch_bundle == sabb_table.parent)
|
||||||
for fields in ["item_code", "warehouse"]:
|
.select(
|
||||||
if filters.get(fields):
|
Sum(sabb_table.qty).as_("qty"),
|
||||||
query_filters.append(["Serial and Batch Bundle", fields, "=", filters.get(fields)])
|
Sum(sabb_table.stock_value_difference).as_("stock_value"),
|
||||||
|
)
|
||||||
bundle_data = frappe.get_all(
|
.where(
|
||||||
"Serial and Batch Bundle",
|
(sabb_table.batch_no == filters.batch_no)
|
||||||
fields=[
|
& (sabb_table.docstatus == 1)
|
||||||
"sum(`tabSerial and Batch Entry`.`qty`) as qty",
|
& (table.posting_date < filters.from_date)
|
||||||
"sum(`tabSerial and Batch Entry`.`stock_value_difference`) as stock_value",
|
& (table.is_cancelled == 0)
|
||||||
],
|
)
|
||||||
filters=query_filters,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for field in ["item_code", "warehouse", "company"]:
|
||||||
|
if filters.get(field):
|
||||||
|
query = query.where(table[field] == filters.get(field))
|
||||||
|
|
||||||
|
bundle_data = query.run(as_dict=True)
|
||||||
|
|
||||||
if bundle_data:
|
if bundle_data:
|
||||||
opening_data.qty_after_transaction += flt(bundle_data[0].qty)
|
opening_data.qty_after_transaction += flt(bundle_data[0].qty)
|
||||||
opening_data.stock_value += flt(bundle_data[0].stock_value)
|
opening_data.stock_value += flt(bundle_data[0].stock_value)
|
||||||
|
|||||||
Reference in New Issue
Block a user