mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
fix: Get Bundle Items
This commit is contained in:
@@ -438,31 +438,7 @@ class GrossProfitGenerator(object):
|
|||||||
parents_index = 0
|
parents_index = 0
|
||||||
for index, row in enumerate(self.si_list):
|
for index, row in enumerate(self.si_list):
|
||||||
if parents_index < len(parents) and row.parent == parents[parents_index]:
|
if parents_index < len(parents) and row.parent == parents[parents_index]:
|
||||||
invoice = frappe._dict({
|
invoice = self.get_invoice_row(row)
|
||||||
'parent_invoice': "",
|
|
||||||
'indent': 0.0,
|
|
||||||
'parent': row.parent,
|
|
||||||
'posting_date': row.posting_date,
|
|
||||||
'posting_time': row.posting_time,
|
|
||||||
'project': row.project,
|
|
||||||
'update_stock': row.update_stock,
|
|
||||||
'customer': row.customer,
|
|
||||||
'customer_group': row.customer_group,
|
|
||||||
'item_code': None,
|
|
||||||
'item_name': None,
|
|
||||||
'description': None,
|
|
||||||
'warehouse': None,
|
|
||||||
'item_group': None,
|
|
||||||
'brand': None,
|
|
||||||
'dn_detail': None,
|
|
||||||
'delivery_note': None,
|
|
||||||
'qty': None,
|
|
||||||
'item_row': None,
|
|
||||||
'is_return': row.is_return,
|
|
||||||
'cost_center': row.cost_center,
|
|
||||||
'base_net_amount': frappe.db.get_value('Sales Invoice', row.parent, 'base_net_total')
|
|
||||||
})
|
|
||||||
|
|
||||||
self.si_list.insert(index, invoice)
|
self.si_list.insert(index, invoice)
|
||||||
parents_index += 1
|
parents_index += 1
|
||||||
|
|
||||||
@@ -476,8 +452,41 @@ class GrossProfitGenerator(object):
|
|||||||
if frappe.db.exists('Product Bundle', row.item_code):
|
if frappe.db.exists('Product Bundle', row.item_code):
|
||||||
self.add_bundle_items(row, index)
|
self.add_bundle_items(row, index)
|
||||||
|
|
||||||
|
def get_invoice_row(self, row):
|
||||||
|
return frappe._dict({
|
||||||
|
'parent_invoice': "",
|
||||||
|
'indent': 0.0,
|
||||||
|
'parent': row.parent,
|
||||||
|
'posting_date': row.posting_date,
|
||||||
|
'posting_time': row.posting_time,
|
||||||
|
'project': row.project,
|
||||||
|
'update_stock': row.update_stock,
|
||||||
|
'customer': row.customer,
|
||||||
|
'customer_group': row.customer_group,
|
||||||
|
'item_code': None,
|
||||||
|
'item_name': None,
|
||||||
|
'description': None,
|
||||||
|
'warehouse': None,
|
||||||
|
'item_group': None,
|
||||||
|
'brand': None,
|
||||||
|
'dn_detail': None,
|
||||||
|
'delivery_note': None,
|
||||||
|
'qty': None,
|
||||||
|
'item_row': None,
|
||||||
|
'is_return': row.is_return,
|
||||||
|
'cost_center': row.cost_center,
|
||||||
|
'base_net_amount': frappe.db.get_value('Sales Invoice', row.parent, 'base_net_total')
|
||||||
|
})
|
||||||
|
|
||||||
def add_bundle_items(self, product_bundle, index):
|
def add_bundle_items(self, product_bundle, index):
|
||||||
bundle_items = frappe.get_all(
|
bundle_items = self.get_bundle_items(product_bundle)
|
||||||
|
|
||||||
|
for i, item in enumerate(bundle_items):
|
||||||
|
bundle_item = self.get_bundle_item_row(product_bundle, item)
|
||||||
|
self.si_list.insert((index+i+1), bundle_item)
|
||||||
|
|
||||||
|
def get_bundle_items(self, product_bundle):
|
||||||
|
return frappe.get_all(
|
||||||
'Product Bundle Item',
|
'Product Bundle Item',
|
||||||
filters = {
|
filters = {
|
||||||
'parent': product_bundle.item_code
|
'parent': product_bundle.item_code
|
||||||
@@ -485,33 +494,31 @@ class GrossProfitGenerator(object):
|
|||||||
fields = ['item_code', 'qty']
|
fields = ['item_code', 'qty']
|
||||||
)
|
)
|
||||||
|
|
||||||
for i, item in enumerate(bundle_items):
|
def get_bundle_item_row(self, product_bundle, item):
|
||||||
item_name, description, item_group, brand = self.get_bundle_item_details(item.item_code)
|
item_name, description, item_group, brand = self.get_bundle_item_details(item.item_code)
|
||||||
|
|
||||||
bundle_item = frappe._dict({
|
return frappe._dict({
|
||||||
'parent_invoice': product_bundle.item_code,
|
'parent_invoice': product_bundle.item_code,
|
||||||
'indent': product_bundle.indent + 1,
|
'indent': product_bundle.indent + 1,
|
||||||
'parent': item.item_code,
|
'parent': item.item_code,
|
||||||
'posting_date': product_bundle.posting_date,
|
'posting_date': product_bundle.posting_date,
|
||||||
'posting_time': product_bundle.posting_time,
|
'posting_time': product_bundle.posting_time,
|
||||||
'project': product_bundle.project,
|
'project': product_bundle.project,
|
||||||
'customer': product_bundle.customer,
|
'customer': product_bundle.customer,
|
||||||
'customer_group': product_bundle.customer_group,
|
'customer_group': product_bundle.customer_group,
|
||||||
'item_code': item.item_code,
|
'item_code': item.item_code,
|
||||||
'item_name': item_name,
|
'item_name': item_name,
|
||||||
'description': description,
|
'description': description,
|
||||||
'warehouse': product_bundle.warehouse,
|
'warehouse': product_bundle.warehouse,
|
||||||
'item_group': item_group,
|
'item_group': item_group,
|
||||||
'brand': brand,
|
'brand': brand,
|
||||||
'dn_detail': product_bundle.dn_detail,
|
'dn_detail': product_bundle.dn_detail,
|
||||||
'delivery_note': product_bundle.delivery_note,
|
'delivery_note': product_bundle.delivery_note,
|
||||||
'qty': (flt(product_bundle.qty) * flt(item.qty)),
|
'qty': (flt(product_bundle.qty) * flt(item.qty)),
|
||||||
'item_row': None,
|
'item_row': None,
|
||||||
'is_return': product_bundle.is_return,
|
'is_return': product_bundle.is_return,
|
||||||
'cost_center': product_bundle.cost_center
|
'cost_center': product_bundle.cost_center
|
||||||
})
|
})
|
||||||
|
|
||||||
self.si_list.insert((index+i+1), bundle_item)
|
|
||||||
|
|
||||||
def get_bundle_item_details(self, item_code):
|
def get_bundle_item_details(self, item_code):
|
||||||
return frappe.db.get_value(
|
return frappe.db.get_value(
|
||||||
|
|||||||
Reference in New Issue
Block a user