Merge pull request #8016 from rmehta/posting-date-option

[feature] posting date, time is always current unless explicitly set
This commit is contained in:
Nabin Hait 2017-03-15 11:22:04 +05:30 committed by GitHub
commit ee7b4f2882
33 changed files with 673 additions and 420 deletions

View File

@ -188,6 +188,7 @@ def make_purchase_invoice(asset, item_code, gross_purchase_amount, company, post
pi = frappe.new_doc("Purchase Invoice") pi = frappe.new_doc("Purchase Invoice")
pi.company = company pi.company = company
pi.currency = frappe.db.get_value("Company", company, "default_currency") pi.currency = frappe.db.get_value("Company", company, "default_currency")
pi.set_posting_time = 1
pi.posting_date = posting_date pi.posting_date = posting_date
pi.append("items", { pi.append("items", {
"item_code": item_code, "item_code": item_code,

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 0,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -254,7 +255,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "", "default": "",
"depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type)", "depends_on": "eval:in_list([\"Receive\", \"Pay\"], doc.payment_type) && doc.docstatus==0",
"fieldname": "party_type", "fieldname": "party_type",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -1664,17 +1665,17 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"idx": 0, "idx": 0,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-02-17 16:15:52.917533", "modified": "2017-03-14 17:12:48.816644",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Entry", "name": "Payment Entry",

View File

@ -6,6 +6,10 @@ frappe.provide("erpnext.accounts");
erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
setup: function(doc) {
this.setup_posting_date_time_check();
this._super(doc);
},
onload: function() { onload: function() {
this._super(); this._super();

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 0,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -253,6 +254,36 @@
"unique": 0, "unique": 0,
"width": "50%" "width": "50%"
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -284,6 +315,37 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 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,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"print_width": "100px",
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0,
"width": "100px"
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -3000,37 +3062,6 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 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,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"print_width": "100px",
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0,
"width": "100px"
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -3515,19 +3546,19 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-file-text", "icon": "fa fa-file-text",
"idx": 204, "idx": 204,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2017-02-22 18:16:09.890488", "modified": "2017-03-14 17:00:07.106802",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Purchase Invoice", "name": "Purchase Invoice",

View File

@ -40,6 +40,7 @@ class PurchaseInvoice(BuyingController):
if not self.is_opening: if not self.is_opening:
self.is_opening = 'No' self.is_opening = 'No'
self.validate_posting_time()
super(PurchaseInvoice, self).validate() super(PurchaseInvoice, self).validate()
if not self.is_return: if not self.is_return:

View File

@ -8,6 +8,10 @@ cur_frm.pformat.print_heading = 'Invoice';
frappe.provide("erpnext.accounts"); frappe.provide("erpnext.accounts");
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
setup: function(doc) {
this.setup_posting_date_time_check();
this._super(doc);
},
onload: function() { onload: function() {
var me = this; var me = this;
this._super(); this._super();

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 0,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -253,65 +254,6 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 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": 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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -342,6 +284,65 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -378,27 +379,87 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "project", "depends_on": "eval:doc.docstatus==0",
"fieldtype": "Link", "fieldname": "set_posting_time",
"fieldtype": "Check",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 1, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Project", "label": "Edit Posting Date and Time",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"oldfieldname": "project_name", "permlevel": 0,
"oldfieldtype": "Link", "precision": "",
"options": "Project", "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, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 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, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
@ -3558,36 +3619,6 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 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,
"unique": 0
},
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -4315,19 +4346,19 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-file-text", "icon": "fa fa-file-text",
"idx": 181, "idx": 181,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2017-02-22 18:20:35.085909", "modified": "2017-03-14 16:10:33.113402",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@ -1046,6 +1046,8 @@ class TestSalesInvoice(unittest.TestCase):
def create_sales_invoice(**args): def create_sales_invoice(**args):
si = frappe.new_doc("Sales Invoice") si = frappe.new_doc("Sales Invoice")
args = frappe._dict(args) args = frappe._dict(args)
if args.posting_date:
si.set_posting_time = 1
si.posting_date = args.posting_date or nowdate() si.posting_date = args.posting_date or nowdate()
si.company = args.company or "_Test Company" si.company = args.company or "_Test Company"

View File

@ -8,7 +8,7 @@ frappe.provide("erpnext.buying");
frappe.ui.form.on("Purchase Order", { frappe.ui.form.on("Purchase Order", {
setup: function(frm) { setup: function(frm) {
frm.custom_make_buttons = { frm.custom_make_buttons = {
'Purchase Receipt': 'Receive', 'Purchase Receipt': 'Receipt',
'Purchase Invoice': 'Invoice', 'Purchase Invoice': 'Invoice',
'Stock Entry': 'Material to Supplier' 'Stock Entry': 'Material to Supplier'
} }

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -781,6 +782,7 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-user", "icon": "fa fa-user",
@ -788,12 +790,11 @@
"image_field": "image", "image_field": "image",
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-02-17 16:46:48.202078", "modified": "2017-03-14 17:04:17.785461",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Buying", "module": "Buying",
"name": "Supplier", "name": "Supplier",
@ -948,6 +949,6 @@
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_order": "ASC", "sort_order": "ASC",
"title_field": "supplier_name", "title_field": "supplier_name",
"track_changes": 0, "track_changes": 1,
"track_seen": 0 "track_seen": 0
} }

View File

@ -93,6 +93,9 @@ def make_new_document(reference_doc, date_field, posting_date):
"next_date": get_next_date(reference_doc.next_date, mcount,cint(reference_doc.repeat_on_day_of_month)) "next_date": get_next_date(reference_doc.next_date, mcount,cint(reference_doc.repeat_on_day_of_month))
}) })
if new_document.meta.get_field('set_posting_time'):
new_document.set('set_posting_time', 1)
# copy document fields # copy document fields
for fieldname in ("owner", "recurring_type", "repeat_on_day_of_month", for fieldname in ("owner", "recurring_type", "repeat_on_day_of_month",
"recurring_id", "notification_email_address", "is_recurring", "end_date", "recurring_id", "notification_email_address", "is_recurring", "end_date",

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -2340,6 +2341,7 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-user", "icon": "fa fa-user",
@ -2347,12 +2349,11 @@
"image_field": "image", "image_field": "image",
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-02-17 16:56:25.571268", "modified": "2017-03-14 17:04:27.247238",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Employee", "name": "Employee",
@ -2428,6 +2429,6 @@
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"title_field": "employee_name", "title_field": "employee_name",
"track_changes": 0, "track_changes": 1,
"track_seen": 0 "track_seen": 0
} }

View File

@ -2,6 +2,12 @@
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
frappe.ui.form.on("Production Order", { frappe.ui.form.on("Production Order", {
setup: function(frm) {
frm.custom_make_buttons = {
'Timesheet': 'Make Timesheet',
'Stock Entry': 'Make Stock Entry',
}
},
onload: function(frm) { onload: function(frm) {
if (!frm.doc.status) if (!frm.doc.status)
frm.doc.status = 'Draft'; frm.doc.status = 'Draft';
@ -27,8 +33,8 @@ frappe.ui.form.on("Production Order", {
}, },
refresh: function(frm) { refresh: function(frm) {
erpnext.toggle_naming_series(); erpnext.toggle_naming_series();
frm.set_intro("");
erpnext.production_order.set_custom_buttons(frm); erpnext.production_order.set_custom_buttons(frm);
frm.set_intro("");
if (frm.doc.docstatus === 0 && !frm.doc.__islocal) { if (frm.doc.docstatus === 0 && !frm.doc.__islocal) {
frm.set_intro(__("Submit this Production Order for further processing.")); frm.set_intro(__("Submit this Production Order for further processing."));
@ -110,34 +116,21 @@ erpnext.production_order = {
set_custom_buttons: function(frm) { set_custom_buttons: function(frm) {
var doc = frm.doc; var doc = frm.doc;
if (doc.docstatus === 1) { 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') { if (doc.status != 'Stopped' && doc.status != 'Completed') {
frm.add_custom_button(__('Stop'), cur_frm.cscript['Stop Production Order'], __("Status")); frm.add_custom_button(__('Stop'), cur_frm.cscript['Stop Production Order'], __("Status"));
} else if (doc.status == 'Stopped') { } else if (doc.status == 'Stopped') {
frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Production Order'], __("Status")); 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') { 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'), var btn = frm.add_custom_button(__('Start'),
cur_frm.cscript['Transfer Raw Materials']); cur_frm.cscript['Transfer Raw Materials']);
btn.addClass('btn-primary'); btn.addClass('btn-primary');
} }
if ((flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing)) && frm.doc.status != 'Stopped') { 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'), var btn = frm.add_custom_button(__('Finish'),
cur_frm.cscript['Update Finished Goods']); cur_frm.cscript['Update Finished Goods']);

View File

@ -0,0 +1,11 @@
from frappe import _
def get_data():
return {
'fieldname': 'production_order',
'transactions': [
{
'items': ['Stock Entry', 'Timesheet']
}
]
}

View File

@ -18,6 +18,36 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({
}); });
}, },
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() { show_stock_ledger: function() {
var me = this; var me = this;
if(this.frm.doc.docstatus===1) { if(this.frm.doc.docstatus===1) {

View File

@ -416,7 +416,7 @@
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@ -1693,7 +1693,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2017-03-12 15:50:23.099622", "modified": "2017-03-14 17:04:38.115970",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Company", "name": "Company",
@ -1845,6 +1845,6 @@
"read_only_onload": 0, "read_only_onload": 0,
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_order": "ASC", "sort_order": "ASC",
"track_changes": 0, "track_changes": 1,
"track_seen": 0 "track_seen": 0
} }

View File

@ -21,31 +21,98 @@ frappe.ui.form.on("Delivery Note", {
erpnext.queries.setup_warehouse_query(frm); 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({ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend({
setup: function(doc) {
this.setup_posting_date_time_check();
this._super(doc);
},
refresh: function(doc, dt, dn) { refresh: function(doc, dt, dn) {
var me = this;
this._super(); this._super();
if (!doc.is_return && doc.status!="Closed") { if (!doc.is_return && doc.status!="Closed") {
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) 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) { 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) { if(doc.docstatus==0 && !doc.__islocal) {
cur_frm.add_custom_button(__('Packing Slip'), this.frm.add_custom_button(__('Packing Slip'), function() {
cur_frm.cscript['Make Packing Slip'], __("Make")); 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) { 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) { if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Sales Order'), this.frm.add_custom_button(__('Sales Order'),
function() { function() {
erpnext.utils.map_current_doc({ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note", method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
@ -54,9 +121,9 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
docstatus: 1, docstatus: 1,
status: ["!=", "Closed"], status: ["!=", "Closed"],
per_delivered: ["<", 99.99], per_delivered: ["<", 99.99],
project: cur_frm.doc.project || undefined, project: me.frm.doc.project || undefined,
customer: cur_frm.doc.customer || undefined, customer: me.frm.doc.customer || undefined,
company: cur_frm.doc.company company: me.frm.doc.company
} }
}) })
}, __("Get items from")); }, __("Get items from"));
@ -69,49 +136,53 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
this.show_general_ledger(); this.show_general_ledger();
} }
if (this.frm.has_perm("submit") && doc.status !== "Closed") { 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) { 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 // show Make Invoice button only if Delivery Note is not created from Sales Invoice
var from_sales_invoice = false; 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; return item.against_sales_invoice ? true : false;
}); });
if(!from_sales_invoice) if(!from_sales_invoice) {
cur_frm.add_custom_button(__('Invoice'), this.make_sales_invoice, __("Make")); this.frm.add_custom_button(__('Invoice'), function() { me.make_sales_invoice() },
__("Make"));
}
} }
if(doc.docstatus==1 && doc.status === "Closed" && this.frm.has_perm("submit")) { 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); erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
// unhide expense_account and cost_center is auto_accounting_for_stock enabled // unhide expense_account and cost_center is auto_accounting_for_stock enabled
var aii_enabled = cint(sys_defaults.auto_accounting_for_stock) 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() { make_sales_invoice: function() {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice", method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
frm: cur_frm frm: this.frm
}) })
}, },
make_installation_note: function() { make_installation_note: function() {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note", method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note",
frm: cur_frm frm: this.frm
}); });
}, },
make_sales_return: function() { make_sales_return: function() {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_return", method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_return",
frm: cur_frm frm: this.frm
}) })
}, },
@ -124,27 +195,22 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
}, },
close_delivery_note: function(doc){ close_delivery_note: function(doc){
cur_frm.cscript.update_status("Closed") this.update_status("Closed")
}, },
reopen_delivery_note : function() { reopen_delivery_note : function() {
cur_frm.cscript.update_status("Submitted") this.update_status("Submitted")
} },
}); update_status: function(status) {
var me = this;
// 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.ui.form.is_saving = true;
frappe.call({ frappe.call({
method:"erpnext.stock.doctype.delivery_note.delivery_note.update_delivery_note_status", method:"erpnext.stock.doctype.delivery_note.delivery_note.update_delivery_note_status",
args: {docname: cur_frm.doc.name, status: status}, args: {docname: me.frm.doc.name, status: status},
callback: function(r){ callback: function(r){
if(!r.exc) if(!r.exc)
cur_frm.reload_doc(); me.frm.reload_doc();
}, },
always: function(){ always: function(){
frappe.ui.form.is_saving = false; frappe.ui.form.is_saving = false;
@ -152,28 +218,8 @@ cur_frm.cscript.update_status = function(status) {
}) })
} }
// ***************** 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){ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){
var dn_fields = frappe.meta.docfield_map['Delivery Note']; var dn_fields = frappe.meta.docfield_map['Delivery Note'];
@ -199,60 +245,3 @@ erpnext.stock.delivery_note.set_print_hide = function(doc, cdt, cdn){
dn_fields['taxes'].print_hide = 0; 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
}
}
}
}

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 0,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -286,12 +287,43 @@
"unique": 0, "unique": 0,
"width": "150px" "width": "150px"
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Today", "default": "Today",
"depends_on": "",
"fieldname": "posting_date", "fieldname": "posting_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
@ -319,6 +351,40 @@
"unique": 0, "unique": 0,
"width": "100px" "width": "100px"
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -2516,39 +2582,6 @@
"unique": 0, "unique": 0,
"width": "50%" "width": "50%"
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -3214,19 +3247,19 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-truck", "icon": "fa fa-truck",
"idx": 146, "idx": 146,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2017-02-20 13:29:16.788934", "modified": "2017-03-14 16:57:42.173938",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Delivery Note", "name": "Delivery Note",

