diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index bc337a150ef..f670c905d4b 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -6,6 +6,15 @@ frappe.provide("erpnext.journal_entry"); frappe.ui.form.on("Journal Entry", { + setup: function(frm) { + frm.get_field('accounts').grid.editable_fields = [ + {fieldname: 'account', columns: 3}, + {fieldname: 'party', columns: 4}, + {fieldname: 'debit_in_account_currency', columns: 2}, + {fieldname: 'credit_in_account_currency', columns: 2} + ]; + }, + refresh: function(frm) { erpnext.toggle_naming_series(); frm.cscript.voucher_type(frm.doc); @@ -50,7 +59,7 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ }, load_defaults: function() { - this.frm.show_print_first = true; + //this.frm.show_print_first = true; if(this.frm.doc.__islocal && this.frm.doc.company) { frappe.model.set_default_values(this.frm.doc); $.each(this.frm.doc.accounts || [], function(i, jvd) { diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 923514da5b9..b634ccf2664 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -15,16 +15,21 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ this.frm.set_df_property("credit_to", "print_hide", 0); } } + + // formatter for material request item + this.frm.set_indicator_formatter('item_code', + function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" }) + }, refresh: function(doc) { this._super(); - + hide_fields(this.frm.doc); // Show / Hide button this.show_general_ledger(); - + if(doc.update_stock==1 && doc.docstatus==1) { this.show_stock_ledger(); } @@ -34,13 +39,13 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ this.frm.add_custom_button(__('Payment'), this.make_bank_entry, __("Make")); cur_frm.page.set_inner_btn_group_as_primary(__("Make")); } - + if(doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) { - cur_frm.add_custom_button(doc.update_stock ? __('Purchase Return') : __('Debit Note'), + cur_frm.add_custom_button(doc.update_stock ? __('Purchase Return') : __('Debit Note'), this.make_debit_note, __("Make")); } } - + if(doc.docstatus===0) { cur_frm.add_custom_button(__('Purchase Order'), function() { frappe.model.map_current_doc({ @@ -69,7 +74,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ }) }, __("Get items from")); } - + this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes"); }, @@ -156,7 +161,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ frm: cur_frm }) }, - + asset: function(frm, cdt, cdn) { var row = locals[cdt][cdn]; if(row.asset) { @@ -188,13 +193,13 @@ function hide_fields(doc) { var docfield = frappe.meta.docfield_map[doc.doctype][parent_fields[i]]; if(!docfield.hidden) unhide_field(parent_fields[i]); } - + } item_fields_stock = ['warehouse_section', 'received_qty', 'rejected_qty']; cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock, - (cint(doc.update_stock)==1 ? true : false)); + (cint(doc.update_stock)==1 ? true : false)); cur_frm.refresh_fields(); } @@ -361,7 +366,7 @@ frappe.ui.form.on("Purchase Invoice", { } }) }, - + is_subcontracted: function(frm) { if (frm.doc.is_subcontracted === "Yes") { erpnext.buying.get_default_bom(frm); @@ -369,4 +374,3 @@ frappe.ui.form.on("Purchase Invoice", { frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted==="Yes"); } }) - \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 952cce6a008..109a9ebcbfe 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -63,7 +63,7 @@ class SalesInvoice(SellingController): self.validate_write_off_account() self.validate_fixed_asset() self.set_income_account_for_fixed_assets() - + # if cint(self.is_pos): # self.validate_pos() @@ -85,7 +85,7 @@ class SalesInvoice(SellingController): def before_save(self): set_account_for_mode_of_payment(self) - + def update_change_amount(self): self.base_paid_amount = 0.0 if self.paid_amount: @@ -95,7 +95,7 @@ class SalesInvoice(SellingController): self.change_amount = flt(self.paid_amount - self.grand_total, self.precision("change_amount")) self.base_change_amount = flt(self.change_amount * self.conversion_rate, self.precision("base_change_amount")) - def on_submit(self): + def on_submit(self): if not self.recurring_id: frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self) @@ -109,12 +109,12 @@ class SalesInvoice(SellingController): self.update_status_updater_args() self.update_prevdoc_status() self.update_billing_status_in_dn() - - # Updating stock ledger should always be called after updating prevdoc status, + + # Updating stock ledger should always be called after updating prevdoc status, # because updating reserved qty in bin depends upon updated delivered qty in SO if self.update_stock == 1: self.update_stock_ledger() - + # this sequence because outstanding may get -ve self.make_gl_entries() @@ -149,8 +149,8 @@ class SalesInvoice(SellingController): self.update_billing_status_for_zero_amount_refdoc("Sales Order") self.validate_c_form_on_cancel() - - # Updating stock ledger should always be called after updating prevdoc status, + + # Updating stock ledger should always be called after updating prevdoc status, # because updating reserved qty in bin depends upon updated delivered qty in SO if self.update_stock == 1: self.update_stock_ledger() @@ -466,14 +466,14 @@ class SalesInvoice(SellingController): msgprint(_("POS Profile required to make POS Entry"), raise_exception=True) return warehouse - + def set_income_account_for_fixed_assets(self): disposal_account = depreciation_cost_center = None for d in self.get("items"): if d.is_fixed_asset: if not disposal_account: disposal_account, depreciation_cost_center = get_disposal_account_and_cost_center(self.company) - + d.income_account = disposal_account if not d.cost_center: d.cost_center = depreciation_cost_center @@ -573,12 +573,12 @@ class SalesInvoice(SellingController): if flt(item.base_net_amount): if item.is_fixed_asset: asset = frappe.get_doc("Asset", item.asset) - + fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(asset, item.base_net_amount) for gle in fixed_asset_gl_entries: gle["against"] = self.customer gl_entries.append(self.get_gl_dict(gle)) - + asset.db_set("disposal_date", self.posting_date) asset.set_status("Sold" if self.docstatus==1 else None) else: diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 8617a26361f..d101ece1c89 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -10,6 +10,16 @@ cur_frm.cscript.tax_table = "Purchase Taxes and Charges"; cur_frm.email_field = "contact_email"; erpnext.buying.BuyingController = erpnext.TransactionController.extend({ + setup: function() { + this._super(); + this.frm.get_field('items').grid.editable_fields = [ + {fieldname: 'item_code', columns: 4}, + {fieldname: 'qty', columns: 2}, + {fieldname: 'rate', columns: 3}, + {fieldname: 'amount', columns: 2} + ]; + }, + onload: function() { this.setup_queries(); this._super(); diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 17050caac4d..29501f5973d 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -8,6 +8,10 @@ frappe.ui.form.on("Sales Order", { erpnext.queries.setup_queries(frm, "Warehouse", function() { return erpnext.queries.warehouse(frm.doc); }); + + // formatter for material request item + frm.set_indicator_formatter('item_code', + function(doc) { return (doc.qty<=doc.delivered_qty) ? "green" : "orange" }) } }); @@ -117,7 +121,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( tc_name: function() { this.get_terms(); }, - + make_material_request: function() { frappe.model.open_mapped_doc({ method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request", diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index e613daf84ae..d02fed28d76 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -10,12 +10,24 @@ cur_frm.email_field = "contact_email"; frappe.provide("erpnext.selling"); erpnext.selling.SellingController = erpnext.TransactionController.extend({ + setup: function() { + this._super(); + this.frm.get_field('items').grid.editable_fields = [ + {fieldname: 'item_code', columns: 4}, + {fieldname: 'qty', columns: 2}, + {fieldname: 'rate', columns: 3}, + {fieldname: 'amount', columns: 2} + ]; + }, + onload: function() { this._super(); this.setup_queries(); }, setup_queries: function() { + + var me = this; this.frm.add_fetch("sales_partner", "commission_rate", "commission_rate"); @@ -336,17 +348,21 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ frappe.ui.form.on(cur_frm.doctype,"project", function(frm) { if(in_list(["Delivery Note", "Sales Invoice"], frm.doc.doctype)) { - frappe.call({ - method:'erpnext.projects.doctype.project.project.get_cost_center_name' , - args: { project: frm.doc.project }, - callback: function(r, rt) { - if(!r.exc) { - $.each(frm.doc["items"] || [], function(i, row) { - frappe.model.set_value(row.doctype, row.name, "cost_center", r.message); - msgprint(__("Cost Center For Item with Item Code '"+row.item_name+"' has been Changed to "+ r.message)); - }) + if(frm.doc.project) { + frappe.call({ + method:'erpnext.projects.doctype.project.project.get_cost_center_name' , + args: { project: frm.doc.project }, + callback: function(r, rt) { + if(!r.exc) { + $.each(frm.doc["items"] || [], function(i, row) { + if(r.message) { + frappe.model.set_value(row.doctype, row.name, "cost_center", r.message); + msgprint(__("Cost Center For Item with Item Code '"+row.item_name+"' has been Changed to "+ r.message)); + } + }) + } } - } - }) + }) + } } }) diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 2195a58a624..68ce231af2c 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -7,20 +7,15 @@ frappe.ui.form.on('Material Request', { setup: function(frm) { frm.get_field('items').grid.editable_fields = [ {fieldname: 'item_code', columns: 4}, - {fieldname: 'qty', columns: 3}, - {fieldname: 'uom', columns: 2}, + {fieldname: 'qty', columns: 2}, + {fieldname: 'warehouse', columns: 3}, {fieldname: 'schedule_date', columns: 2}, ]; - + }, + onload: function(frm) { // formatter for material request item - frappe.meta.set_formatter('Material Request Item', 'item_code', frm.doc.name, - function(value, df, options, doc) { - return repl('%(name)s', { - color: (doc.qty<=doc.ordered_qty) ? "green" : "orange", - name: doc.item_code - }); - } - ); + frm.set_indicator_formatter('item_code', + function(doc) { return (doc.qty<=doc.ordered_qty) ? "green" : "orange" }) } }); diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 76b039532ab..737902b5277 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -49,6 +49,14 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }; }); } + + this.frm.get_field('items').grid.editable_fields = [ + {fieldname: 'item_code', columns: 3}, + {fieldname: 'qty', columns: 2}, + {fieldname: 's_warehouse', columns: 3}, + {fieldname: 't_warehouse', columns: 3} + ]; + }, onload_post_render: function() { diff --git a/erpnext/templates/form_grid/material_request_grid.html b/erpnext/templates/form_grid/material_request_grid.html deleted file mode 100644 index 282437aef21..00000000000 --- a/erpnext/templates/form_grid/material_request_grid.html +++ /dev/null @@ -1,49 +0,0 @@ -{% var visible_columns = row.get_visible_columns(["item_code", "warehouse", - "item_name", "amount", "stock_uom", "uom", "qty", "schedule_date"]); %} - -{% if(!doc) { %} -