* Resolve issue #10914 An exception was raised when a Sales Order has been created to a Sales Invoice and one of the items had no Item Code. * Update sales_order.py
This commit is contained in:
parent
db4fd7f5b6
commit
567623654b
@ -567,9 +567,11 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
|
|||||||
target.base_amount = target.amount * flt(source_parent.conversion_rate)
|
target.base_amount = target.amount * flt(source_parent.conversion_rate)
|
||||||
target.qty = target.amount / flt(source.rate) if (source.rate and source.billed_amt) else source.qty
|
target.qty = target.amount / flt(source.rate) if (source.rate and source.billed_amt) else source.qty
|
||||||
|
|
||||||
|
if source_parent.project:
|
||||||
|
target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center")
|
||||||
|
if not target.cost_center and target.item_code:
|
||||||
item = frappe.db.get_value("Item", target.item_code, ["item_group", "selling_cost_center"], as_dict=1)
|
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") \
|
target.cost_center = item.selling_cost_center \
|
||||||
or item.selling_cost_center \
|
|
||||||
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
|
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
|
||||||
|
|
||||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user