Merge pull request #5724 from rohitwaghchaure/v7_timesheet_issue

[Fix] Added note field in timesheet and fixes in timesheet patch
This commit is contained in:
Rushabh Mehta 2016-07-13 10:53:01 +05:30 committed by GitHub
commit c748e9c991
6 changed files with 71 additions and 21 deletions

View File

@ -250,6 +250,7 @@ class ProductionOrder(Document):
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':

View File

@ -3,16 +3,20 @@ import frappe
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 @@ def get_timesheet_data(data):
'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
}

View File

@ -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 @@ def get_timesheet_data(data):
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
}
return get_timelog_data(time_log)

View File

@ -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)

View File

@ -10,6 +10,7 @@
"docstatus": 0,
"doctype": "DocType",
"document_type": "Document",
"editable_grid": 1,
"fields": [
{
"allow_on_submit": 0,
@ -549,6 +550,55 @@
"set_only_once": 0,
"unique": 0
},
{
"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,
@ -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
}

View File

@ -87,8 +87,8 @@ class Timesheet(Document):
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):