Merge pull request #2764 from nabinhait/fix1
Fetch default accounts, cost center only if company matches with the tra...
This commit is contained in:
commit
2fbafab4b2
@ -144,16 +144,13 @@ def get_basic_details(args, item_doc):
|
|||||||
"warehouse": user_default_warehouse or args.warehouse or item.default_warehouse,
|
"warehouse": user_default_warehouse or args.warehouse or item.default_warehouse,
|
||||||
"income_account": (item.income_account
|
"income_account": (item.income_account
|
||||||
or args.income_account
|
or args.income_account
|
||||||
or frappe.db.get_value("Item Group", item.item_group, "default_income_account")
|
or frappe.db.get_value("Item Group", item.item_group, "default_income_account")),
|
||||||
or frappe.db.get_value("Company", args.company, "default_income_account")),
|
|
||||||
"expense_account": (item.expense_account
|
"expense_account": (item.expense_account
|
||||||
or args.expense_account
|
or args.expense_account
|
||||||
or frappe.db.get_value("Item Group", item.item_group, "default_expense_account")
|
or frappe.db.get_value("Item Group", item.item_group, "default_expense_account")),
|
||||||
or frappe.db.get_value("Company", args.company, "default_expense_account")),
|
|
||||||
"cost_center": (frappe.db.get_value("Project", args.project_name, "cost_center")
|
"cost_center": (frappe.db.get_value("Project", args.project_name, "cost_center")
|
||||||
or (item.selling_cost_center if args.transaction_type == "selling" else item.buying_cost_center)
|
or (item.selling_cost_center if args.transaction_type == "selling" else item.buying_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")),
|
||||||
or frappe.db.get_value("Company", args.company, "cost_center")),
|
|
||||||
"batch_no": None,
|
"batch_no": None,
|
||||||
"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
|
"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
|
||||||
item_doc.get("item_tax")))),
|
item_doc.get("item_tax")))),
|
||||||
@ -171,6 +168,12 @@ def get_basic_details(args, item_doc):
|
|||||||
"discount_percentage": 0.0
|
"discount_percentage": 0.0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# if default specified in item is for another company, fetch from company
|
||||||
|
for d in [["Account", "income_account", "default_income_account"], ["Account", "expense_account", "default_expense_account"],
|
||||||
|
["Cost Center", "cost_center", "cost_center"], ["Warehouse", "warehouse", ""]]:
|
||||||
|
if not out[d[1]] or args.company != frappe.db.get_value(d[0], out.get(d[1]), "company"):
|
||||||
|
out[d[1]] = frappe.db.get_value("Company", args.company, d[2]) if d[2] else None
|
||||||
|
|
||||||
for fieldname in ("item_name", "item_group", "barcode", "brand", "stock_uom"):
|
for fieldname in ("item_name", "item_group", "barcode", "brand", "stock_uom"):
|
||||||
out[fieldname] = item.get(fieldname)
|
out[fieldname] = item.get(fieldname)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user