View File

@ -94,6 +94,7 @@ class DeliveryNote(SellingController):
frappe.throw(_("Sales Order required for Item {0}").format(d.item_code)) frappe.throw(_("Sales Order required for Item {0}").format(d.item_code))
def validate(self): def validate(self):
self.validate_posting_time()
super(DeliveryNote, self).validate() super(DeliveryNote, self).validate()
self.set_status() self.set_status()
self.so_required() self.so_required()

View File

@ -437,6 +437,7 @@ class TestDeliveryNote(unittest.TestCase):
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1) frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
dn1 = make_delivery_note(so.name) dn1 = make_delivery_note(so.name)
dn1.set_posting_time = 1
dn1.posting_time = "10:00" dn1.posting_time = "10:00"
dn1.get("items")[0].qty = 2 dn1.get("items")[0].qty = 2
dn1.submit() dn1.submit()
@ -446,6 +447,7 @@ class TestDeliveryNote(unittest.TestCase):
self.assertEqual(dn1.status, "Completed") self.assertEqual(dn1.status, "Completed")
dn2 = make_delivery_note(so.name) dn2 = make_delivery_note(so.name)
dn2.set_posting_time = 1
dn2.posting_time = "08:00" dn2.posting_time = "08:00"
dn2.get("items")[0].qty = 4 dn2.get("items")[0].qty = 4
dn2.submit() dn2.submit()
@ -468,6 +470,7 @@ class TestDeliveryNote(unittest.TestCase):
so = make_sales_order() so = make_sales_order()
dn1 = make_delivery_note(so.name) dn1 = make_delivery_note(so.name)
dn1.set_posting_time = 1
dn1.posting_time = "10:00" dn1.posting_time = "10:00"
dn1.get("items")[0].qty = 2 dn1.get("items")[0].qty = 2
dn1.submit() dn1.submit()

