mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-03 10:35:27 +00:00
fix: don't duplicate default income account to Item (#50413)
* fix: don't duplicate default income account to Item
Only store _Default Income Account_ in **Item** if it's different from the **Company**'s _Default Income Account_.
Resolves #48231
* refactor: move db call out of loop
* docs: add docstring
(cherry picked from commit b6cb9d4799)
This commit is contained in:
@@ -1004,10 +1004,19 @@ class SellingController(StockController):
|
|||||||
|
|
||||||
|
|
||||||
def set_default_income_account_for_item(obj):
|
def set_default_income_account_for_item(obj):
|
||||||
for d in obj.get("items"):
|
"""Set income account as default for items in the transaction.
|
||||||
if d.item_code:
|
|
||||||
if getattr(d, "income_account", None):
|
Updates the item default income account for each item in the transaction
|
||||||
set_item_default(d.item_code, obj.company, "income_account", d.income_account)
|
if it differs from the company's default income account.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
obj: Transaction document containing items table with income_account field
|
||||||
|
"""
|
||||||
|
company_default = frappe.get_cached_value("Company", obj.company, "default_income_account")
|
||||||
|
for d in obj.get("items", default=[]):
|
||||||
|
income_account = getattr(d, "income_account", None)
|
||||||
|
if d.item_code and income_account and income_account != company_default:
|
||||||
|
set_item_default(d.item_code, obj.company, "income_account", income_account)
|
||||||
|
|
||||||
|
|
||||||
def get_serial_and_batch_bundle(child, parent, delivery_note_child=None):
|
def get_serial_and_batch_bundle(child, parent, delivery_note_child=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user