diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json index 4149046ccef..ea9569f9b48 100644 --- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json +++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json @@ -55,6 +55,13 @@ "label": "Time Between Operations (in mins)", "permlevel": 0, "precision": "" + }, + { + "fieldname": "over_production_allowance_percentage", + "fieldtype": "Percent", + "label": "Over Production Allowance Percentage", + "permlevel": 0, + "precision": "" } ], "hide_heading": 0, @@ -65,7 +72,7 @@ "is_submittable": 0, "issingle": 1, "istable": 0, - "modified": "2015-04-21 07:57:40.260862", + "modified": "2015-06-15 05:52:22.986958", "modified_by": "Administrator", "module": "Manufacturing", "name": "Manufacturing Settings", diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index ca5f6d972cc..0274b7ef0b1 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -90,8 +90,9 @@ class ProductionOrder(Document): (self.sales_order, self.production_item))[0][0] # total qty in SO so_qty = flt(so_item_qty) + flt(dnpi_qty) - - if total_qty > so_qty: + + allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings", "over_production_allowance_percentage")) + if total_qty > so_qty + (allowance_percentage/100 * so_qty): frappe.throw(_("Cannot produce more Item {0} than Sales Order quantity {1}").format(self.production_item, so_qty), OverProductionError) diff --git a/erpnext/projects/doctype/activity_cost/activity_cost.json b/erpnext/projects/doctype/activity_cost/activity_cost.json index bdc147e5fb6..fafea58797a 100644 --- a/erpnext/projects/doctype/activity_cost/activity_cost.json +++ b/erpnext/projects/doctype/activity_cost/activity_cost.json @@ -9,41 +9,6 @@ "doctype": "DocType", "document_type": "Master", "fields": [ - { - "allow_on_submit": 0, - "fieldname": "employee", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "in_filter": 0, - "in_list_view": 0, - "label": "Employee", - "no_copy": 0, - "options": "Employee", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0 - }, - { - "fieldname": "employee_name", - "fieldtype": "Data", - "label": "Employee Name", - "options": "", - "permlevel": 0, - "precision": "", - "read_only": 1 - }, - { - "fieldname": "column_break_2", - "fieldtype": "Column Break", - "permlevel": 0, - "precision": "" - }, { "allow_on_submit": 0, "fieldname": "activity_type", @@ -64,6 +29,41 @@ "search_index": 0, "set_only_once": 0 }, + { + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "allow_on_submit": 0, + "fieldname": "employee", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Employee", + "no_copy": 0, + "options": "Employee", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0 + }, + { + "fieldname": "employee_name", + "fieldtype": "Data", + "label": "Employee Name", + "options": "", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, { "fieldname": "section_break_4", "fieldtype": "Section Break", @@ -136,7 +136,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-06-11 06:50:47.999788", + "modified": "2015-06-16 03:12:25.644839", "modified_by": "Administrator", "module": "Projects", "name": "Activity Cost", diff --git a/erpnext/projects/doctype/activity_cost/activity_cost.py b/erpnext/projects/doctype/activity_cost/activity_cost.py index 8cd04f564a6..862a70717ab 100644 --- a/erpnext/projects/doctype/activity_cost/activity_cost.py +++ b/erpnext/projects/doctype/activity_cost/activity_cost.py @@ -15,12 +15,21 @@ class ActivityCost(Document): self.check_unique() def set_title(self): - if not self.employee_name: - self.employee_name = frappe.db.get_value("Employee", self.employee, "employee_name") - self.title = _("{0} for {1}").format(self.employee_name, self.activity_type) - + if self.employee: + if not self.employee_name: + self.employee_name = frappe.db.get_value("Employee", self.employee, "employee_name") + self.title = _("{0} for {1}").format(self.employee_name, self.activity_type) + else: + self.title = self.activity_type + def check_unique(self): - if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""", - (self.employee_name, self.activity_type, self.name)): - frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}") - .format(self.employee, self.activity_type), DuplicationError) + if self.employee: + if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""", + (self.employee_name, self.activity_type, self.name)): + frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}") + .format(self.employee, self.activity_type), DuplicationError) + else: + if frappe.db.sql("""select name from `tabActivity Cost` where ifnull(employee, '')='' and activity_type= %s and name != %s""", + (self.activity_type, self.name)): + frappe.throw(_("Default Activity Cost exists for Activity Type - {0}") + .format(self.activity_type), DuplicationError) diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index aa5647e8e82..841ef28e165 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -272,4 +272,7 @@ def get_events(start, end, filters=None): def get_activity_cost(employee=None, activity_type=None): rate = frappe.db.sql("""select costing_rate, billing_rate from `tabActivity Cost` where employee= %s and activity_type= %s""", (employee, activity_type), as_dict=1) + if not rate: + rate = frappe.db.sql("""select costing_rate, billing_rate from `tabActivity Cost` where ifnull(employee, '')='' + and activity_type= %s""", (activity_type), as_dict=1) return rate[0] if rate else {}