mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
Merge pull request #3744 from nabinhait/return
Sales / Purchase Return Improvements
This commit is contained in:
@@ -8,57 +8,64 @@ frappe.provide("erpnext.stock.delivery_note");
|
||||
erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend({
|
||||
refresh: function(doc, dt, dn) {
|
||||
this._super();
|
||||
|
||||
if (!doc.is_return) {
|
||||
if(doc.__onload && !doc.__onload.billing_complete && doc.docstatus==1) {
|
||||
// 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) {
|
||||
return item.against_sales_invoice ? true : false;
|
||||
});
|
||||
|
||||
if(doc.__onload && !doc.__onload.billing_complete && doc.docstatus==1) {
|
||||
// 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) {
|
||||
return item.against_sales_invoice ? true : false;
|
||||
});
|
||||
if(!from_sales_invoice)
|
||||
cur_frm.add_custom_button(__('Make Invoice'), this.make_sales_invoice);
|
||||
}
|
||||
|
||||
if(!from_sales_invoice)
|
||||
cur_frm.add_custom_button(__('Make Invoice'), this.make_sales_invoice);
|
||||
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1)
|
||||
cur_frm.add_custom_button(__('Make Installation Note'), this.make_installation_note);
|
||||
|
||||
if (doc.docstatus==1) {
|
||||
cur_frm.add_custom_button(__('Make Sales Return'), this.make_sales_return);
|
||||
}
|
||||
|
||||
if(doc.docstatus==0 && !doc.__islocal) {
|
||||
cur_frm.add_custom_button(__('Make Packing Slip'),
|
||||
cur_frm.cscript['Make Packing Slip'], frappe.boot.doctype_icons["Packing Slip"]);
|
||||
}
|
||||
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(__('From Sales Order'),
|
||||
function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||
source_doctype: "Sales Order",
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_delivered: ["<", 99.99],
|
||||
project_name: cur_frm.doc.project_name || undefined,
|
||||
customer: cur_frm.doc.customer || undefined,
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1)
|
||||
cur_frm.add_custom_button(__('Make Installation Note'), this.make_installation_note);
|
||||
|
||||
|
||||
if (doc.docstatus==1) {
|
||||
cur_frm.add_custom_button(__('Make Sales Return'), this.make_sales_return);
|
||||
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
}
|
||||
|
||||
if(doc.docstatus==0 && !doc.__islocal) {
|
||||
cur_frm.add_custom_button(__('Make Packing Slip'),
|
||||
cur_frm.cscript['Make Packing Slip'], frappe.boot.doctype_icons["Packing Slip"]);
|
||||
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(__('From Sales Order'),
|
||||
function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||
source_doctype: "Sales Order",
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_delivered: ["<", 99.99],
|
||||
project_name: cur_frm.doc.project_name || undefined,
|
||||
customer: cur_frm.doc.customer || undefined,
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
make_sales_invoice: function() {
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
frappe.listview_settings['Delivery Note'] = {
|
||||
add_fields: ["customer", "customer_name", "base_grand_total", "per_installed",
|
||||
"transporter_name", "grand_total"]
|
||||
"transporter_name", "grand_total", "is_return"],
|
||||
get_indicator: function(doc) {
|
||||
if(cint(doc.is_return)==1) {
|
||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,32 +29,37 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
refresh: function() {
|
||||
this._super();
|
||||
|
||||
if(this.frm.doc.docstatus == 1) {
|
||||
if(this.frm.doc.__onload && !this.frm.doc.__onload.billing_complete) {
|
||||
cur_frm.add_custom_button(__('Make Purchase Invoice'), this.make_purchase_invoice);
|
||||
this.show_stock_ledger();
|
||||
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
if(!this.frm.doc.is_return) {
|
||||
if(this.frm.doc.docstatus==0) {
|
||||
cur_frm.add_custom_button(__('From Purchase Order'),
|
||||
function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||
source_doctype: "Purchase Order",
|
||||
get_query_filters: {
|
||||
supplier: cur_frm.doc.supplier || undefined,
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_received: ["<", 99.99],
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.add_custom_button(__('Make Purchase Return'), this.make_purchase_return);
|
||||
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
} else {
|
||||
cur_frm.add_custom_button(__('From Purchase Order'),
|
||||
function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||
source_doctype: "Purchase Order",
|
||||
get_query_filters: {
|
||||
supplier: cur_frm.doc.supplier || undefined,
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_received: ["<", 99.99],
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
if(this.frm.doc.docstatus == 1) {
|
||||
if(this.frm.doc.__onload && !this.frm.doc.__onload.billing_complete) {
|
||||
cur_frm.add_custom_button(__('Make Purchase Invoice'), this.make_purchase_invoice);
|
||||
}
|
||||
|
||||
cur_frm.add_custom_button(__('Make Purchase Return'), this.make_purchase_return);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
|
||||
},
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
frappe.listview_settings['Purchase Receipt'] = {
|
||||
add_fields: ["supplier", "supplier_name", "base_grand_total", "is_subcontracted",
|
||||
"transporter_name"]
|
||||
"transporter_name", "is_return"],
|
||||
get_indicator: function(doc) {
|
||||
if(cint(doc.is_return)==1) {
|
||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +57,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
this.toggle_related_fields(this.frm.doc);
|
||||
this.toggle_enable_bom();
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
},
|
||||
|
||||
on_submit: function() {
|
||||
|
||||
@@ -83,7 +83,9 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
refresh: function() {
|
||||
if(this.frm.doc.docstatus==1) {
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user