Set cost center while creating invoice from SO/PO

This commit is contained in:
Nabin Hait 2016-10-18 14:54:17 +05:30
parent 401be3f49b
commit 55a8797919
3 changed files with 15 additions and 4 deletions

View File

@ -10,6 +10,7 @@
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"fields": [
{
"allow_on_submit": 0,
@ -249,14 +250,15 @@
"hide_toolbar": 0,
"icon": "icon-money",
"idx": 1,
"in_create": 0,
"image_view": 0,
"in_create": 1,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-05-16 15:23:14.770933",
"modified": "2016-10-18 14:22:00.207907",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Cost Center",
@ -368,6 +370,5 @@
"read_only_onload": 0,
"search_fields": "parent_cost_center, is_group",
"sort_order": "ASC",
"track_seen": 0,
"version": 0
"track_seen": 0
}

View File

@ -302,6 +302,11 @@ def make_purchase_invoice(source_name, target_doc=None):
target.amount = flt(obj.amount) - flt(obj.billed_amt)
target.base_amount = target.amount * flt(source_parent.conversion_rate)
target.qty = target.amount / flt(obj.rate) if (flt(obj.rate) and flt(obj.billed_amt)) else flt(obj.qty)
item = frappe.db.get_value("Item", target.item_code, ["item_group", "buying_cost_center"], as_dict=1)
target.cost_center = frappe.db.get_value("Project", obj.project, "cost_center") \
or item.buying_cost_center \
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
doc = get_mapped_doc("Purchase Order", source_name, {
"Purchase Order": {

View File

@ -442,6 +442,11 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
target.amount = flt(source.amount) - flt(source.billed_amt)
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
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", obj.project, "cost_center") \
or item.selling_cost_center \
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
doclist = get_mapped_doc("Sales Order", source_name, {
"Sales Order": {