fix(item_defaults): Item name was overwriting by child name
This commit is contained in:
parent
ddbf3aaccb
commit
3b5f18231a
@ -4,6 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import urllib
|
||||
import copy
|
||||
from frappe.utils import nowdate, cint, cstr
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
from frappe.website.website_generator import WebsiteGenerator
|
||||
@ -180,6 +181,8 @@ def get_item_group_defaults(item, company):
|
||||
|
||||
for d in item_group.item_group_defaults or []:
|
||||
if d.company == company:
|
||||
return d.as_dict()
|
||||
row = copy.deepcopy(d.as_dict())
|
||||
row.pop("name")
|
||||
return row
|
||||
|
||||
return frappe._dict()
|
@ -7,6 +7,7 @@ import itertools
|
||||
import json
|
||||
import erpnext
|
||||
import frappe
|
||||
import copy
|
||||
from erpnext.controllers.item_variant import (ItemVariantExistsError,
|
||||
copy_attributes_to_variant, get_variant, make_variant_item_code, validate_item_variant_attributes)
|
||||
from erpnext.setup.doctype.item_group.item_group import (get_parent_item_groups, invalidate_cache_for)
|
||||
@ -933,8 +934,9 @@ def get_item_defaults(item_code, company):
|
||||
|
||||
for d in item.item_defaults:
|
||||
if d.company == company:
|
||||
out.update(d.as_dict())
|
||||
|
||||
row = copy.deepcopy(d.as_dict())
|
||||
row.pop("name")
|
||||
out.update(row)
|
||||
return out
|
||||
|
||||
def set_item_default(item_code, company, fieldname, value):
|
||||
|
@ -320,12 +320,6 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
'asset_category': asset_category, 'serial_no_series': 'ABC.###'})
|
||||
asset_item = item_data.item_code
|
||||
|
||||
if not frappe.db.exists('Location', 'Test Location'):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Location',
|
||||
'location_name': 'Test Location'
|
||||
}).insert()
|
||||
|
||||
pr = make_purchase_receipt(item_code=asset_item, qty=3)
|
||||
asset = frappe.db.get_value('Asset', {'purchase_receipt': pr.name}, 'name')
|
||||
asset_movement = frappe.db.get_value('Asset Movement', {'reference_name': pr.name}, 'name')
|
||||
@ -348,6 +342,12 @@ def get_gl_entries(voucher_type, voucher_no):
|
||||
order by account desc""", (voucher_type, voucher_no), as_dict=1)
|
||||
|
||||
def make_purchase_receipt(**args):
|
||||
if not frappe.db.exists('Location', 'Test Location'):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Location',
|
||||
'location_name': 'Test Location'
|
||||
}).insert()
|
||||
|
||||
frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
|
||||
pr = frappe.new_doc("Purchase Receipt")
|
||||
args = frappe._dict(args)
|
||||
@ -388,5 +388,5 @@ def make_purchase_receipt(**args):
|
||||
return pr
|
||||
|
||||
|
||||
test_dependencies = ["BOM", "Item Price"]
|
||||
test_dependencies = ["BOM", "Item Price", "Location"]
|
||||
test_records = frappe.get_test_records('Purchase Receipt')
|
||||
|
Loading…
x
Reference in New Issue
Block a user