Fix cost center not getting pulled in DN and SINV (#8878)

* Fixes for getting selling cost center instead of company's default cost center.

* fix error in update_item
This commit is contained in:
Sagar Vora 2017-05-17 19:16:27 +05:30 committed by Nabin Hait
parent 67ddcf9d32
commit 3b04b030eb
3 changed files with 18 additions and 11 deletions

View File

@ -826,7 +826,8 @@ def make_delivery_note(source_name, target_doc=None):
"parent": "against_sales_invoice",
"serial_no": "serial_no",
"sales_order": "against_sales_order",
"so_detail": "so_detail"
"so_detail": "so_detail",
"cost_center": "cost_center"
},
"postprocess": update_item,
"condition": lambda doc: doc.delivered_by_supplier!=1

View File

@ -427,6 +427,11 @@ def make_delivery_note(source_name, target_doc=None):
target.amount = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.rate)
target.qty = flt(source.qty) - flt(source.delivered_qty)
item = frappe.db.get_value("Item", target.item_code, ["item_group", "selling_cost_center"], as_dict=1)
target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center") \
or item.selling_cost_center \
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
target_doc = get_mapped_doc("Sales Order", source_name, {
"Sales Order": {
"doctype": "Delivery Note",

View File

@ -398,7 +398,8 @@ def make_sales_invoice(source_name, target_doc=None):
"parent": "delivery_note",
"so_detail": "so_detail",
"against_sales_order": "sales_order",
"serial_no": "serial_no"
"serial_no": "serial_no",
"cost_center": "cost_center"
},
"postprocess": update_item,
"filter": lambda d: abs(d.qty) - abs(invoiced_qty_map.get(d.name, 0))<=0