mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-14 18:51:21 +00:00
[pull-mappers] no fields via custom button, started with quotation, material request, purchase order
This commit is contained in:
@@ -27,8 +27,15 @@ wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
||||
refresh: function(doc, cdt, cdn) {
|
||||
this._super();
|
||||
this.frm.dashboard.reset();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
cur_frm.dashboard.add_progress(cint(doc.per_received) + wn._("% Received"),
|
||||
doc.per_received);
|
||||
cur_frm.dashboard.add_progress(cint(doc.per_billed) + wn._("% Billed"),
|
||||
doc.per_billed);
|
||||
|
||||
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
if(flt(doc.per_received, 2) < 100)
|
||||
cur_frm.add_custom_button('Make Purchase Receipt', this.make_purchase_receipt);
|
||||
@@ -36,20 +43,15 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
cur_frm.add_custom_button('Make Invoice', this.make_purchase_invoice);
|
||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100)
|
||||
cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
|
||||
} else if(doc.docstatus===0) {
|
||||
cur_frm.cscript.add_from_mappers();
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button('Unstop Purchase Order',
|
||||
cur_frm.cscript['Unstop Purchase Order']);
|
||||
},
|
||||
|
||||
get_items: function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.material_request.material_request.make_purchase_order",
|
||||
source_name: cur_frm.doc.indent_no,
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
make_purchase_receipt: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||
@@ -64,12 +66,36 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
})
|
||||
},
|
||||
|
||||
get_supplier_quotation_items: function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
|
||||
source_name: cur_frm.doc.supplier_quotation,
|
||||
})
|
||||
add_from_mappers: function() {
|
||||
cur_frm.add_custom_button(wn._('From Material Request'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.material_request.material_request.make_purchase_order",
|
||||
source_doctype: "Material Request",
|
||||
get_query_filters: {
|
||||
material_request_type: "Purchase",
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 99.99],
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
cur_frm.add_custom_button(wn._('From Supplier Quotation'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
|
||||
source_doctype: "Supplier Quotation",
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
@@ -93,14 +119,6 @@ cur_frm.fields_dict['po_details'].grid.get_field('project_name').get_query = fun
|
||||
AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['indent_no'].get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `name` FROM `tabMaterial Request` \
|
||||
WHERE material_request_type="Purchase" and company = "' + doc.company
|
||||
+ '" and `docstatus` = 1 and `status` != "Stopped" \
|
||||
and ifnull(`per_ordered`,0) < 99.99 and %(key)s LIKE "%s" \
|
||||
ORDER BY `name` DESC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'get_last_purchase_rate', '', function(r, rt) {
|
||||
refresh_field(cur_frm.cscript.fname);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-21 16:16:39",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:51:59",
|
||||
"modified": "2013-07-08 15:12:46",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -183,59 +183,6 @@
|
||||
"label": "Re-Calculate Values",
|
||||
"oldfieldtype": "Button"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"description": "You can make a purchase order from multiple Material Requests. Select Material Requests one by one and click on the button below.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "indent_no",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"label": "Select Material Request",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "indent_no",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Material Request",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "get_items",
|
||||
"fieldtype": "Button",
|
||||
"hidden": 0,
|
||||
"label": "Get Items",
|
||||
"no_copy": 0,
|
||||
"oldfieldtype": "Button",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"print_width": "50%",
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"description": "You can make a purchase order from multiple Supplier Quotations. Select Supplier Quotations one by one and click on the button below.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "supplier_quotation",
|
||||
"fieldtype": "Link",
|
||||
"label": "Select Supplier Quotation",
|
||||
"no_copy": 1,
|
||||
"options": "Supplier Quotation",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "get_supplier_quotation_items",
|
||||
"fieldtype": "Button",
|
||||
"label": "Get Items",
|
||||
"options": "get_supplier_quotation_items",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_list_and_currency",
|
||||
@@ -269,7 +216,7 @@
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
"label": "Exchange Rate",
|
||||
"no_copy": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "conversion_rate",
|
||||
"oldfieldtype": "Currency",
|
||||
"print_hide": 1,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:06",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-31 14:26:22",
|
||||
"modified": "2013-07-08 13:51:42",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -32,7 +32,7 @@
|
||||
"hidden": 0,
|
||||
"in_filter": 1,
|
||||
"label": "Reqd By Date",
|
||||
"no_copy": 1,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "schedule_date",
|
||||
"oldfieldtype": "Date",
|
||||
"print_hide": 1,
|
||||
@@ -121,7 +121,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "import_ref_rate",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Ref Rate ",
|
||||
"label": "Price List Rate",
|
||||
"options": "currency",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
|
||||
@@ -29,16 +29,25 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext
|
||||
|
||||
if (this.frm.doc.docstatus === 1) {
|
||||
cur_frm.add_custom_button("Make Purchase Order", this.make_purchase_order);
|
||||
}
|
||||
else if (this.frm.doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(wn._('From Material Request'),
|
||||
function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.material_request.material_request.make_supplier_quotation",
|
||||
source_doctype: "Material Request",
|
||||
get_query_filters: {
|
||||
material_request_type: "Purchase",
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 99.99],
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
get_items: function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "stock.doctype.material_request.material_request.make_supplier_quotation",
|
||||
source_name: cur_frm.doc.indent_no,
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
make_purchase_order: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
|
||||
@@ -62,14 +71,6 @@ cur_frm.fields_dict['quotation_items'].grid.get_field('project_name').get_query
|
||||
order by `tabProject`.name ASC LIMIT 50";
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['indent_no'].get_query = function(doc) {
|
||||
return "select distinct `name` from `tabMaterial Request` \
|
||||
where material_request_type='Purchase' and company = \"" + doc.company +
|
||||
"\" and `docstatus` = 1 and `status` != \"Stopped\" and \
|
||||
ifnull(`per_ordered`,0) < 99.99 and \
|
||||
%(key)s LIKE \"%s\" order by `name` desc limit 50";
|
||||
}
|
||||
|
||||
cur_frm.cscript.supplier_address = function(doc, dt, dn) {
|
||||
if (doc.supplier) {
|
||||
get_server_fields("get_supplier_address", JSON.stringify({supplier: doc.supplier,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-21 16:16:45",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:57:12",
|
||||
"modified": "2013-07-08 15:14:48",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -168,32 +168,6 @@
|
||||
"label": "Re-Calculate Values",
|
||||
"oldfieldtype": "Button"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_14",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"description": "You can make a purchase order from multiple Material Requests. Select Material Requests one by one and click on the button below.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "indent_no",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"label": "Select Material Request",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "indent_no",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Material Request",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "get_items",
|
||||
"fieldtype": "Button",
|
||||
"hidden": 0,
|
||||
"label": "Get Items",
|
||||
"oldfieldtype": "Button"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "currency_price_list",
|
||||
|
||||
Reference in New Issue
Block a user