Merge pull request #14090 from manassolanki/poc-fixes
create item default on making of invoice
This commit is contained in:
commit
fa57cdd86d
@ -343,17 +343,16 @@ def check_active_sales_items(obj):
|
|||||||
item = frappe.db.sql("""select i.docstatus, id.income_account
|
item = frappe.db.sql("""select i.docstatus, id.income_account
|
||||||
from `tabItem` i, `tabItem Default` id
|
from `tabItem` i, `tabItem Default` id
|
||||||
where i.name=%s and id.parent=i.name and id.company=%s""",
|
where i.name=%s and id.parent=i.name and id.company=%s""",
|
||||||
(d.item_code,obj.company), as_dict=True)
|
(d.item_code, obj.company), as_dict=True)
|
||||||
|
|
||||||
income_account_set = False
|
if getattr(d, "income_account", None):
|
||||||
if getattr(d, "income_account", None) and item and not item[0].income_account:
|
|
||||||
doc = frappe.get_doc("Item", d.item_code)
|
doc = frappe.get_doc("Item", d.item_code)
|
||||||
|
if item and not item[0].income_account:
|
||||||
for default in doc.item_defaults:
|
for default in doc.item_defaults:
|
||||||
if default.company == obj.company:
|
if default.company == obj.company:
|
||||||
default.income_account = d.income_account
|
default.income_account = d.income_account
|
||||||
income_account_set = True
|
|
||||||
break
|
break
|
||||||
if not income_account_set:
|
elif not item:
|
||||||
doc.append("item_defaults", {
|
doc.append("item_defaults", {
|
||||||
"company": obj.company,
|
"company": obj.company,
|
||||||
"income_account": d.income_account
|
"income_account": d.income_account
|
||||||
|
Loading…
x
Reference in New Issue
Block a user