mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
Merge branch 'version-12-hotfix' into delievered-received-items-to-bill-report-fix
This commit is contained in:
@@ -371,6 +371,11 @@ class TestWorkOrder(unittest.TestCase):
|
|||||||
ste1 = frappe.get_doc(make_stock_entry(wo.name, "Manufacture", 1))
|
ste1 = frappe.get_doc(make_stock_entry(wo.name, "Manufacture", 1))
|
||||||
self.assertEqual(len(ste1.items), 3)
|
self.assertEqual(len(ste1.items), 3)
|
||||||
|
|
||||||
|
def test_cost_center_for_manufacture(self):
|
||||||
|
wo_order = make_wo_order_test_record()
|
||||||
|
ste = make_stock_entry(wo_order.name, "Material Transfer for Manufacture", wo_order.qty)
|
||||||
|
self.assertEquals(ste.get("items")[0].get("cost_center"), "_Test Cost Center - _TC")
|
||||||
|
|
||||||
def test_operation_time_with_batch_size(self):
|
def test_operation_time_with_batch_size(self):
|
||||||
fg_item = "Test Batch Size Item For BOM"
|
fg_item = "Test Batch Size Item For BOM"
|
||||||
rm1 = "Test Batch Size Item RM 1 For BOM"
|
rm1 = "Test Batch Size Item RM 1 For BOM"
|
||||||
|
|||||||
@@ -218,10 +218,9 @@ def get_tax_template(master_doctype, company, is_inter_state, state_code):
|
|||||||
|
|
||||||
for tax_category in tax_categories:
|
for tax_category in tax_categories:
|
||||||
if tax_category.gst_state == number_state_mapping[state_code] or \
|
if tax_category.gst_state == number_state_mapping[state_code] or \
|
||||||
(not default_tax and not tax_category.gst_state):
|
(not default_tax and not tax_category.gst_state):
|
||||||
default_tax = frappe.db.get_value(master_doctype,
|
default_tax = frappe.db.get_value(master_doctype,
|
||||||
{'disabled': 0, 'tax_category': tax_category.name}, 'name')
|
{'company': company, 'disabled': 0, 'tax_category': tax_category.name}, 'name')
|
||||||
|
|
||||||
return default_tax
|
return default_tax
|
||||||
|
|
||||||
def get_tax_template_for_sez(party_details, master_doctype, company, party_type):
|
def get_tax_template_for_sez(party_details, master_doctype, company, party_type):
|
||||||
|
|||||||
@@ -1194,8 +1194,6 @@ class StockEntry(StockController):
|
|||||||
return item_dict
|
return item_dict
|
||||||
|
|
||||||
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
|
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
|
||||||
cost_center = frappe.db.get_value("Company", self.company, 'cost_center')
|
|
||||||
|
|
||||||
for d in item_dict:
|
for d in item_dict:
|
||||||
stock_uom = item_dict[d].get("stock_uom") or frappe.db.get_value("Item", d, "stock_uom")
|
stock_uom = item_dict[d].get("stock_uom") or frappe.db.get_value("Item", d, "stock_uom")
|
||||||
|
|
||||||
@@ -1206,9 +1204,10 @@ class StockEntry(StockController):
|
|||||||
se_child.uom = item_dict[d]["uom"] if item_dict[d].get("uom") else stock_uom
|
se_child.uom = item_dict[d]["uom"] if item_dict[d].get("uom") else stock_uom
|
||||||
se_child.stock_uom = stock_uom
|
se_child.stock_uom = stock_uom
|
||||||
se_child.qty = flt(item_dict[d]["qty"], se_child.precision("qty"))
|
se_child.qty = flt(item_dict[d]["qty"], se_child.precision("qty"))
|
||||||
se_child.cost_center = item_dict[d].get("cost_center") or cost_center
|
|
||||||
se_child.allow_alternative_item = item_dict[d].get("allow_alternative_item", 0)
|
se_child.allow_alternative_item = item_dict[d].get("allow_alternative_item", 0)
|
||||||
se_child.subcontracted_item = item_dict[d].get("main_item_code")
|
se_child.subcontracted_item = item_dict[d].get("main_item_code")
|
||||||
|
se_child.cost_center = (item_dict[d].get("cost_center") or
|
||||||
|
get_default_cost_center(item_dict[d], company = self.company))
|
||||||
|
|
||||||
for field in ["idx", "po_detail", "original_item",
|
for field in ["idx", "po_detail", "original_item",
|
||||||
"expense_account", "description", "item_name"]:
|
"expense_account", "description", "item_name"]:
|
||||||
|
|||||||
@@ -527,23 +527,40 @@ def get_default_deferred_account(args, item, fieldname=None):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_default_cost_center(args, item, item_group, brand, company=None):
|
def get_default_cost_center(args, item=None, item_group=None, brand=None, company=None):
|
||||||
cost_center = None
|
cost_center = None
|
||||||
|
|
||||||
|
if not company and args.get("company"):
|
||||||
|
company = args.get("company")
|
||||||
|
|
||||||
if args.get('project'):
|
if args.get('project'):
|
||||||
cost_center = frappe.db.get_value("Project", args.get("project"), "cost_center", cache=True)
|
cost_center = frappe.db.get_value("Project", args.get("project"), "cost_center", cache=True)
|
||||||
|
|
||||||
if not cost_center:
|
if not cost_center and (item and item_group and brand):
|
||||||
if args.get('customer'):
|
if args.get('customer'):
|
||||||
cost_center = item.get('selling_cost_center') or item_group.get('selling_cost_center') or brand.get('selling_cost_center')
|
cost_center = item.get('selling_cost_center') or item_group.get('selling_cost_center') or brand.get('selling_cost_center')
|
||||||
else:
|
else:
|
||||||
cost_center = item.get('buying_cost_center') or item_group.get('buying_cost_center') or brand.get('buying_cost_center')
|
cost_center = item.get('buying_cost_center') or item_group.get('buying_cost_center') or brand.get('buying_cost_center')
|
||||||
|
|
||||||
cost_center = cost_center or args.get("cost_center")
|
elif not cost_center and args.get("item_code") and company:
|
||||||
|
for method in ["get_item_defaults", "get_item_group_defaults", "get_brand_defaults"]:
|
||||||
|
path = "erpnext.stock.get_item_details.{0}".format(method)
|
||||||
|
data = frappe.get_attr(path)(args.get("item_code"), company)
|
||||||
|
|
||||||
|
if data and (data.selling_cost_center or data.buying_cost_center):
|
||||||
|
return data.selling_cost_center or data.buying_cost_center
|
||||||
|
|
||||||
|
if not cost_center and args.get("cost_center"):
|
||||||
|
cost_center = args.get("cost_center")
|
||||||
|
|
||||||
if (company and cost_center
|
if (company and cost_center
|
||||||
and frappe.get_cached_value("Cost Center", cost_center, "company") != company):
|
and frappe.get_cached_value("Cost Center", cost_center, "company") != company):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if not cost_center and company:
|
||||||
|
cost_center = frappe.get_cached_value("Company",
|
||||||
|
company, "cost_center")
|
||||||
|
|
||||||
return cost_center
|
return cost_center
|
||||||
|
|
||||||
def get_default_supplier(args, item, item_group, brand):
|
def get_default_supplier(args, item, item_group, brand):
|
||||||
|
|||||||
Reference in New Issue
Block a user