Merge pull request #14078 from manassolanki/pos-fix
[enterprise] minor fixes
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 4789464..4d2e7cc 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -39,7 +39,7 @@
update_multi_mode_option(doc, pos_profile)
default_print_format = pos_profile.get('print_format') or "Point of Sale"
print_template = frappe.db.get_value('Print Format', default_print_format, 'html')
- items_list = get_items_list(pos_profile)
+ items_list = get_items_list(pos_profile, doc.company)
customers = get_customers_list(pos_profile)
return {
@@ -151,25 +151,26 @@
doc.append('taxes', tax)
-def get_items_list(pos_profile):
- cond = "1=1"
- item_groups = []
+def get_items_list(pos_profile, company):
+ cond = ""
+ args_list = [company]
if pos_profile.get('item_groups'):
# Get items based on the item groups defined in the POS profile
for d in pos_profile.get('item_groups'):
- item_groups.extend([d.name for d in get_child_nodes('Item Group', d.item_group)])
- cond = "item_group in (%s)" % (', '.join(['%s'] * len(item_groups)))
+ args_list.extend([d.name for d in get_child_nodes('Item Group', d.item_group)])
+ cond = "and i.item_group in (%s)" % (', '.join(['%s'] * len(args_list)))
return frappe.db.sql("""
select
- name, item_code, item_name, description, item_group, expense_account, has_batch_no,
- has_serial_no, expense_account, selling_cost_center, stock_uom, image,
- default_warehouse, is_stock_item, brand
+ i.name, i.item_code, i.item_name, i.description, i.item_group, i.has_batch_no,
+ i.has_serial_no, i.is_stock_item, i.brand, i.stock_uom, i.image,
+ id.expense_account, id.selling_cost_center, id.default_warehouse
from
- tabItem
+ `tabItem` i, `tabItem Default` id
where
- disabled = 0 and has_variants = 0 and is_sales_item = 1 and {cond}
- """.format(cond=cond), tuple(item_groups), as_dict=1)
+ id.parent = i.name and i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
+ and id.company = %s {cond}
+ """.format(cond=cond), tuple(args_list), as_dict=1)
def get_item_groups(pos_profile):
@@ -531,9 +532,12 @@
item_doc.item_code = item.get('item_code')
item_doc.item_name = item.get('item_name')
item_doc.description = item.get('description')
- item_doc.default_warehouse = item.get('warehouse')
item_doc.stock_uom = item.get('stock_uom')
item_doc.item_group = item.get('item_group')
+ item_doc.append('item_defaults', {
+ "company": doc.get("company"),
+ "default_warehouse": item.get('warehouse')
+ })
item_doc.save(ignore_permissions=True)
frappe.db.commit()
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index a33f867..f53f924 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -681,23 +681,29 @@
def get_children(doctype, parent, company, is_root=False):
from erpnext.accounts.report.financial_statements import sort_accounts
- parent_fieldname = 'parent_' + doctype.lower().replace(' ', '_')
- fields = [
- 'name as value',
- 'is_group as expandable'
- ]
- filters = [['docstatus', '<', 2]]
+ fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
+ doctype = frappe.db.escape(doctype)
+
+ # root
if is_root:
- fields += ['root_type', 'report_type', 'account_currency'] if doctype == 'Account' else []
- filters.append([parent_fieldname, '=', ''])
- filters.append(['company', '=', company])
-
+ fields = ", root_type, report_type, account_currency" if doctype=="Account" else ""
+ acc = frappe.db.sql(""" select
+ name as value, is_group as expandable {fields}
+ from `tab{doctype}`
+ where ifnull(`parent_{fieldname}`,'') = ''
+ and `company` = %s and docstatus<2
+ order by name""".format(fields=fields, fieldname = fieldname, doctype=doctype),
+ company, as_dict=1)
else:
- fields += ['account_currency'] if doctype == 'Account' else []
- fields += [parent_fieldname + ' as parent']
-
-
- acc = frappe.get_list(doctype, fields=fields, filters=filters)
+ # other
+ fields = ", account_currency" if doctype=="Account" else ""
+ acc = frappe.db.sql("""select
+ name as value, is_group as expandable, parent_{fieldname} as parent {fields}
+ from `tab{doctype}`
+ where ifnull(`parent_{fieldname}`,'') = %s
+ and docstatus<2
+ order by name""".format(fields=fields, fieldname=fieldname, doctype=doctype),
+ parent, as_dict=1)
if doctype == 'Account':
sort_accounts(acc, is_root, key="value")
diff --git a/erpnext/agriculture/doctype/land_unit/land_unit.py b/erpnext/agriculture/doctype/land_unit/land_unit.py
index 35bda1c..f577eca 100644
--- a/erpnext/agriculture/doctype/land_unit/land_unit.py
+++ b/erpnext/agriculture/doctype/land_unit/land_unit.py
@@ -169,10 +169,11 @@
if is_root:
parent = ''
- land_units = frappe.get_list(doctype,
- fields = ['name as value', 'is_group as expandable'],
- filters= [['parent_land_unit', '=', parent]],
- order_by='name')
+ land_units = frappe.db.sql("""select name as value,
+ is_group as expandable
+ from `tabLand Unit`
+ where ifnull(`parent_land_unit`,'') = %s
+ order by name""", (parent), as_dict=1)
# return nodes
return land_units
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 5a7573b..846c5b4 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -14,6 +14,7 @@
from erpnext.buying.utils import validate_for_items, check_for_closed_status
from erpnext.stock.utils import get_bin
from six import string_types
+from erpnext.stock.doctype.item.item import get_item_defaults
form_grid_templates = {
"items": "templates/form_grid/item_grid.html"
@@ -374,7 +375,7 @@
target.base_amount = target.amount * flt(source_parent.conversion_rate)
target.qty = target.amount / flt(obj.rate) if (flt(obj.rate) and flt(obj.billed_amt)) else flt(obj.qty)
- item = frappe.db.get_value("Item", target.item_code, ["item_group", "buying_cost_center"], as_dict=1)
+ item = get_item_defaults(target.item_code, target.company)
target.cost_center = frappe.db.get_value("Project", obj.project, "cost_center") \
or item.buying_cost_center \
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index fa2436d..13baf6f 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -216,8 +216,9 @@
raw_materials_cost = 0
items = list(set([d.item_code for d in bom_items]))
- item_wh = frappe._dict(frappe.db.sql("""select item_code, default_warehouse
- from `tabItem` where name in ({0})""".format(", ".join(["%s"] * len(items))), items))
+ item_wh = frappe._dict(frappe.db.sql("""select i.item_code, id.default_warehouse
+ from `tabItem` i, `tabItem Default` id where id.company=%s and i.name in ({0})"""
+ .format(", ".join(["%s"] * len(items))), [self.company] + items))
for bom_item in bom_items:
if self.doctype == "Purchase Order":
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 2a22b32..83e7916 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -340,10 +340,22 @@
def check_active_sales_items(obj):
for d in obj.get("items"):
if d.item_code:
- item = frappe.db.sql("""select docstatus,
- income_account from tabItem where name = %s""",
- d.item_code, as_dict=True)[0]
+ item = frappe.db.sql("""select i.docstatus, id.income_account
+ from `tabItem` i, `tabItem Default` id
+ where i.name=%s and id.parent=i.name and id.company=%s""",
+ (d.item_code,obj.company), as_dict=True)[0]
+ income_account_set = False
if getattr(d, "income_account", None) and not item.income_account:
- frappe.db.set_value("Item", d.item_code, "income_account",
- d.income_account)
+ doc = frappe.get_doc("Item", d.item_code)
+ for default in doc.item_defaults:
+ if default.company == obj.company:
+ default.income_account = d.income_account
+ income_account_set = True
+ break
+ if not income_account_set:
+ doc.append("item_defaults", {
+ "company": obj.company,
+ "income_account": d.income_account
+ })
+ doc.save()
\ No newline at end of file
diff --git a/erpnext/demo/data/item.json b/erpnext/demo/data/item.json
index 6974b94..908de15 100644
--- a/erpnext/demo/data/item.json
+++ b/erpnext/demo/data/item.json
@@ -1,7 +1,9 @@
[
{
"default_supplier": "Asiatic Solutions",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "For Upper Bearing",
"image": "/assets/erpnext_demo/images/disc.png",
"item_code": "Disc Collars",
@@ -10,7 +12,9 @@
},
{
"default_supplier": "Nan Duskin",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "CAST IRON, MCMASTER PART NO. 3710T13",
"image": "/assets/erpnext_demo/images/bearing.jpg",
"item_code": "Bearing Block",
@@ -19,7 +23,9 @@
},
{
"default_supplier": null,
- "default_warehouse": "Finished Goods",
+ "item_defaults": [{
+ "default_warehouse": "Finished Goods"
+ }],
"description": "Wind Mill C Series for Commercial Use 18ft",
"image": "/assets/erpnext_demo/images/wind-turbine-2.png",
"item_code": "Wind MIll C Series",
@@ -28,7 +34,9 @@
},
{
"default_supplier": null,
- "default_warehouse": "Finished Goods",
+ "item_defaults": [{
+ "default_warehouse": "Finished Goods"
+ }],
"description": "Wind Mill A Series for Home Use 9ft",
"image": "/assets/erpnext_demo/images/wind-turbine.png",
"item_code": "Wind Mill A Series",
@@ -37,7 +45,9 @@
},
{
"default_supplier": null,
- "default_warehouse": "Finished Goods",
+ "item_defaults": [{
+ "default_warehouse": "Finished Goods"
+ }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine",
@@ -51,7 +61,9 @@
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "1.5 in. Diameter x 36 in. Mild Steel Tubing",
"image": null,
"item_code": "Bearing Pipe",
@@ -60,7 +72,9 @@
},
{
"default_supplier": "New World Realty",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet",
"image": null,
"item_code": "Wing Sheet",
@@ -69,7 +83,9 @@
},
{
"default_supplier": "Eagle Hardware",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate",
"image": null,
"item_code": "Upper Bearing Plate",
@@ -78,7 +94,9 @@
},
{
"default_supplier": "Asiatic Solutions",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "Bearing Assembly",
"image": null,
"item_code": "Bearing Assembly",
@@ -87,7 +105,9 @@
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null,
"item_code": "Base Plate",
@@ -97,7 +117,9 @@
},
{
"default_supplier": "Scott Ties",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "N/A",
"image": null,
"item_code": "Stand",
@@ -106,7 +128,9 @@
},
{
"default_supplier": "Eagle Hardware",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar",
"image": null,
"item_code": "Bearing Collar",
@@ -115,7 +139,9 @@
},
{
"default_supplier": "Eagle Hardware",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "1/4 in. x 6 in. x 6 in. Mild Steel Plate",
"image": null,
"item_code": "Base Bearing Plate",
@@ -124,7 +150,9 @@
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing",
"image": null,
"item_code": "External Disc",
@@ -133,7 +161,9 @@
},
{
"default_supplier": "Eagle Hardware",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "1.25 in. Diameter x 6 ft. Mild Steel Tubing",
"image": null,
"item_code": "Shaft",
@@ -142,7 +172,9 @@
},
{
"default_supplier": "Ks Merchandise",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "1/2 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null,
"item_code": "Blade Rib",
@@ -151,7 +183,9 @@
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "For Bearing Collar",
"image": null,
"item_code": "Internal Disc",
@@ -160,7 +194,9 @@
},
{
"default_supplier": null,
- "default_warehouse": "Finished Goods",
+ "item_defaults": [{
+ "default_warehouse": "Finished Goods"
+ }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Small</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine-S",
@@ -177,7 +213,9 @@
},
{
"default_supplier": null,
- "default_warehouse": "Finished Goods",
+ "item_defaults": [{
+ "default_warehouse": "Finished Goods"
+ }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Medium</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine-M",
@@ -194,7 +232,9 @@
},
{
"default_supplier": null,
- "default_warehouse": "Finished Goods",
+ "item_defaults": [{
+ "default_warehouse": "Finished Goods"
+ }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Large</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine-L",
@@ -218,7 +258,9 @@
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null,
"item_code": "Base Plate Un Painted",
@@ -284,7 +326,9 @@
"has_batch_no": 1,
"create_new_batch": 1,
"valuation_rate": 200,
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores"
+ }],
"description": "Corrugated Box",
"item_code": "Corrugated Box",
"item_name": "Corrugated Box",
diff --git a/erpnext/demo/data/item_education.json b/erpnext/demo/data/item_education.json
index 077fcaa..40e4701 100644
--- a/erpnext/demo/data/item_education.json
+++ b/erpnext/demo/data/item_education.json
@@ -1,63 +1,90 @@
[
{
"default_supplier": "Asiatic Solutions",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Books",
"item_group": "Raw Material",
"item_name": "Books"
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Pencil",
"item_group": "Raw Material",
"item_name": "Pencil"
},
{
"default_supplier": "New World Realty",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Tables",
"item_group": "Raw Material",
"item_name": "Tables"
},
{
"default_supplier": "Eagle Hardware",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Chair",
"item_group": "Raw Material",
"item_name": "Chair"
},
{
"default_supplier": "Asiatic Solutions",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Black Board",
"item_group": "Sub Assemblies",
"item_name": "Black Board"
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Chalk",
"item_group": "Raw Material",
"item_name": "Chalk"
},
{
"default_supplier": "HomeBase",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Notepad",
"item_group": "Raw Material",
"item_name": "Notepad"
},
{
"default_supplier": "Ks Merchandise",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Uniform",
"item_group": "Raw Material",
"item_name": "Uniform"
},
{
"is_stock_item": 0,
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"description": "Computer",
"item_code": "Computer",
"item_name": "Computer",
@@ -65,7 +92,10 @@
},
{
"is_stock_item": 0,
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"description": "Mobile",
"item_code": "Mobile",
"item_name": "Mobile",
@@ -73,7 +103,10 @@
},
{
"is_stock_item": 0,
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"description": "ERP",
"item_code": "ERP",
"item_name": "ERP",
@@ -81,15 +114,20 @@
},
{
"is_stock_item": 0,
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"description": "Autocad",
"item_code": "Autocad",
"item_name": "Autocad",
"item_group": "All Item Groups"
},
{
- "default_warehouse": "Stores",
- "default_warehouse": "Stores",
+ "item_defaults": [{
+ "default_warehouse": "Stores",
+ "company": "Whitmore College"
+ }],
"item_code": "Service",
"item_group": "Services",
"item_name": "Service",
diff --git a/erpnext/demo/setup/education.py b/erpnext/demo/setup/education.py
index 2a894f7..0403c06 100644
--- a/erpnext/demo/setup/education.py
+++ b/erpnext/demo/setup/education.py
@@ -36,7 +36,8 @@
item = frappe.new_doc('Item')
item.update(i)
item.min_order_qty = random.randint(10, 30)
- item.default_warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.default_warehouse}, limit=1)[0].name
+ item.item_defaults[0].default_warehouse = frappe.get_all('Warehouse',
+ filters={'warehouse_name': item.item_defaults[0].default_warehouse}, limit=1)[0].name
item.insert()
def make_student_applicants():
diff --git a/erpnext/demo/setup/manufacture.py b/erpnext/demo/setup/manufacture.py
index 4d8c450..4db510a 100644
--- a/erpnext/demo/setup/manufacture.py
+++ b/erpnext/demo/setup/manufacture.py
@@ -4,6 +4,7 @@
import frappe
from frappe.utils import nowdate, add_days
from erpnext.demo.setup.setup_data import import_json
+from erpnext.demo.domains import data
from six import iteritems
@@ -65,10 +66,11 @@
for i in items:
item = frappe.new_doc('Item')
item.update(i)
- if item.default_warehouse:
- warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.default_warehouse}, limit=1)
+ if item.item_defaults[0].default_warehouse:
+ item.item_defaults[0].company = data.get("Manufacturing").get('company_name')
+ warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.item_defaults[0].default_warehouse}, limit=1)
if warehouse:
- item.default_warehouse = warehouse[0].name
+ item.item_defaults[0].default_warehouse = warehouse[0].name
item.insert()
def setup_product_bundle():
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index 93f6532..824ddf5 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -318,26 +318,26 @@
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False, is_tree=False):
- filters = [['company', '=', company]]
- fields = ['name as value', 'employee_name as title']
+ condition = ''
if is_root:
- parent = ''
+ parent = ""
if parent and company and parent!=company:
- filters.append(['reports_to', '=', parent])
+ condition = ' and reports_to = "{0}"'.format(frappe.db.escape(parent))
else:
- filters.append(['reports_to', '=', ''])
+ condition = ' and ifnull(reports_to, "")=""'
- employees = frappe.get_list(doctype, fields=fields,
- filters=filters, order_by='name')
+ employee = frappe.db.sql("""
+ select
+ name as value, employee_name as title,
+ exists(select name from `tabEmployee` where reports_to=emp.name) as expandable
+ from
+ `tabEmployee` emp
+ where company='{company}' {condition} order by name"""
+ .format(company=company, condition=condition), as_dict=1)
- for employee in employees:
- is_expandable = frappe.get_all(doctype, filters=[
- ['reports_to', '=', employee.get('value')]
- ])
- employee.expandable = 1 if is_expandable else 0
-
- return employees
+ # return employee
+ return employee
def on_doctype_update():
diff --git a/erpnext/hr/doctype/identification_document_type/__init__.py b/erpnext/hr/doctype/identification_document_type/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/hr/doctype/identification_document_type/__init__.py
diff --git a/erpnext/hr/doctype/identification_document_type/identification_document_type.js b/erpnext/hr/doctype/identification_document_type/identification_document_type.js
new file mode 100644
index 0000000..351cf9d
--- /dev/null
+++ b/erpnext/hr/doctype/identification_document_type/identification_document_type.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Identification Document Type', {
+ refresh: function(frm) {
+
+ }
+});
diff --git a/erpnext/hr/doctype/identification_document_type/identification_document_type.json b/erpnext/hr/doctype/identification_document_type/identification_document_type.json
new file mode 100644
index 0000000..33cbde7
--- /dev/null
+++ b/erpnext/hr/doctype/identification_document_type/identification_document_type.json
@@ -0,0 +1,93 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "field:identification_document_type",
+ "beta": 0,
+ "creation": "2018-05-15 07:13:28.620570",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "identification_document_type",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Identification Document Type",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2018-05-16 04:34:00.448680",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Identification Document Type",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 0,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/identification_document_type/identification_document_type.py b/erpnext/hr/doctype/identification_document_type/identification_document_type.py
new file mode 100644
index 0000000..d9d81d2
--- /dev/null
+++ b/erpnext/hr/doctype/identification_document_type/identification_document_type.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class IdentificationDocumentType(Document):
+ pass
diff --git a/erpnext/hr/doctype/identification_document_type/test_identification_document_type.js b/erpnext/hr/doctype/identification_document_type/test_identification_document_type.js
new file mode 100644
index 0000000..6587909
--- /dev/null
+++ b/erpnext/hr/doctype/identification_document_type/test_identification_document_type.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Identification Document Type", function (assert) {
+ let done = assert.async();
+
+ // number of asserts
+ assert.expect(1);
+
+ frappe.run_serially([
+ // insert a new Identification Document Type
+ () => frappe.tests.make('Identification Document Type', [
+ // values to be set
+ {key: 'value'}
+ ]),
+ () => {
+ assert.equal(cur_frm.doc.key, 'value');
+ },
+ () => done()
+ ]);
+
+});
diff --git a/erpnext/hr/doctype/identification_document_type/test_identification_document_type.py b/erpnext/hr/doctype/identification_document_type/test_identification_document_type.py
new file mode 100644
index 0000000..1265afa
--- /dev/null
+++ b/erpnext/hr/doctype/identification_document_type/test_identification_document_type.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestIdentificationDocumentType(unittest.TestCase):
+ pass
diff --git a/erpnext/hr/doctype/purpose_of_travel/__init__.py b/erpnext/hr/doctype/purpose_of_travel/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/hr/doctype/purpose_of_travel/__init__.py
diff --git a/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.js b/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.js
new file mode 100644
index 0000000..a9424d6
--- /dev/null
+++ b/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Purpose of Travel', {
+ refresh: function(frm) {
+
+ }
+});
diff --git a/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.json b/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.json
new file mode 100644
index 0000000..68d2d6b
--- /dev/null
+++ b/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.json
@@ -0,0 +1,93 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "field:purpose_of_travel",
+ "beta": 0,
+ "creation": "2018-05-15 07:00:30.933908",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "purpose_of_travel",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Purpose of Travel",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2018-05-15 07:05:26.219209",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Purpose of Travel",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 0,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.py b/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.py
new file mode 100644
index 0000000..62f62a5
--- /dev/null
+++ b/erpnext/hr/doctype/purpose_of_travel/purpose_of_travel.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class PurposeofTravel(Document):
+ pass
diff --git a/erpnext/hr/doctype/purpose_of_travel/test_purpose_of_travel.js b/erpnext/hr/doctype/purpose_of_travel/test_purpose_of_travel.js
new file mode 100644
index 0000000..936c21c
--- /dev/null
+++ b/erpnext/hr/doctype/purpose_of_travel/test_purpose_of_travel.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Purpose of Travel", function (assert) {
+ let done = assert.async();
+
+ // number of asserts
+ assert.expect(1);
+
+ frappe.run_serially([
+ // insert a new Purpose of Travel
+ () => frappe.tests.make('Purpose of Travel', [
+ // values to be set
+ {key: 'value'}
+ ]),
+ () => {
+ assert.equal(cur_frm.doc.key, 'value');
+ },
+ () => done()
+ ]);
+
+});
diff --git a/erpnext/hr/doctype/purpose_of_travel/test_purpose_of_travel.py b/erpnext/hr/doctype/purpose_of_travel/test_purpose_of_travel.py
new file mode 100644
index 0000000..ccd950d
--- /dev/null
+++ b/erpnext/hr/doctype/purpose_of_travel/test_purpose_of_travel.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestPurposeofTravel(unittest.TestCase):
+ pass
diff --git a/erpnext/hr/doctype/travel_itinerary/__init__.py b/erpnext/hr/doctype/travel_itinerary/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/hr/doctype/travel_itinerary/__init__.py
diff --git a/erpnext/hr/doctype/travel_itinerary/travel_itinerary.json b/erpnext/hr/doctype/travel_itinerary/travel_itinerary.json
new file mode 100644
index 0000000..f887027
--- /dev/null
+++ b/erpnext/hr/doctype/travel_itinerary/travel_itinerary.json
@@ -0,0 +1,512 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2018-05-15 07:40:59.181192",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "travel_from",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Travel From",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "travel_to",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Travel To",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "mode_of_travel",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Mode of Travel",
+ "length": 0,
+ "no_copy": 0,
+ "options": "\nFlight\nTrain\nTaxi\nRented Car",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "meal_preference",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Meal Preference",
+ "length": 0,
+ "no_copy": 0,
+ "options": "\nVegetarian\nNon-Vegetarian\nGluten Free\nNon Diary",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "travel_advance_required",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Travel Advance Required",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "travel_advance_required",
+ "fieldname": "advance_amount",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Advance Amount",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_6",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "",
+ "fieldname": "departure_date",
+ "fieldtype": "Datetime",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Departure Datetime",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "",
+ "fieldname": "arrival_date",
+ "fieldtype": "Datetime",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Arrival Datetime",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "lodging_required",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Lodging Required",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "lodging_required",
+ "fieldname": "preferred_area_for_lodging",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Preferred Area for Lodging",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "lodging_required",
+ "fieldname": "check_in_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Check-in Date",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "lodging_required",
+ "fieldname": "check_out_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Check-out Date",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "section_break_14",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "other_details",
+ "fieldtype": "Small Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Other Details",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2018-05-15 09:55:20.138108",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Travel Itinerary",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/travel_itinerary/travel_itinerary.py b/erpnext/hr/doctype/travel_itinerary/travel_itinerary.py
new file mode 100644
index 0000000..0b369be
--- /dev/null
+++ b/erpnext/hr/doctype/travel_itinerary/travel_itinerary.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class TravelItinerary(Document):
+ pass
diff --git a/erpnext/hr/doctype/travel_request/__init__.py b/erpnext/hr/doctype/travel_request/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request/__init__.py
diff --git a/erpnext/hr/doctype/travel_request/test_travel_request.js b/erpnext/hr/doctype/travel_request/test_travel_request.js
new file mode 100644
index 0000000..7e64591
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request/test_travel_request.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Travel Request", function (assert) {
+ let done = assert.async();
+
+ // number of asserts
+ assert.expect(1);
+
+ frappe.run_serially([
+ // insert a new Travel Request
+ () => frappe.tests.make('Travel Request', [
+ // values to be set
+ {key: 'value'}
+ ]),
+ () => {
+ assert.equal(cur_frm.doc.key, 'value');
+ },
+ () => done()
+ ]);
+
+});
diff --git a/erpnext/hr/doctype/travel_request/test_travel_request.py b/erpnext/hr/doctype/travel_request/test_travel_request.py
new file mode 100644
index 0000000..dac5517
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request/test_travel_request.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestTravelRequest(unittest.TestCase):
+ pass
diff --git a/erpnext/hr/doctype/travel_request/travel_request.js b/erpnext/hr/doctype/travel_request/travel_request.js
new file mode 100644
index 0000000..9dd48eb
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request/travel_request.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Travel Request', {
+ refresh: function(frm) {
+
+ }
+});
diff --git a/erpnext/hr/doctype/travel_request/travel_request.json b/erpnext/hr/doctype/travel_request/travel_request.json
new file mode 100644
index 0000000..2f22bbc
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request/travel_request.json
@@ -0,0 +1,909 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "TRQ.#####",
+ "beta": 0,
+ "creation": "2018-05-15 06:32:33.950356",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "travel_type",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Travel Type",
+ "length": 0,
+ "no_copy": 0,
+ "options": "\nDomestic\nInternational",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "travel_funding",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Travel Funding",
+ "length": 0,
+ "no_copy": 0,
+ "options": "\nRequire Full Funding\nFully Sponsored\nPartially Sponsored, Require Partial Funding",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "travel_proof",
+ "fieldtype": "Attach",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Copy of Invitation/Announcement",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_2",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "purpose_of_travel",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Purpose of Travel",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Purpose of Travel",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "details_of_sponsor",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Details of Sponsor (Name, Location)",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 1,
+ "columns": 0,
+ "fieldname": "section_break_4",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Description",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "description",
+ "fieldtype": "Small Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Any other details",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 1,
+ "columns": 0,
+ "fieldname": "employee_details",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Employee Details",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "employee",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Employee",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Employee",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "employee_name",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Employee Name",
+ "length": 0,
+ "no_copy": 0,
+ "options": "employee.employee_name",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "cell_number",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Contact Number",
+ "length": 0,
+ "no_copy": 0,
+ "options": "employee.cell_number",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "prefered_email",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Contact Email",
+ "length": 0,
+ "no_copy": 0,
+ "options": "employee.prefered_email",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_7",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "date_of_birth",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Date of Birth",
+ "length": 0,
+ "no_copy": 0,
+ "options": "employee.date_of_birth",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "personal_id_type",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Identification Document Type",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Identification Document Type",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "personal_id_number",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Identification Document Number",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "passport_number",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Passport Number",
+ "length": 0,
+ "no_copy": 0,
+ "options": "employee.passport_number",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "travel_itinerary",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Travel Itinerary",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "itinerary",
+ "fieldtype": "Table",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "options": "Travel Itinerary",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "costing_details",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Costing Details",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "cost_center",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Cost Center",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Cost Center",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "costings",
+ "fieldtype": "Table",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Costing",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Travel Request Costing",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 1,
+ "columns": 0,
+ "fieldname": "event_details",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Event Details",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "name_of_organizer",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Name of Organizer",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "address_of_organizer",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Address of Organizer",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "other_details",
+ "fieldtype": "Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Other Details",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2018-05-16 04:35:56.819570",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Travel Request",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/travel_request/travel_request.py b/erpnext/hr/doctype/travel_request/travel_request.py
new file mode 100644
index 0000000..01d3f34
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request/travel_request.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class TravelRequest(Document):
+ pass
diff --git a/erpnext/hr/doctype/travel_request_costing/__init__.py b/erpnext/hr/doctype/travel_request_costing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request_costing/__init__.py
diff --git a/erpnext/hr/doctype/travel_request_costing/travel_request_costing.json b/erpnext/hr/doctype/travel_request_costing/travel_request_costing.json
new file mode 100644
index 0000000..b64b1a9
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request_costing/travel_request_costing.json
@@ -0,0 +1,257 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2018-05-15 10:28:37.429581",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "expense_type",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Expense Type",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Expense Claim Type",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_2",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "sponsored_amount",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Sponsored Amount",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "funded_amount",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Funded Amount",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "total_amount",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Total Amount",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "section_break_4",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "comments",
+ "fieldtype": "Small Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Comments",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2018-05-15 10:42:07.960530",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Travel Request Costing",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/travel_request_costing/travel_request_costing.py b/erpnext/hr/doctype/travel_request_costing/travel_request_costing.py
new file mode 100644
index 0000000..9fa85e8
--- /dev/null
+++ b/erpnext/hr/doctype/travel_request_costing/travel_request_costing.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class TravelRequestCosting(Document):
+ pass
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 559bbdf..bbf8f71 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -544,14 +544,16 @@
item.image,
item.stock_uom,
item.allow_alternative_item,
- item.default_warehouse,
- item.expense_account as expense_account,
- item.buying_cost_center as cost_center
+ item_default.default_warehouse,
+ item_default.expense_account as expense_account,
+ item_default.buying_cost_center as cost_center
{select_columns}
from
- `tab{table}` bom_item, `tabBOM` bom, `tabItem` item
+ `tab{table}` bom_item, `tabBOM` bom, `tabItem` item, `tabItem Default` item_default
where
bom_item.docstatus < 2
+ and item_default.parent = item.name
+ and item_default.company = %(company)s
and bom.name = %(bom)s
and bom_item.parent = bom.name
and item.name = bom_item.item_code
@@ -564,14 +566,14 @@
query = query.format(table="BOM Explosion Item",
where_conditions="",
select_columns = ", bom_item.source_warehouse, (Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s ) as idx")
- items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom }, as_dict=True)
+ items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom, "company": company }, as_dict=True)
elif fetch_scrap_items:
query = query.format(table="BOM Scrap Item", where_conditions="", select_columns=", bom_item.idx")
- items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True)
+ items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
else:
query = query.format(table="BOM Item", where_conditions="",
select_columns = ", bom_item.source_warehouse, bom_item.idx")
- items = frappe.db.sql(query, { "qty": qty, "bom": bom }, as_dict=True)
+ items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
for item in items:
if item.item_code in item_dict:
@@ -624,28 +626,18 @@
return
if frappe.form_dict.parent:
- bom_items = frappe.get_list('BOM Item',
- fields=['item_code', 'bom_no as value', 'stock_qty'],
- filters=[['parent', '=', frappe.form_dict.parent]],
- order_by='idx')
-
- item_names = tuple(d.get('item_code') for d in bom_items)
-
- items = frappe.get_list('Item',
- fields=['image', 'description', 'name'],
- filters=[['name', 'in', item_names]]) # to get only required item dicts
-
- for bom_item in bom_items:
- # extend bom_item dict with respective item dict
- bom_item.update(
- # returns an item dict from items list which matches with item_code
- (item for item in items if item.get('name')
- == bom_item.get('item_code')).next()
- )
- bom_item.expandable = 0 if bom_item.value in ('', None) else 1
-
- return bom_items
-
+ return frappe.db.sql("""select
+ bom_item.item_code,
+ bom_item.bom_no as value,
+ bom_item.stock_qty,
+ if(ifnull(bom_item.bom_no, "")!="", 1, 0) as expandable,
+ item.image,
+ item.description
+ from `tabBOM Item` bom_item, tabItem item
+ where bom_item.parent=%s
+ and bom_item.item_code = item.name
+ order by bom_item.idx
+ """, frappe.form_dict.parent, as_dict=True)
def get_boms_in_bottom_up_order(bom_no=None):
def _get_parent(bom_no):
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index ee64a16..006e542 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -293,14 +293,15 @@
for d in frappe.db.sql("""select bei.item_code, item.default_bom as bom,
ifnull(sum(bei.stock_qty/ifnull(bom.quantity, 1)), 0) as qty, item.item_name,
bei.description, bei.stock_uom, item.min_order_qty, bei.source_warehouse,
- item.default_material_request_type, item.min_order_qty, item.default_warehouse
+ item.default_material_request_type, item.min_order_qty, item_default.default_warehouse
from
- `tabBOM Explosion Item` bei, `tabBOM` bom, `tabItem` item
+ `tabBOM Explosion Item` bei, `tabBOM` bom, `tabItem` item, `tabItem Default` item_default
where
- bom.name = bei.parent and item.name = bei.item_code
- and bei.docstatus < 2 and bom.name=%s and item.is_stock_item in (1, {0})
+ bom.name = bei.parent and item.name = bei.item_code and bei.docstatus < 2
+ and item_default.parent = item.name and item_default.company=%s
+ and bom.name=%s and item.is_stock_item in (1, {0})
group by bei.item_code, bei.stock_uom""".format(self.include_non_stock_items),
- data.bom_no, as_dict=1):
+ (self.company, data.bom_no), as_dict=1):
bom_wise_item_details.setdefault(d.item_code, d)
else:
bom_wise_item_details = self.get_subitems(data, bom_wise_item_details, data.bom_no, 1)
@@ -317,16 +318,18 @@
item.is_sub_contracted_item as is_sub_contracted, bom_item.source_warehouse,
item.default_bom as default_bom, bom_item.description as description,
bom_item.stock_uom as stock_uom, item.min_order_qty as min_order_qty,
- item.default_warehouse
+ item_default.default_warehouse
FROM
- `tabBOM Item` bom_item, `tabBOM` bom, tabItem item
+ `tabBOM Item` bom_item, `tabBOM` bom, tabItem item, `tabItem Default` item_default
where
bom.name = bom_item.parent and bom.name = %(bom)s
and bom_item.docstatus < 2 and bom_item.item_code = item.name
+ and item.name = item_default.parent and item_default.company = %(company)s
and item.is_stock_item in (1, {0})
group by bom_item.item_code""".format(self.include_non_stock_items),{
'bom': bom_no,
- 'parent_qty': parent_qty
+ 'parent_qty': parent_qty,
+ 'company': self.company
}, as_dict=1)
for d in items:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index f1d3677..97c6dd6 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -541,3 +541,4 @@
erpnext.patches.v11_0.make_asset_finance_book_against_old_entries
erpnext.patches.v11_0.check_buying_selling_in_currency_exchange
erpnext.patches.v11_0.refactor_erpnext_shopify
+erpnext.patches.v11_0.move_item_defaults_to_child_table_for_multicompany
diff --git a/erpnext/patches/v11_0/move_item_defaults_to_child_table_for_multicompany.py b/erpnext/patches/v11_0/move_item_defaults_to_child_table_for_multicompany.py
new file mode 100644
index 0000000..8e17ea6
--- /dev/null
+++ b/erpnext/patches/v11_0/move_item_defaults_to_child_table_for_multicompany.py
@@ -0,0 +1,59 @@
+# Copyright (c) 2018, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ '''
+
+ Fields to move from the item to item defaults child table
+ [ default_warehouse, buying_cost_center, expense_account, selling_cost_center, income_account ]
+
+ '''
+
+ frappe.reload_doc('stock', 'doctype', 'item_default')
+ frappe.reload_doc('stock', 'doctype', 'item')
+
+ companies = frappe.get_all("Company")
+ if len(companies) == 1:
+ frappe.db.sql('''
+ INSERT INTO `tabItem Default`
+ (name, parent, parenttype, parentfield, idx, company, default_warehouse,
+ buying_cost_center, selling_cost_center, expense_account, income_account, default_supplier)
+ SELECT
+ SUBSTRING(SHA2(name,224), 1, 10) as name, name as parent, 'Item' as parenttype,
+ 'item_defaults' as parentfield, 1 as idx, %s as company, default_warehouse,
+ buying_cost_center, selling_cost_center, expense_account, income_account, default_supplier
+ FROM `tabItem`;
+ ''', companies[0].name)
+ else:
+ item_details = frappe.get_all("Item", fields=["name", "default_warehouse", "buying_cost_center",
+ "expense_account", "selling_cost_center", "income_account"], limit=100)
+
+ for item in item_details:
+ item_defaults = []
+
+ def insert_into_item_defaults(doc_field_name, doc_field_value, company):
+ for d in item_defaults:
+ if d.get("company") == company:
+ d[doc_field_name] = doc_field_value
+ return
+ item_defaults.append({
+ "company": company,
+ doc_field_name: doc_field_value
+ })
+
+ for d in [
+ ["default_warehouse", "Warehouse"], ["expense_account", "Account"], ["expense_account", "Account"],
+ ["buying_cost_center", "Cost Center"], ["selling_cost_center", "Cost Center"]
+ ]:
+ if item.get(d[0]):
+ company = frappe.get_value(d[1], item.get(d[0]), "company", cache=True)
+ insert_into_item_defaults(d[0], item.get(d[0]), company)
+
+ doc = frappe.get_doc("Item", item.name)
+ doc.extend("item_defaults", item_defaults)
+
+ for child_doc in doc.item_defaults:
+ child_doc.db_insert()
\ No newline at end of file
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index c86e699..fcaa344 100644
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -186,25 +186,27 @@
@frappe.whitelist()
def get_children(doctype, parent, task=None, project=None, is_root=False):
-
- filters = [['docstatus', '<', '2']]
+ conditions = ''
if task:
- filters.append(['parent_task', '=', task])
+ # via filters
+ conditions += ' and parent_task = "{0}"'.format(frappe.db.escape(task))
elif parent and not is_root:
# via expand child
- filters.append(['parent_task', '=', parent])
+ conditions += ' and parent_task = "{0}"'.format(frappe.db.escape(parent))
else:
- filters.append(['parent_task', '=', ''])
+ conditions += ' and ifnull(parent_task, "")=""'
if project:
- filters.append(['project', '=', project])
+ conditions += ' and project = "{0}"'.format(frappe.db.escape(project))
- tasks = frappe.get_list(doctype, fields=[
- 'name as value',
- 'subject as title',
- 'is_group as expandable'
- ], filters=filters, order_by='name')
+ tasks = frappe.db.sql("""select name as value,
+ subject as title,
+ is_group as expandable
+ from `tabTask`
+ where docstatus < 2
+ {conditions}
+ order by name""".format(conditions=conditions), as_dict=1)
# return tasks
return tasks
diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py
index ced5ebf..3b36a2d 100644
--- a/erpnext/selling/doctype/quotation/test_quotation.py
+++ b/erpnext/selling/doctype/quotation/test_quotation.py
@@ -150,12 +150,10 @@
from erpnext.stock.doctype.item.test_item import make_item
first_item = make_item("_Test Laptop",
- {"is_stock_item": 1, "expense_account": "_Test Account Cost for Goods Sold - _TC",
- "cost_center": "_Test Cost Center - _TC"})
+ {"is_stock_item": 1})
second_item = make_item("_Test CPU",
- {"is_stock_item": 1, "expense_account": "_Test Account Cost for Goods Sold - _TC",
- "cost_center": "_Test Cost Center - _TC"})
+ {"is_stock_item": 1})
qo_item1 = [
{
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 7e6c3dc..5116725 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -15,6 +15,8 @@
from erpnext.controllers.selling_controller import SellingController
from frappe.desk.doctype.auto_repeat.auto_repeat import get_next_schedule_date
from erpnext.selling.doctype.customer.customer import check_credit_limit
+from erpnext.stock.doctype.item.item import get_item_defaults
+
form_grid_templates = {
"items": "templates/form_grid/item_grid.html"
@@ -493,7 +495,7 @@
target.amount = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.rate)
target.qty = flt(source.qty) - flt(source.delivered_qty)
- item = frappe.db.get_value("Item", target.item_code, ["item_group", "selling_cost_center"], as_dict=1)
+ item = get_item_defaults(target.item_code, target.company)
if item:
target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center") \
@@ -557,7 +559,7 @@
if source_parent.project:
target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center")
if not target.cost_center and target.item_code:
- item = frappe.db.get_value("Item", target.item_code, ["item_group", "selling_cost_center"], as_dict=1)
+ item = get_item_defaults(target.item_code, target.company)
target.cost_center = item.selling_cost_center \
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index c5f7ef2..8388941 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -359,14 +359,9 @@
make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
- po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1,
- 'default_supplier': '_Test Supplier',
- "expense_account": "_Test Account Cost for Goods Sold - _TC",
- "cost_center": "_Test Cost Center - _TC"
- })
+ po_item = make_item("_Test Item for Drop Shipping", {"is_stock_item": 1, "delivered_by_supplier": 1})
- dn_item = make_item("_Test Regular Item", {"is_stock_item": 1, "expense_account": "_Test Account Cost for Goods Sold - _TC",
- "cost_center": "_Test Cost Center - _TC"})
+ dn_item = make_item("_Test Regular Item", {"is_stock_item": 1})
so_items = [
{
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index a2feddc..9e9ac55 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -291,9 +291,6 @@
Trash accounts and cost centers for this company if no gl entry exists
"""
self.update_nsm_model()
- accounts = frappe.db.sql_list("select name from tabAccount where company=%s", self.name)
- cost_centers = frappe.db.sql_list("select name from `tabCost Center` where company=%s", self.name)
- warehouses = frappe.db.sql_list("select name from tabWarehouse where company=%s", self.name)
rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name)
if not rec:
@@ -308,33 +305,19 @@
frappe.db.sql("""delete from `tabWarehouse` where company=%s""", self.name)
frappe.defaults.clear_default("company", value=self.name)
- frappe.db.sql("delete from `tabMode of Payment Account` where company=%s", self.name)
+ for doctype in ["Mode of Payment Account", "Item Default"]:
+ frappe.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name)
# clear default accounts, warehouses from item
+ warehouses = frappe.db.sql_list("select name from tabWarehouse where company=%s", self.name)
if warehouses:
- for f in ["default_warehouse", "website_warehouse"]:
- frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
- % (f, f, ', '.join(['%s']*len(warehouses))), tuple(warehouses))
-
frappe.db.sql("""delete from `tabItem Reorder` where warehouse in (%s)"""
% ', '.join(['%s']*len(warehouses)), tuple(warehouses))
- if accounts:
- for f in ["income_account", "expense_account"]:
- frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
- % (f, f, ', '.join(['%s']*len(accounts))), tuple(accounts))
-
- if cost_centers:
- for f in ["selling_cost_center", "buying_cost_center"]:
- frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
- % (f, f, ', '.join(['%s']*len(cost_centers))), tuple(cost_centers))
-
# reset default company
frappe.db.sql("""update `tabSingles` set value=""
where doctype='Global Defaults' and field='default_company'
and value=%s""", self.name)
- # delete mode of payment account
- frappe.db.sql("delete from `tabMode of Payment Account` where company=%s", self.name)
# delete BOMs
boms = frappe.db.sql_list("select name from tabBOM where company=%s", self.name)
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 5013e23..ce1bdc3 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -1614,6 +1614,69 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 1,
+ "columns": 0,
+ "fieldname": "defaults",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Defaults",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "item_defaults",
+ "fieldtype": "Table",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Item Defaults",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Item Default",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 945bde3..9487963 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -81,7 +81,8 @@
def after_insert(self):
'''set opening stock and item price'''
if self.standard_rate:
- self.add_price()
+ for default in self.item_defaults:
+ self.add_price(default.default_price_list)
if self.opening_stock:
self.set_opening_stock()
@@ -166,15 +167,16 @@
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
# default warehouse, or Stores
- default_warehouse = (self.default_warehouse
- or frappe.db.get_single_value('Stock Settings', 'default_warehouse')
- or frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')}))
+ for default in self.item_defaults:
+ default_warehouse = (default.default_warehouse
+ or frappe.db.get_single_value('Stock Settings', 'default_warehouse')
+ or frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')}))
- if default_warehouse:
- stock_entry = make_stock_entry(item_code=self.name, target=default_warehouse,
- qty=self.opening_stock, rate=self.valuation_rate)
+ if default_warehouse:
+ stock_entry = make_stock_entry(item_code=self.name, target=default_warehouse, qty=self.opening_stock,
+ rate=self.valuation_rate, company=default.company)
- stock_entry.add_comment("Comment", _("Opening Stock"))
+ stock_entry.add_comment("Comment", _("Opening Stock"))
def make_route(self):
if not self.route:
@@ -880,3 +882,14 @@
if not matched:
frappe.throw(
_("Default Unit of Measure for Item {0} cannot be changed directly because you have already made some transaction(s) with another UOM. You will need to create a new Item to use a different Default UOM.").format(item))
+
+def get_item_defaults(item, company):
+ return frappe.db.sql('''
+ select
+ i.item_name, i.description, i.stock_uom, i.name, i.is_stock_item, i.item_code, i.item_group,
+ id.expense_account, id.buying_cost_center, id.default_warehouse, id.selling_cost_center
+ from
+ `tabItem` i, `tabItem Default` id
+ where
+ i.name = id.parent and i.name = %s and id.company = %s
+ ''', (item, company), as_dict=1)[0]
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index 3f0d7fa..1c915ee 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -35,8 +35,9 @@
item.update(properties)
- if item.is_stock_item and not item.default_warehouse:
- item.default_warehouse = "_Test Warehouse - _TC"
+ if item.is_stock_item:
+ for item_default in [doc for doc in item.item_defaults if not doc.default_warehouse]:
+ item_default.default_warehouse = "_Test Warehouse - _TC"
item.insert()
@@ -199,7 +200,12 @@
"increment": 0.5
}
],
- "default_warehouse": "_Test Warehouse - _TC",
+ "item_defaults": [
+ {
+ "default_warehouse": "_Test Warehouse - _TC",
+ "company": "_Test Company"
+ }
+ ],
"has_variants": 1
})
@@ -305,5 +311,8 @@
item.item_group = "All Item Groups"
item.is_stock_item = is_stock_item or 1
item.valuation_rate = valuation_rate or 0.0
- item.default_warehouse = warehouse or '_Test Warehouse - _TC'
+ item.append("item_defaults", {
+ "default_warehouse": warehouse or '_Test Warehouse - _TC',
+ "company": "_Test Company"
+ })
item.save()
diff --git a/erpnext/stock/doctype/item_default/__init__.py b/erpnext/stock/doctype/item_default/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/stock/doctype/item_default/__init__.py
diff --git a/erpnext/stock/doctype/item_default/item_default.json b/erpnext/stock/doctype/item_default/item_default.json
new file mode 100644
index 0000000..72d7880
--- /dev/null
+++ b/erpnext/stock/doctype/item_default/item_default.json
@@ -0,0 +1,449 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2018-05-03 02:29:24.444341",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Company",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Company",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "default_warehouse",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Default Warehouse",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Warehouse",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_3",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "default_price_list",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Default Price List",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Price List",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "purchase_defaults",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Purchase Defaults",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "buying_cost_center",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default Buying Cost Center",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Cost Center",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "default_supplier",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default Supplier",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Supplier",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_8",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "expense_account",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default Expense Account",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Account",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "selling_defaults",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Sales Defaults",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "selling_cost_center",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default Selling Cost Center",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Cost Center",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_12",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "income_account",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default Income Account",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Account",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2018-05-03 02:44:24.097373",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Item Default",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_default/item_default.py b/erpnext/stock/doctype/item_default/item_default.py
new file mode 100644
index 0000000..935f0ff
--- /dev/null
+++ b/erpnext/stock/doctype/item_default/item_default.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+
+class ItemDefault(Document):
+ pass
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index 74dfa05..7ca5ead 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -18,9 +18,10 @@
from `tabProduct Bundle Item` t1, `tabProduct Bundle` t2
where t2.new_item_code=%s and t1.parent = t2.name order by t1.idx""", item_code, as_dict=1)
-def get_packing_item_details(item):
- return frappe.db.sql("""select item_name, description, stock_uom, default_warehouse from `tabItem`
- where name = %s""", item, as_dict = 1)[0]
+def get_packing_item_details(item, company):
+ return frappe.db.sql("""select i.item_name, i.description, i.stock_uom, id.default_warehouse
+ from `tabItem` i, `tabItem Default` id where id.parent=i.name and i.name = %s and id.company""",
+ (item, company), as_dict = 1)[0]
def get_bin_qty(item, warehouse):
det = frappe.db.sql("""select actual_qty, projected_qty from `tabBin`
@@ -28,12 +29,13 @@
return det and det[0] or frappe._dict()
def update_packing_list_item(doc, packing_item_code, qty, main_item_row, description):
- item = get_packing_item_details(packing_item_code)
+ item = get_packing_item_details(packing_item_code, doc.company)
# check if exists
exists = 0
for d in doc.get("packed_items"):
- if d.parent_item == main_item_row.item_code and d.item_code == packing_item_code and d.parent_detail_docname == main_item_row.name and d.description == description:
+ if d.parent_item == main_item_row.item_code and d.item_code == packing_item_code and\
+ d.parent_detail_docname == main_item_row.name and d.description == description:
pi, exists = d, 1
break
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 233138f..5a6384a 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -10,6 +10,7 @@
from erpnext.stock.stock_ledger import get_previous_sle, NegativeStockError, get_valuation_rate
from erpnext.stock.get_item_details import get_bin_details, get_default_cost_center, get_conversion_factor
from erpnext.stock.doctype.batch.batch import get_batch_no, set_batch_nos, get_batch_qty
+from erpnext.stock.doctype.item.item import get_item_defaults
from erpnext.manufacturing.doctype.bom.bom import validate_bom_no
from erpnext.stock.utils import get_bin
import json
@@ -562,14 +563,14 @@
pro_doc.run_method("update_planned_qty")
def get_item_details(self, args=None, for_update=False):
- item = frappe.db.sql("""select stock_uom, description, image, item_name,
- expense_account, buying_cost_center, item_group, has_serial_no,
- has_batch_no, sample_quantity
- from `tabItem`
- where name = %s
- and disabled=0
- and (end_of_life is null or end_of_life='0000-00-00' or end_of_life > %s)""",
- (args.get('item_code'), nowdate()), as_dict = 1)
+ item = frappe.db.sql("""select i.stock_uom, i.description, i.image, i.item_name, i.item_group,
+ i.has_batch_no, i.sample_quantity, i.has_serial_no,
+ id.expense_account, id.buying_cost_center
+ from `tabItem`, `tabItem Default` id
+ where i.name=%s and i.name=id.parent and id.company=%s
+ and i.disabled=0
+ and (i.end_of_life is null or i.end_of_life='0000-00-00' or i.end_of_life > %s)""",
+ (args.get('item_code'), self.company, nowdate()), as_dict = 1)
if not item:
frappe.throw(_("Item {0} is not active or end of life has been reached").format(args.get("item_code")))
@@ -716,8 +717,7 @@
item_code = frappe.db.get_value("BOM", self.bom_no, "item")
to_warehouse = self.to_warehouse
- item = frappe.db.get_value("Item", item_code, ["item_name",
- "description", "stock_uom", "expense_account", "buying_cost_center", "name", "default_warehouse"], as_dict=1)
+ item = get_item_defaults(item_code, self.company)
if not self.work_order and not to_warehouse:
# in case of BOM
@@ -782,8 +782,8 @@
for item in wo_items:
qty = item.required_qty
- item_account_details = frappe.db.get_value("Item", item.item_code, ["item_name",
- "description", "stock_uom", "expense_account", "buying_cost_center", "name", "default_warehouse"], as_dict=1)
+
+ item_account_details = get_item_defaults(item.item_code, self.company)
# Take into account consumption if there are any.
if self.purpose == 'Manufacture':
req_qty_each = flt(item.required_qty / wo.qty)
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
index 8bf2610..8647d0f 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry_utils.py
@@ -12,6 +12,7 @@
:item_code: Item to be moved
:qty: Qty to be moved
+ :company: Company Name (optional)
:from_warehouse: Optional
:to_warehouse: Optional
:rate: Optional
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 3342768..ce32e01 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -49,7 +49,8 @@
args: {
warehouse: data.warehouse,
posting_date: frm.doc.posting_date,
- posting_time: frm.doc.posting_time
+ posting_time: frm.doc.posting_time,
+ company:frm.doc.company
},
callback: function(r) {
var items = [];
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 938173d..e434233 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -268,12 +268,12 @@
self._cancel()
@frappe.whitelist()
-def get_items(warehouse, posting_date, posting_time):
+def get_items(warehouse, posting_date, posting_time, company):
items = frappe.get_list("Bin", fields=["item_code"], filters={"warehouse": warehouse}, as_list=1)
- items += frappe.get_list("Item", fields=["name"], filters= {"is_stock_item": 1, "has_serial_no": 0,
- "has_batch_no": 0, "has_variants": 0, "disabled": 0, "default_warehouse": warehouse},
- as_list=1)
+ items += frappe.db.sql_list('''select i.name from `tabItem` i, `tabItem Default` id where i.name = id.parent
+ and i.is_stock_item=1 and i.has_serial_no=0 and i.has_batch_no=0 and i.has_variants=0 and i.disabled=0
+ and id.default_warehouse=%s and id.company=%s''', (warehouse, company))
res = []
for item in set(items):
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index b90ee32..9c47f98 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -144,19 +144,17 @@
if is_root:
parent = ""
- fields = ['name as value', 'is_group as expandable']
- filters = [
- ['docstatus', '<', '2'],
- ['parent_warehouse', '=', parent],
- ['company', 'in', (company, None,'')]
- ]
-
- warehouses = frappe.get_list(doctype, fields=fields, filters=filters, order_by='name')
+ warehouses = frappe.db.sql("""select name as value,
+ is_group as expandable
+ from `tabWarehouse`
+ where docstatus < 2
+ and ifnull(`parent_warehouse`,'') = %s
+ and (`company` = %s or company is null or company = '')
+ order by name""", (parent, company), as_dict=1)
# return warehouses
for wh in warehouses:
wh["balance"] = get_stock_value_on(warehouse=wh.value)
-
return warehouses
@frappe.whitelist()
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index b336565..fd145d2 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -11,6 +11,8 @@
from frappe.model.meta import get_field_precision
from erpnext.stock.doctype.batch.batch import get_batch_no
from erpnext import get_company_currency
+from erpnext.stock.doctype.item.item import get_item_defaults
+
from six import string_types, iteritems
@@ -52,7 +54,7 @@
for bundle_item in bundled_items.items:
valuation_rate += \
- flt(get_valuation_rate(bundle_item.item_code, out.get("warehouse")).get("valuation_rate") \
+ flt(get_valuation_rate(bundle_item.item_code, args.company, out.get("warehouse")).get("valuation_rate") \
* bundle_item.qty)
out.update({
@@ -60,7 +62,7 @@
})
else:
- out.update(get_valuation_rate(args.item_code, out.get("warehouse")))
+ out.update(get_valuation_rate(args.item_code, args.company, out.get("warehouse")))
get_price_list_rate(args, item_doc, out)
@@ -204,7 +206,8 @@
user_default_warehouse = user_default_warehouse_list[0] \
if len(user_default_warehouse_list) == 1 else ""
- warehouse = user_default_warehouse or item.default_warehouse or args.warehouse
+ item_defaults = get_item_defaults(item.name, args.company)
+ warehouse = user_default_warehouse or item_defaults.default_warehouse or args.warehouse
material_request_type = ''
if args.get('doctype') == "Material Request":
@@ -227,9 +230,9 @@
"description": cstr(item.description).strip(),
"image": cstr(item.image).strip(),
"warehouse": warehouse,
- "income_account": get_default_income_account(args, item),
- "expense_account": get_default_expense_account(args, item),
- "cost_center": get_default_cost_center(args, item),
+ "income_account": get_default_income_account(args, item_defaults),
+ "expense_account": get_default_expense_account(args, item_defaults),
+ "cost_center": get_default_cost_center(args, item_defaults),
'has_serial_no': item.has_serial_no,
'has_batch_no': item.has_batch_no,
"batch_no": None,
@@ -677,8 +680,9 @@
if bom:
return bom
-def get_valuation_rate(item_code, warehouse=None):
- item = frappe.get_doc("Item", item_code)
+def get_valuation_rate(item_code, company, warehouse=None):
+ item = get_item_defaults(item_code, company)
+ # item = frappe.get_doc("Item", item_code)
if item.is_stock_item:
if not warehouse:
warehouse = item.default_warehouse
diff --git a/erpnext/utilities/user_progress_utils.py b/erpnext/utilities/user_progress_utils.py
index 20e533e..0377a0a 100644
--- a/erpnext/utilities/user_progress_utils.py
+++ b/erpnext/utilities/user_progress_utils.py
@@ -110,7 +110,10 @@
"is_stock_item": 1,
"item_group": _("Products"),
"stock_uom": _(args.get("item_uom_" + str(i))),
- "default_warehouse": default_warehouse
+ "item_defaults": [{
+ "default_warehouse": default_warehouse,
+ "company": defaults.get("company_name")
+ }]
}).insert()
except frappe.NameError: