Merge pull request #5865 from rohitwaghchaure/v7_fixes_and_cleanup
[mionr] fixes and cleanups
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index cb57ff4..a89f40e 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -69,13 +69,13 @@
var me = this;
// navigator.onLine
this.connection_status = false;
- this.page.set_indicator("Offline", "grey")
+ this.page.set_indicator(__("Offline"), "grey")
frappe.call({
method:"frappe.handler.ping",
callback: function(r){
if(r.message){
me.connection_status = true;
- me.page.set_indicator("Online", "green")
+ me.page.set_indicator(__("Online"), "green")
}
}
})
@@ -278,7 +278,7 @@
"fieldtype": "Data",
"label": "Item",
"fieldname": "pos_item",
- "placeholder": "Search Item"
+ "placeholder": __("Search Item")
},
parent: this.wrapper.find(".search-area"),
only_input: true,
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index 37b13c3..8d30247 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -167,9 +167,7 @@
target_doc.qty = -1* source_doc.qty
if doctype == "Purchase Receipt":
target_doc.received_qty = -1* source_doc.qty
- target_doc.prevdoc_doctype = source_doc.prevdoc_doctype
- target_doc.prevdoc_docname = source_doc.prevdoc_docname
- target_doc.prevdoc_detail_docname = source_doc.prevdoc_detail_docname
+ target_doc.purchase_order = source_doc.purchase_order
elif doctype == "Purchase Invoice":
target_doc.received_qty = -1* source_doc.qty
target_doc.purchase_order = source_doc.purchase_order
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index c1813dc..3e31d5e 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -302,3 +302,4 @@
erpnext.patches.v7_0.migrate_schools_to_erpnext
erpnext.patches.v7_0.remove_administrator_role_in_doctypes
erpnext.patches.v7_0.rename_fee_amount_to_fee_component
+erpnext.patches.v7_0.calculate_total_costing_amount
diff --git a/erpnext/patches/v7_0/calculate_total_costing_amount.py b/erpnext/patches/v7_0/calculate_total_costing_amount.py
new file mode 100644
index 0000000..f426904
--- /dev/null
+++ b/erpnext/patches/v7_0/calculate_total_costing_amount.py
@@ -0,0 +1,14 @@
+import frappe
+from frappe.utils import flt
+
+def execute():
+ frappe.reload_doc('projects', 'doctype', 'timesheet')
+
+ for data in frappe.get_all('Timesheet', fields=["name, total_costing_amount"],
+ filters = [["docstatus", "<", "2"]]):
+ if flt(data.total_costing_amount) == 0.0:
+ ts = frappe.get_doc('Timesheet', data.name)
+ ts.update_cost()
+ ts.calculate_total_amounts()
+ ts.flags.ignore_validate_update_after_submit = True
+ ts.save()
diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js
index f816def..f3dfefa 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.js
+++ b/erpnext/projects/doctype/timesheet/timesheet.js
@@ -5,11 +5,11 @@
frappe.ui.form.on("Timesheet", {
setup: function(frm) {
frm.get_field('time_logs').grid.editable_fields = [
- {fieldname: 'billable', columns: 2},
+ {fieldname: 'billable', columns: 1},
{fieldname: 'activity_type', columns: 2},
- {fieldname: 'from_time', columns: 2},
- {fieldname: 'hours', columns: 2},
- {fieldname: 'to_time', columns: 2},
+ {fieldname: 'from_time', columns: 3},
+ {fieldname: 'hours', columns: 1},
+ {fieldname: 'project', columns: 3}
];
frm.fields_dict.employee.get_query = function() {
@@ -22,7 +22,8 @@
child = locals[cdt][cdn];
return{
filters: {
- 'project': child.project
+ 'project': child.project,
+ 'status': ["!=", "Closed"]
}
}
}
@@ -37,8 +38,7 @@
refresh: function(frm) {
if(frm.doc.docstatus==1) {
- if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0
- && !frm.doc.production_order){
+ if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0){
frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") },
"icon-file-alt");
}
@@ -147,13 +147,16 @@
var tl = frm.doc.time_logs || [];
total_hr = 0;
total_billing_amount = 0;
+ total_costing_amount = 0;
for(var i=0; i<tl.length; i++) {
if (tl[i].hours) {
total_hr += tl[i].hours;
total_billing_amount += tl[i].billing_amount;
+ total_costing_amount += tl[i].costing_amount;
}
}
cur_frm.set_value("total_hours", total_hr);
cur_frm.set_value("total_billing_amount", total_billing_amount);
+ cur_frm.set_value("total_costing_amount", total_costing_amount);
}
\ No newline at end of file
diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json
index a15522b..c035cd3 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.json
+++ b/erpnext/projects/doctype/timesheet/timesheet.json
@@ -157,7 +157,7 @@
"no_copy": 1,
"options": "Draft\nSubmitted\nBilled\nPayslip\nCompleted\nCancelled",
"permlevel": 0,
- "print_hide": 0,
+ "print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
@@ -478,7 +478,7 @@
"bold": 0,
"collapsible": 0,
"default": "0",
- "description": "updated via Time Logs",
+ "description": "",
"fieldname": "total_hours",
"fieldtype": "Float",
"hidden": 0,
@@ -529,7 +529,7 @@
"collapsible": 0,
"default": "0",
"depends_on": "",
- "description": "updated via Time Logs",
+ "description": "",
"fieldname": "total_billing_amount",
"fieldtype": "Float",
"hidden": 0,
@@ -555,6 +555,31 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "fieldname": "total_costing_amount",
+ "fieldtype": "Float",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Total Costing Amount",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
"fieldname": "section_break_18",
"fieldtype": "Section Break",
"hidden": 0,
@@ -637,7 +662,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-07-13 23:44:05.086570",
+ "modified": "2016-07-26 00:01:56.055046",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet",
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index e882346..895ace3 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -20,14 +20,21 @@
class Timesheet(Document):
def validate(self):
self.set_status()
- self.total_hours = 0.0
- self.total_billing_amount = 0.0
self.validate_dates()
self.validate_time_logs()
self.update_cost()
+ self.calculate_total_amounts()
+
+ def calculate_total_amounts(self):
+ self.total_hours = 0.0
+ self.total_billing_amount = 0.0
+ self.total_costing_amount = 0.0
+
for d in self.get("time_logs"):
self.total_hours += flt(d.hours)
- if d.billable: self.total_billing_amount += flt(d.billing_amount)
+ if d.billable:
+ self.total_billing_amount += flt(d.billing_amount)
+ self.total_costing_amount += flt(d.costing_amount)
def set_status(self):
self.status = {
@@ -88,7 +95,7 @@
frappe.throw(_("Row {0}: Completed Qty must be greater than zero.").format(data.idx))
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),
+ frappe.throw(_("Row {0}: Completed Qty cannot be more than {1} for operation {2}").format(data.idx, pending_qty, data.operation),
OverProductionLoggedError)
def update_production_order(self, time_sheet):
@@ -220,7 +227,7 @@
def update_cost(self):
for data in self.time_logs:
- if data.activity_type and not data.billing_amount:
+ if data.activity_type and (not data.billing_amount or not data.costing_amount):
rate = get_activity_cost(self.employee, data.activity_type)
hours = data.hours or 0
if rate:
diff --git a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
index 9413629..7604ded 100644
--- a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
+++ b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
@@ -14,7 +14,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "depends_on": "eval:!parent.production_order",
+ "depends_on": "",
"fieldname": "billable",
"fieldtype": "Check",
"hidden": 0,
@@ -27,7 +27,7 @@
"no_copy": 0,
"permlevel": 0,
"precision": "",
- "print_hide": 0,
+ "print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
@@ -163,7 +163,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "depends_on": "eval:!parent.production_order",
+ "depends_on": "billable",
"fieldname": "section_break_11",
"fieldtype": "Section Break",
"hidden": 0,
@@ -265,7 +265,7 @@
"collapsible": 0,
"default": "0",
"depends_on": "",
- "description": "To display value check Billable",
+ "description": "",
"fieldname": "billing_amount",
"fieldtype": "Currency",
"hidden": 0,
@@ -292,7 +292,7 @@
"bold": 0,
"collapsible": 0,
"default": "0",
- "description": "To display value check Billable",
+ "description": "",
"fieldname": "costing_amount",
"fieldtype": "Currency",
"hidden": 0,
@@ -532,7 +532,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-07-21 09:59:01.622745",
+ "modified": "2016-07-26 00:07:58.267131",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet Detail",