[fix] posting date, time is always current unless explicitly set
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 1564b48..ddff5d7 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -8,6 +8,10 @@
frappe.provide("erpnext.accounts");
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
+ setup: function(doc) {
+ this.setup_posting_date_time_check();
+ this._super(doc);
+ },
onload: function() {
var me = this;
this._super();
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index ae8fd8a..3f9868d 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "naming_series:",
@@ -258,65 +259,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "column_break1",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "oldfieldtype": "Column Break",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 1,
- "collapsible": 0,
- "columns": 0,
- "default": "Today",
- "fieldname": "posting_date",
- "fieldtype": "Date",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Date",
- "length": 0,
- "no_copy": 1,
- "oldfieldname": "posting_date",
- "oldfieldtype": "Date",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 1,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "due_date",
"fieldtype": "Date",
"hidden": 0,
@@ -347,6 +289,65 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "project",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 1,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Project",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "project_name",
+ "oldfieldtype": "Link",
+ "options": "Project",
+ "permlevel": 0,
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break1",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldtype": "Column Break",
+ "permlevel": 0,
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "company",
"fieldtype": "Link",
"hidden": 0,
@@ -378,27 +379,87 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "project",
- "fieldtype": "Link",
+ "depends_on": "eval:doc.docstatus==0",
+ "fieldname": "set_posting_time",
+ "fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
- "in_global_search": 1,
+ "in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Project",
+ "label": "Edit Posting Date and Time",
"length": 0,
"no_copy": 0,
- "oldfieldname": "project_name",
- "oldfieldtype": "Link",
- "options": "Project",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 1,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "Today",
+ "fieldname": "posting_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Date",
+ "length": 0,
+ "no_copy": 1,
+ "oldfieldname": "posting_date",
+ "oldfieldtype": "Date",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
+ "reqd": 1,
+ "search_index": 1,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "posting_time",
+ "fieldtype": "Time",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Posting Time",
+ "length": 0,
+ "no_copy": 1,
+ "oldfieldname": "posting_time",
+ "oldfieldtype": "Time",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
@@ -3563,36 +3624,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "posting_time",
- "fieldtype": "Time",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Posting Time",
- "length": 0,
- "no_copy": 1,
- "oldfieldname": "posting_time",
- "oldfieldtype": "Time",
- "permlevel": 0,
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "remarks",
"fieldtype": "Small Text",
"hidden": 0,
@@ -4315,19 +4346,19 @@
"unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-file-text",
"idx": 181,
"image_view": 0,
"in_create": 0,
- "in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2017-02-22 18:20:35.085909",
+ "modified": "2017-03-14 16:10:33.113402",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 01a9a2f..5b16cd6 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -8,7 +8,7 @@
frappe.ui.form.on("Purchase Order", {
setup: function(frm) {
frm.custom_make_buttons = {
- 'Purchase Receipt': 'Receive',
+ 'Purchase Receipt': 'Receipt',
'Purchase Invoice': 'Invoice',
'Stock Entry': 'Material to Supplier'
}
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index d8eb25b..7d42f41 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -2,6 +2,12 @@
// License: GNU General Public License v3. See license.txt
frappe.ui.form.on("Production Order", {
+ setup: function(frm) {
+ frm.custom_make_buttons = {
+ 'Timesheet': 'Make Timesheet',
+ 'Stock Entry': 'Make Stock Entry',
+ }
+ },
onload: function(frm) {
if (!frm.doc.status)
frm.doc.status = 'Draft';
@@ -16,7 +22,7 @@
});
erpnext.production_order.set_default_warehouse(frm);
}
-
+
// formatter for production order operation
frm.set_indicator_formatter('operation',
function(doc) { return (frm.doc.qty==doc.completed_qty) ? "green" : "orange" })
@@ -27,8 +33,8 @@
},
refresh: function(frm) {
erpnext.toggle_naming_series();
- frm.set_intro("");
erpnext.production_order.set_custom_buttons(frm);
+ frm.set_intro("");
if (frm.doc.docstatus === 0 && !frm.doc.__islocal) {
frm.set_intro(__("Submit this Production Order for further processing."));
@@ -37,7 +43,7 @@
if (frm.doc.docstatus===1) {
frm.trigger('show_progress');
}
-
+
if(frm.doc.docstatus == 1 && frm.doc.status != 'Stopped'){
frm.add_custom_button(__('Make Timesheet'), function(){
frappe.model.open_mapped_doc({
@@ -110,34 +116,21 @@
set_custom_buttons: function(frm) {
var doc = frm.doc;
if (doc.docstatus === 1) {
- frm.add_custom_button(__("Stock Entries"), function() {
- frappe.route_options = {
- production_order: frm.doc.name
- }
- frappe.set_route("List", "Stock Entry");
- }, __("View"));
-
if (doc.status != 'Stopped' && doc.status != 'Completed') {
frm.add_custom_button(__('Stop'), cur_frm.cscript['Stop Production Order'], __("Status"));
} else if (doc.status == 'Stopped') {
frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Production Order'], __("Status"));
}
- // opertions
- if (((doc.operations || []).length) && frm.doc.status != 'Stopped') {
- frm.add_custom_button(__('Timesheet'), function() {
- frappe.route_options = {"production_order": frm.doc.name};
- frappe.set_route("List", "Timesheet");
- }, __("View"));
- }
-
if ((flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) && frm.doc.status != 'Stopped') {
+ frm.has_start_btn = true;
var btn = frm.add_custom_button(__('Start'),
cur_frm.cscript['Transfer Raw Materials']);
btn.addClass('btn-primary');
}
if ((flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing)) && frm.doc.status != 'Stopped') {
+ frm.has_finish_btn = true;
var btn = frm.add_custom_button(__('Finish'),
cur_frm.cscript['Update Finished Goods']);
diff --git a/erpnext/manufacturing/doctype/production_order/production_order_dashboard.py b/erpnext/manufacturing/doctype/production_order/production_order_dashboard.py
new file mode 100644
index 0000000..7c8c8c6
--- /dev/null
+++ b/erpnext/manufacturing/doctype/production_order/production_order_dashboard.py
@@ -0,0 +1,11 @@
+from frappe import _
+
+def get_data():
+ return {
+ 'fieldname': 'production_order',
+ 'transactions': [
+ {
+ 'items': ['Stock Entry', 'Timesheet']
+ }
+ ]
+ }
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/stock_controller.js b/erpnext/public/js/controllers/stock_controller.js
index a360d91..cf1f1e9 100644
--- a/erpnext/public/js/controllers/stock_controller.js
+++ b/erpnext/public/js/controllers/stock_controller.js
@@ -18,6 +18,36 @@
});
},
+ setup_posting_date_time_check: function() {
+ // make posting date default and read only unless explictly checked
+ frappe.ui.form.on(this.frm.doctype, 'set_posting_date_and_time_read_only', function(frm) {
+ if(frm.doc.docstatus == 0 && frm.doc.set_posting_time) {
+ frm.set_df_property('posting_date', 'read_only', 0);
+ frm.set_df_property('posting_time', 'read_only', 0);
+ } else {
+ frm.set_df_property('posting_date', 'read_only', 1);
+ frm.set_df_property('posting_time', 'read_only', 1);
+ }
+ })
+
+ frappe.ui.form.on(this.frm.doctype, 'set_posting_time', function(frm) {
+ frm.trigger('set_posting_date_and_time_read_only');
+ });
+
+ frappe.ui.form.on(this.frm.doctype, 'refresh', function(frm) {
+ // set default posting date / time
+ if(frm.doc.docstatus==0) {
+ if(!frm.doc.posting_date) {
+ frm.set_value('posting_date', frappe.datetime.nowdate());
+ }
+ if(!frm.doc.posting_time) {
+ frm.set_value('posting_time', frappe.datetime.now_time());
+ }
+ frm.trigger('set_posting_date_and_time_read_only');
+ }
+ });
+ },
+
show_stock_ledger: function() {
var me = this;
if(this.frm.doc.docstatus===1) {
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 02732d2..fb5ff54 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -134,7 +134,7 @@
}
});
}
-
+
this.setup_quality_inspection();
},
@@ -143,9 +143,9 @@
return;
}
var me = this;
- var inspection_type = in_list(["Purchase Receipt", "Purchase Invoice"], this.frm.doc.doctype)
+ var inspection_type = in_list(["Purchase Receipt", "Purchase Invoice"], this.frm.doc.doctype)
? "Incoming" : "Outgoing";
-
+
var quality_inspection_field = this.frm.get_docfield("items", "quality_inspection");
quality_inspection_field.get_route_options_for_new_doc = function(row) {
if(me.frm.is_new()) return;
@@ -159,7 +159,7 @@
"batch_no": row.doc.batch_no
}
}
-
+
this.frm.set_query("quality_inspection", "items", function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
return {
@@ -319,7 +319,7 @@
refresh_field("serial_no", item.name, item.parentfield);
if(!doc.is_return) {
- frappe.model.set_value(item.doctype, item.name,
+ frappe.model.set_value(item.doctype, item.name,
"qty", sr_no.length / item.conversion_factor);
frappe.model.set_value(item.doctype, item.name, "stock_qty", sr_no.length);
}
@@ -460,7 +460,7 @@
/* manqala 19/09/2016: let the translation date be whichever of the transaction_date or posting_date is available */
var transaction_date = this.frm.doc.transaction_date || this.frm.doc.posting_date;
/* end manqala */
-
+
var me = this;
this.set_dynamic_labels();
@@ -596,7 +596,7 @@
this.frm.set_currency_labels(["base_total", "base_net_total", "base_total_taxes_and_charges",
"base_discount_amount", "base_grand_total", "base_rounded_total", "base_in_words",
"base_taxes_and_charges_added", "base_taxes_and_charges_deducted", "total_amount_to_pay",
- "base_paid_amount", "base_write_off_amount", "base_change_amount", "base_operating_cost",
+ "base_paid_amount", "base_write_off_amount", "base_change_amount", "base_operating_cost",
"base_raw_material_cost", "base_total_cost", "base_scrap_material_cost"
], company_currency);
@@ -619,7 +619,7 @@
this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_total_taxes_and_charges",
"base_taxes_and_charges_added", "base_taxes_and_charges_deducted",
"base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount",
- "base_paid_amount", "base_write_off_amount", "base_operating_cost",
+ "base_paid_amount", "base_write_off_amount", "base_operating_cost",
"base_raw_material_cost", "base_total_cost", "base_scrap_material_cost"],
this.frm.doc.currency != company_currency);
@@ -1080,5 +1080,5 @@
return method
},
-
+
});
\ No newline at end of file
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 4705be6..976cfc8 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -21,31 +21,98 @@
erpnext.queries.setup_warehouse_query(frm);
+ frm.set_query('project', function(doc) {
+ return {
+ query: "erpnext.controllers.queries.get_project_name",
+ filters: {
+ 'customer': doc.customer
+ }
+ }
+ })
+
+ frm.set_query('transporter_name', function(doc) {
+ return {
+ filters: { 'supplier_type': "transporter" }
+ }
+ });
+
+ if (sys_defaults.auto_accounting_for_stock) {
+ frm.set_query('expense_account', 'items', function(frm) {
+ return {
+ filters: {
+ "report_type": "Profit and Loss",
+ "company": doc.company,
+ "is_group": 0
+ }
+ }
+ });
+
+ frm.set_query('cost_center', 'items', function(frm) {
+ return {
+ filters: {
+ 'company': doc.company,
+ "is_group": 0
+ }
+ }
+ });
+ }
+
+ $.extend(frm.cscript, new erpnext.stock.DeliveryNoteController({frm: frm}));
+ },
+ print_without_amount: function(frm) {
+ erpnext.stock.delivery_note.set_print_hide(frm.doc);
+ },
+ on_submit: function(frm) {
+ if(cint(frappe.boot.notification_settings.delivery_note)) {
+ frm.email_doc(frappe.boot.notification_settings.delivery_note_message);
+ }
}
});
+frappe.ui.form.on("Delivery Note Item", {
+ expense_account: function(frm, dt, dn) {
+ var d = locals[dt][dn];
+ frm.update_in_all_rows('items', 'expense_account', d.expense_account);
+ },
+ cost_center: function(frm, dt, dn) {
+ var d = locals[dt][dn];
+ frm.update_in_all_rows('items', 'cost_center', d.cost_center);
+ }
+});
+
+
erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend({
+ setup: function(doc) {
+ this.setup_posting_date_time_check();
+ this._super(doc);
+ },
refresh: function(doc, dt, dn) {
+ var me = this;
this._super();
if (!doc.is_return && doc.status!="Closed") {
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1)
- cur_frm.add_custom_button(__('Installation Note'), this.make_installation_note, __("Make"));
+ this.frm.add_custom_button(__('Installation Note'), function() {
+ me.make_installation_note() }, __("Make"));
if (doc.docstatus==1) {
- cur_frm.add_custom_button(__('Sales Return'), this.make_sales_return, __("Make"));
+ this.frm.add_custom_button(__('Sales Return'), function() {
+ me.make_sales_return() }, __("Make"));
}
if(doc.docstatus==0 && !doc.__islocal) {
- cur_frm.add_custom_button(__('Packing Slip'),
- cur_frm.cscript['Make Packing Slip'], __("Make"));
+ this.frm.add_custom_button(__('Packing Slip'), function() {
+ frappe.model.open_mapped_doc({
+ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip",
+ frm: me.frm
+ }) }, __("Make"));
}
if (!doc.__islocal && doc.docstatus==1) {
- cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
+ this.frm.page.set_inner_btn_group_as_primary(__("Make"));
}
if (this.frm.doc.docstatus===0) {
- cur_frm.add_custom_button(__('Sales Order'),
+ this.frm.add_custom_button(__('Sales Order'),
function() {
erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
@@ -54,9 +121,9 @@
docstatus: 1,
status: ["!=", "Closed"],
per_delivered: ["<", 99.99],
- project: cur_frm.doc.project || undefined,
- customer: cur_frm.doc.customer || undefined,
- company: cur_frm.doc.company
+ project: me.frm.doc.project || undefined,
+ customer: me.frm.doc.customer || undefined,
+ company: me.frm.doc.company
}
})
}, __("Get items from"));
@@ -69,49 +136,53 @@
this.show_general_ledger();
}
if (this.frm.has_perm("submit") && doc.status !== "Closed") {
- cur_frm.add_custom_button(__("Close"), this.close_delivery_note, __("Status"))
+ me.frm.add_custom_button(__("Close"), function() { me.close_delivery_note() },
+ __("Status"))
}
}
if(doc.docstatus==1 && !doc.is_return && doc.status!="Closed" && flt(doc.per_billed) < 100) {
// show Make Invoice button only if Delivery Note is not created from Sales Invoice
var from_sales_invoice = false;
- from_sales_invoice = cur_frm.doc.items.some(function(item) {
+ from_sales_invoice = me.frm.doc.items.some(function(item) {
return item.against_sales_invoice ? true : false;
});
- if(!from_sales_invoice)
- cur_frm.add_custom_button(__('Invoice'), this.make_sales_invoice, __("Make"));
+ if(!from_sales_invoice) {
+ this.frm.add_custom_button(__('Invoice'), function() { me.make_sales_invoice() },
+ __("Make"));
+ }
}
if(doc.docstatus==1 && doc.status === "Closed" && this.frm.has_perm("submit")) {
- cur_frm.add_custom_button(__('Reopen'), this.reopen_delivery_note, __("Status"))
+ this.frm.add_custom_button(__('Reopen'), function() { me.reopen_delivery_note() },
+ __("Status"))
}
erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
// unhide expense_account and cost_center is auto_accounting_for_stock enabled
var aii_enabled = cint(sys_defaults.auto_accounting_for_stock)
- cur_frm.fields_dict["items"].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled);
+ this.frm.fields_dict["items"].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled);
},
make_sales_invoice: function() {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
- frm: cur_frm
+ frm: this.frm
})
},
make_installation_note: function() {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note",
- frm: cur_frm
+ frm: this.frm
});
},
make_sales_return: function() {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_return",
- frm: cur_frm
+ frm: this.frm
})
},
@@ -124,56 +195,31 @@
},
close_delivery_note: function(doc){
- cur_frm.cscript.update_status("Closed")
+ this.update_status("Closed")
},
reopen_delivery_note : function() {
- cur_frm.cscript.update_status("Submitted")
+ this.update_status("Submitted")
+ },
+
+ update_status: function(status) {
+ var me = this;
+ frappe.ui.form.is_saving = true;
+ frappe.call({
+ method:"erpnext.stock.doctype.delivery_note.delivery_note.update_delivery_note_status",
+ args: {docname: me.frm.doc.name, status: status},
+ callback: function(r){
+ if(!r.exc)
+ me.frm.reload_doc();
+ },
+ always: function(){
+ frappe.ui.form.is_saving = false;
+ }
+ })
}
});
-// for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm}));
-
-
-cur_frm.cscript.update_status = function(status) {
- frappe.ui.form.is_saving = true;
- frappe.call({
- method:"erpnext.stock.doctype.delivery_note.delivery_note.update_delivery_note_status",
- args: {docname: cur_frm.doc.name, status: status},
- callback: function(r){
- if(!r.exc)
- cur_frm.reload_doc();
- },
- always: function(){
- frappe.ui.form.is_saving = false;
- }
- })
-}
-
-// ***************** Get project name *****************
-cur_frm.fields_dict['project'].get_query = function(doc, cdt, cdn) {
- return {
- query: "erpnext.controllers.queries.get_project_name",
- filters: {
- 'customer': doc.customer
- }
- }
-}
-
-cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
- return{
- filters: { 'supplier_type': "transporter" }
- }
-}
-
-cur_frm.cscript['Make Packing Slip'] = function() {
- frappe.model.open_mapped_doc({
- method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip",
- frm: cur_frm
- })
-}
erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){
var dn_fields = frappe.meta.docfield_map['Delivery Note'];
@@ -199,60 +245,3 @@
dn_fields['taxes'].print_hide = 0;
}
}
-
-cur_frm.cscript.print_without_amount = function(doc, cdt, cdn) {
- erpnext.stock.delivery_note.set_print_hide(doc, cdt, cdn);
-}
-
-cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- if(cint(frappe.boot.notification_settings.delivery_note)) {
- cur_frm.email_doc(frappe.boot.notification_settings.delivery_note_message);
- }
-}
-
-if (sys_defaults.auto_accounting_for_stock) {
-
- cur_frm.cscript.expense_account = function(doc, cdt, cdn){
- var d = locals[cdt][cdn];
- if(d.expense_account) {
- var cl = doc["items"] || [];
- for(var i = 0; i < cl.length; i++){
- if(!cl[i].expense_account) cl[i].expense_account = d.expense_account;
- }
- }
- refresh_field("items");
- }
-
- // expense account
- cur_frm.fields_dict['items'].grid.get_field('expense_account').get_query = function(doc) {
- return {
- filters: {
- "report_type": "Profit and Loss",
- "company": doc.company,
- "is_group": 0
- }
- }
- }
-
- // cost center
- cur_frm.cscript.cost_center = function(doc, cdt, cdn){
- var d = locals[cdt][cdn];
- if(d.cost_center) {
- var cl = doc["items"] || [];
- for(var i = 0; i < cl.length; i++){
- if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
- }
- }
- refresh_field("items");
- }
-
- cur_frm.fields_dict.items.grid.get_field("cost_center").get_query = function(doc) {
- return {
-
- filters: {
- 'company': doc.company,
- "is_group": 0
- }
- }
- }
-}
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index e0deb1b..a85a964 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "naming_series:",
@@ -291,7 +292,38 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "depends_on": "eval:doc.docstatus==0",
+ "fieldname": "set_posting_time",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Edit Posting Date and Time",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"default": "Today",
+ "depends_on": "",
"fieldname": "posting_date",
"fieldtype": "Date",
"hidden": 0,
@@ -324,6 +356,40 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "depends_on": "",
+ "description": "",
+ "fieldname": "posting_time",
+ "fieldtype": "Time",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Posting Time",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "posting_time",
+ "oldfieldtype": "Time",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_hide_if_no_value": 0,
+ "print_width": "100px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0,
+ "width": "100px"
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "po_no",
"fieldtype": "Data",
"hidden": 0,
@@ -2521,39 +2587,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "description": "Time at which items were delivered from warehouse",
- "fieldname": "posting_time",
- "fieldtype": "Time",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Posting Time",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "posting_time",
- "oldfieldtype": "Time",
- "permlevel": 0,
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "print_width": "100px",
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0,
- "width": "100px"
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "per_billed",
"fieldtype": "Percent",
"hidden": 0,
@@ -3214,19 +3247,19 @@
"unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-truck",
"idx": 146,
"image_view": 0,
"in_create": 0,
- "in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2017-02-20 13:29:16.788934",
+ "modified": "2017-03-14 16:57:42.173938",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note",
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 3b2c44c..5e8f5c9 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -94,6 +94,7 @@
frappe.throw(_("Sales Order required for Item {0}").format(d.item_code))
def validate(self):
+ self.validate_posting_time()
super(DeliveryNote, self).validate()
self.set_status()
self.so_required()
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index a96ff6e..f9370b4 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -37,6 +37,11 @@
});
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
+ setup: function(doc) {
+ this.setup_posting_date_time_check();
+ this._super(doc);
+ },
+
refresh: function() {
this._super();
if(this.frm.doc.docstatus===1) {
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
index 2e8cd1a..73367e3 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "naming_series:",
@@ -229,7 +230,38 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "depends_on": "eval:doc.docstatus==0",
+ "fieldname": "set_posting_time",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Edit Posting Date and Time",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"default": "Today",
+ "depends_on": "",
"fieldname": "posting_date",
"fieldtype": "Date",
"hidden": 0,
@@ -262,6 +294,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "depends_on": "",
"description": "Time at which materials were received",
"fieldname": "posting_time",
"fieldtype": "Time",
@@ -2801,19 +2834,19 @@
"width": "100px"
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-truck",
"idx": 261,
"image_view": 0,
"in_create": 0,
- "in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2017-02-20 13:30:17.979040",
+ "modified": "2017-03-14 16:10:58.769483",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 4bcde6a..b89987c 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -46,8 +46,9 @@
}]
def validate(self):
+ self.validate_posting_time()
super(PurchaseReceipt, self).validate()
-
+
if not self._action=="submit":
self.set_status()
self.po_required()
@@ -57,10 +58,10 @@
pc_obj = frappe.get_doc('Purchase Common')
self.check_for_closed_status(pc_obj)
-
+
if getdate(self.posting_date) > getdate(nowdate()):
throw(_("Posting Date cannot be future date"))
-
+
def validate_with_previous_doc(self):
super(PurchaseReceipt, self).validate_with_previous_doc({
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 8f6c592..864f9b1 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -188,6 +188,8 @@
setup: function() {
var me = this;
+ this.setup_posting_date_time_check();
+
this.frm.fields_dict.bom_no.get_query = function() {
return {
filters:{
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index e0833c5..a6dd825 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "naming_series:",
@@ -387,7 +388,38 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "depends_on": "eval:doc.docstatus==0",
+ "fieldname": "set_posting_time",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Edit Posting Date and Time",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"default": "Today",
+ "depends_on": "",
"fieldname": "posting_date",
"fieldtype": "Date",
"hidden": 0,
@@ -408,7 +440,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
- "reqd": 1,
+ "reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
@@ -418,6 +450,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "depends_on": "",
"fieldname": "posting_time",
"fieldtype": "Time",
"hidden": 0,
@@ -438,7 +471,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
- "reqd": 1,
+ "reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@@ -1610,18 +1643,18 @@
"unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-file-text",
"idx": 1,
"image_view": 0,
"in_create": 0,
- "in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2017-02-20 13:27:59.670920",
+ "modified": "2017-03-14 16:11:11.741704",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry",
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 2b031d1..7ed4ede 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -77,7 +77,7 @@
frappe.model.set_value(cdt, cdn, "current_valuation_rate", r.message.rate);
frappe.model.set_value(cdt, cdn, "current_amount", r.message.rate * r.message.qty);
frappe.model.set_value(cdt, cdn, "amount", r.message.rate * r.message.qty);
-
+
}
});
}
@@ -122,7 +122,7 @@
valuation_rate: function(frm, cdt, cdn) {
frm.events.set_amount_quantity(frm, cdt, cdn);
}
-
+
});
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
@@ -154,6 +154,8 @@
var me = this;
this.frm.get_docfield("items").allow_bulk_edit = 1;
+ this.setup_posting_date_time_check();
+
if (sys_defaults.auto_accounting_for_stock) {
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
this.frm.add_fetch("company", "cost_center", "cost_center");
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json
index 41a1679..cd3c3e2 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "naming_series:",
@@ -46,6 +47,35 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "set_posting_time",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Edit Posting Date and Time",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"default": "Today",
"fieldname": "posting_date",
"fieldtype": "Date",
@@ -419,19 +449,19 @@
"unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-upload-alt",
"idx": 1,
"image_view": 0,
"in_create": 0,
- "in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 1,
"menu_index": 0,
- "modified": "2017-02-20 13:31:41.489372",
+ "modified": "2017-03-14 15:55:38.016195",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Reconciliation",
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index be20a81..958da16 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -62,7 +62,7 @@
if args.customer and cint(args.is_pos):
out.update(get_pos_profile_item_details(args.company, args))
-
+
if out.get("warehouse"):
out.update(get_bin_details(args.item_code, out.warehouse))
@@ -482,7 +482,7 @@
if (not plc_conversion_rate) or (price_list_currency and args.price_list_currency \
and price_list_currency != args.price_list_currency):
- # cksgb 19/09/2016: added args.transaction_date as posting_date argument for get_exchange_rate
+ # cksgb 19/09/2016: added args.transaction_date as posting_date argument for get_exchange_rate
plc_conversion_rate = get_exchange_rate(price_list_currency, args.currency,
args.transaction_date) or plc_conversion_rate
diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py
index 2d6cbc0..d447482 100644
--- a/erpnext/utilities/transaction_base.py
+++ b/erpnext/utilities/transaction_base.py
@@ -18,8 +18,10 @@
frappe.db.get_value("Notification Control", None, dt + "_message"))
def validate_posting_time(self):
- if not self.posting_time:
- self.posting_time = now_datetime().strftime('%H:%M:%S')
+ if not getattr(self, 'set_posting_time', False):
+ now = now_datetime()
+ self.posting_date = now.strftime('%Y-%m-%d')
+ self.posting_time = now.strftime('%H:%M:%S')
def add_calendar_event(self, opts, force=False):
if cstr(self.contact_by) != cstr(self._prev.contact_by) or \
@@ -107,7 +109,7 @@
def get_link_filters(self, for_doctype):
if hasattr(self, "prev_link_mapper") and self.prev_link_mapper.get(for_doctype):
fieldname = self.prev_link_mapper[for_doctype]["fieldname"]
-
+
values = filter(None, tuple([item.as_dict()[fieldname] for item in self.items]))
if values:
@@ -120,7 +122,7 @@
ret = None
else:
ret = None
-
+
return ret
def delete_events(ref_type, ref_name):