diff --git a/erpnext/demo/data/item.json b/erpnext/demo/data/item.json index fe12ce892a..6974b943f6 100644 --- a/erpnext/demo/data/item.json +++ b/erpnext/demo/data/item.json @@ -278,5 +278,16 @@ "item_code": "Autocad", "item_name": "Autocad", "item_group": "All Item Groups" + }, + { + "is_stock_item": 1, + "has_batch_no": 1, + "create_new_batch": 1, + "valuation_rate": 200, + "default_warehouse": "Stores", + "description": "Corrugated Box", + "item_code": "Corrugated Box", + "item_name": "Corrugated Box", + "item_group": "All Item Groups" } ] \ No newline at end of file diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py index c4df777c88..34e9a3e572 100644 --- a/erpnext/demo/setup/setup_data.py +++ b/erpnext/demo/setup/setup_data.py @@ -16,6 +16,7 @@ def setup(domain): setup_user() setup_employee() setup_user_roles() + setup_role_permissions() employees = frappe.get_all('Employee', fields=['name', 'date_of_joining']) @@ -91,7 +92,8 @@ def setup_fiscal_year(): pass # set the last fiscal year (current year) as default - fiscal_year.set_as_default() + if fiscal_year: + fiscal_year.set_as_default() def setup_holiday_list(): """Setup Holiday List for the current year""" @@ -374,6 +376,22 @@ def setup_pos_profile(): pos.insert() +def setup_role_permissions(): + role_permissions = {'Batch': ['Accounts User', 'Item Manager']} + for doctype, roles in role_permissions.items(): + for role in roles: + if not frappe.db.get_value('Custom DocPerm', + {'parent': doctype, 'role': role}): + frappe.get_doc({ + 'doctype': 'Custom DocPerm', + 'role': role, + 'read': 1, + 'write': 1, + 'create': 1, + 'delete': 1, + 'parent': doctype + }).insert(ignore_permissions=True) + def import_json(doctype, submit=False, values=None): frappe.flags.in_import = True data = json.loads(open(frappe.get_app_path('erpnext', 'demo', 'data', diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py index 43668fe369..f5ec4f9b58 100644 --- a/erpnext/demo/user/stock.py +++ b/erpnext/demo/user/stock.py @@ -7,6 +7,7 @@ import frappe, random from frappe.desk import query_report from erpnext.stock.stock_ledger import NegativeStockError from erpnext.stock.doctype.serial_no.serial_no import SerialNoRequiredError, SerialNoQtyError +from erpnext.stock.doctype.batch.batch import UnableToSelectBatchError from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_return from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_return @@ -59,7 +60,7 @@ def make_delivery_note(): try: dn.submit() frappe.db.commit() - except (NegativeStockError, SerialNoRequiredError, SerialNoQtyError): + except (NegativeStockError, SerialNoRequiredError, SerialNoQtyError, UnableToSelectBatchError): frappe.db.rollback() def make_stock_reconciliation():