View File

@ -37,6 +37,11 @@ frappe.ui.form.on("Purchase Receipt", {
}); });
erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({
setup: function(doc) {
this.setup_posting_date_time_check();
this._super(doc);
},
refresh: function() { refresh: function() {
this._super(); this._super();
if(this.frm.doc.docstatus===1) { if(this.frm.doc.docstatus===1) {

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 0,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -224,12 +225,43 @@
"unique": 0, "unique": 0,
"width": "50%" "width": "50%"
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Today", "default": "Today",
"depends_on": "",
"fieldname": "posting_date", "fieldname": "posting_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
@ -262,6 +294,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "",
"description": "Time at which materials were received", "description": "Time at which materials were received",
"fieldname": "posting_time", "fieldname": "posting_time",
"fieldtype": "Time", "fieldtype": "Time",
@ -2801,19 +2834,19 @@
"width": "100px" "width": "100px"
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-truck", "icon": "fa fa-truck",
"idx": 261, "idx": 261,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2017-02-20 13:30:17.979040", "modified": "2017-03-14 16:10:58.769483",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Purchase Receipt", "name": "Purchase Receipt",

View File

@ -46,6 +46,7 @@ class PurchaseReceipt(BuyingController):
}] }]
def validate(self): def validate(self):
self.validate_posting_time()
super(PurchaseReceipt, self).validate() super(PurchaseReceipt, self).validate()
if not self._action=="submit": if not self._action=="submit":

View File

@ -188,6 +188,8 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
setup: function() { setup: function() {
var me = this; var me = this;
this.setup_posting_date_time_check();
this.frm.fields_dict.bom_no.get_query = function() { this.frm.fields_dict.bom_no.get_query = function() {
return { return {
filters:{ filters:{

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0, "allow_rename": 0,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -382,12 +383,43 @@
"unique": 0, "unique": 0,
"width": "50%" "width": "50%"
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Today", "default": "Today",
"depends_on": "",
"fieldname": "posting_date", "fieldname": "posting_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
@ -408,7 +440,7 @@
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 0,
"search_index": 1, "search_index": 1,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@ -418,6 +450,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "",
"fieldname": "posting_time", "fieldname": "posting_time",
"fieldtype": "Time", "fieldtype": "Time",
"hidden": 0, "hidden": 0,
@ -438,7 +471,7 @@
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
@ -1610,18 +1643,18 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-file-text", "icon": "fa fa-file-text",
"idx": 1, "idx": 1,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-02-20 13:27:59.670920", "modified": "2017-03-14 16:11:11.741704",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Stock Entry", "name": "Stock Entry",

View File

@ -9,6 +9,9 @@ def make_stock_entry(**args):
s = frappe.new_doc("Stock Entry") s = frappe.new_doc("Stock Entry")
args = frappe._dict(args) args = frappe._dict(args)
if args.posting_date or args.posting_time:
s.set_posting_time = 1
if args.posting_date: if args.posting_date:
s.posting_date = args.posting_date s.posting_date = args.posting_date
if args.posting_time: if args.posting_time:

View File

@ -512,6 +512,7 @@ class TestStockEntry(unittest.TestCase):
# test freeze_stocks_upto_days # test freeze_stocks_upto_days
frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 7) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 7)
se = frappe.copy_doc(test_records[0]) se = frappe.copy_doc(test_records[0])
se.set_posting_time = 1
se.posting_date = add_days(nowdate(), -15) se.posting_date = add_days(nowdate(), -15)
se.insert() se.insert()
self.assertRaises(StockFreezeError, se.submit) self.assertRaises(StockFreezeError, se.submit)

View File

@ -154,6 +154,8 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
var me = this; var me = this;
this.frm.get_docfield("items").allow_bulk_edit = 1; this.frm.get_docfield("items").allow_bulk_edit = 1;
this.setup_posting_date_time_check();
if (sys_defaults.auto_accounting_for_stock) { if (sys_defaults.auto_accounting_for_stock) {
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account"); this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
this.frm.add_fetch("company", "cost_center", "cost_center"); this.frm.add_fetch("company", "cost_center", "cost_center");

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
"autoname": "naming_series:", "autoname": "naming_series:",
@ -41,6 +42,35 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -419,19 +449,19 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "fa fa-upload-alt", "icon": "fa fa-upload-alt",
"idx": 1, "idx": 1,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 1, "max_attachments": 1,
"menu_index": 0, "menu_index": 0,
"modified": "2017-02-20 13:31:41.489372", "modified": "2017-03-14 15:55:38.016195",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Stock Reconciliation", "name": "Stock Reconciliation",

View File

@ -96,6 +96,7 @@ def create_stock_reconciliation(**args):
sr = frappe.new_doc("Stock Reconciliation") sr = frappe.new_doc("Stock Reconciliation")
sr.posting_date = args.posting_date or nowdate() sr.posting_date = args.posting_date or nowdate()
sr.posting_time = args.posting_time or nowtime() sr.posting_time = args.posting_time or nowtime()
sr.set_posting_time = 1
sr.company = args.company or "_Test Company" sr.company = args.company or "_Test Company"
sr.expense_account = args.expense_account or \ sr.expense_account = args.expense_account or \
("Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC") ("Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC")

View File

@ -18,8 +18,10 @@ class TransactionBase(StatusUpdater):
frappe.db.get_value("Notification Control", None, dt + "_message")) frappe.db.get_value("Notification Control", None, dt + "_message"))
def validate_posting_time(self): def validate_posting_time(self):
if not self.posting_time: if not getattr(self, 'set_posting_time', None):
self.posting_time = now_datetime().strftime('%H:%M:%S') 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): def add_calendar_event(self, opts, force=False):
if cstr(self.contact_by) != cstr(self._prev.contact_by) or \ if cstr(self.contact_by) != cstr(self._prev.contact_by) or \