Merge pull request #5724 from rohitwaghchaure/v7_timesheet_issue
[Fix] Added note field in timesheet and fixes in timesheet patch
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 2440fde..b949dfc 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -250,6 +250,7 @@
timesheet = make_timesheet(self.name)
workstation_list = []
last_workstation_idx = {}
+ timesheet.set('time_logs', [])
for i, d in enumerate(self.operations):
if d.workstation and d.status != 'Completed':
diff --git a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
index 24a5f4e..3f5cca1 100644
--- a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
+++ b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py
@@ -3,16 +3,20 @@
from erpnext.manufacturing.doctype.production_order.production_order import make_timesheet, add_timesheet_detail
def execute():
+ if "note" not in frappe.db.get_table_columns("timesheet"):
+ frappe.reload_doc('projects', 'doctype', 'timesheet')
+
for data in frappe.get_all('Time Log', fields=["*"],
filters = [["docstatus", "<", "2"]]):
time_sheet = make_timesheet(data.production_order)
- args = get_timesheet_data(data)
+ args = get_timelog_data(data)
add_timesheet_detail(time_sheet, args)
time_sheet.docstatus = data.docstatus
+ time_sheet.note = data.note
time_sheet.company = frappe.db.get_single_value('Global Defaults', 'default_company')
time_sheet.save(ignore_permissions=True)
-def get_timesheet_data(data):
+def get_timelog_data(data):
return {
'billable': data.billable,
'from_time': data.from_time,
@@ -24,5 +28,9 @@
'operation': data.operation,
'operation_id': data.operation_id,
'workstation': data.workstation,
- 'completed_qty': data.completed_qty
+ 'completed_qty': data.completed_qty,
+ 'billing_rate': data.billing_rate,
+ 'billing_amount': data.billing_amount,
+ 'costing_rate': data.costing_rate,
+ 'costing_amount': data.costing_amount
}
diff --git a/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py b/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py
index aeb5d2f..0eff8d4 100644
--- a/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py
+++ b/erpnext/patches/v7_0/convert_timelogbatch_to_timesheet.py
@@ -1,8 +1,9 @@
import frappe
from frappe.utils import cint
from erpnext.manufacturing.doctype.production_order.production_order import add_timesheet_detail
+from erpnext.patches.v7_0.convert_timelog_to_timesheet import get_timelog_data
-def execute():
+def execute():
for tlb in frappe.get_all('Time Log Batch', fields=["*"],
filters = [["docstatus", "<", "2"]]):
time_sheet = frappe.new_doc('Timesheet')
@@ -22,16 +23,4 @@
time_log = frappe.get_all('Time Log', fields=["*"],
filters = {'name': data.time_log})[0]
- return {
- 'billable': time_log.billable,
- 'from_time': time_log.from_time,
- 'hours': time_log.hours,
- 'to_time': time_log.to_time,
- 'project': time_log.project,
- 'task': time_log.task,
- 'activity_type': time_log.activity_type,
- 'operation': time_log.operation,
- 'operation_id': time_log.operation_id,
- 'workstation': time_log.workstation,
- 'completed_qty': time_log.completed_qty
- }
\ No newline at end of file
+ return get_timelog_data(time_log)
\ No newline at end of file
diff --git a/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py b/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py
index 3b06fdc..695c552 100644
--- a/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py
+++ b/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py
@@ -1,6 +1,8 @@
import frappe
def execute():
+ frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
+ frappe.reload_doc('accounts', 'doctype', 'sales_invoice_payment')
for time_sheet in frappe.db.sql(""" select sales_invoice, name, total_billing_amount from `tabTimesheet`
where sales_invoice is not null and docstatus < 2""", as_dict=True):
si_doc = frappe.get_doc('Sales Invoice', time_sheet.sales_invoice)
diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json
index 59af587..ac6093e 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.json
+++ b/erpnext/projects/doctype/timesheet/timesheet.json
@@ -10,6 +10,7 @@
"docstatus": 0,
"doctype": "DocType",
"document_type": "Document",
+ "editable_grid": 1,
"fields": [
{
"allow_on_submit": 0,
@@ -553,6 +554,55 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "fieldname": "section_break_18",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "note",
+ "fieldtype": "Text Editor",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Note",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
"fieldname": "amended_from",
"fieldtype": "Link",
"hidden": 0,
@@ -586,7 +636,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-07-06 18:36:21.103681",
+ "modified": "2016-07-13 01:18:57.918882",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet",
@@ -617,5 +667,5 @@
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC",
- "track_seen": 1
+ "track_seen": 0
}
\ No newline at end of file
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index 834e073..24a3796 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -87,8 +87,8 @@
if self.production_order and flt(pending_qty) < flt(data.completed_qty):
frappe.throw(_("Row {0}: Completed Qty cannot be more than {0} for operation {1}").format(data.idx, pending_qty, self.operation),
OverProductionLoggedError)
-
- if data.billable and flt(data.billing_rate) == 0.0:
+
+ if data.billable and flt(data.billing_rate) == 0.0 and data.activity_type:
frappe.throw(_("Row {0}: Billing Rate must be greater than zero.").format(data.idx))
def update_production_order(self, time_sheet):