mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 19:19:17 +00:00
* ci: add prettier to pre-commit
(cherry picked from commit 2c16036ef3)
* style: format js files
---------
Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
@@ -1,31 +1,38 @@
|
||||
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Buying Settings', {
|
||||
frappe.ui.form.on("Buying Settings", {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
|
||||
frappe.tour['Buying Settings'] = [
|
||||
frappe.tour["Buying Settings"] = [
|
||||
{
|
||||
fieldname: "supp_master_name",
|
||||
title: "Supplier Naming By",
|
||||
description: __("By default, the Supplier Name is set as per the Supplier Name entered. If you want Suppliers to be named by a <a href='https://docs.erpnext.com/docs/user/manual/en/setting-up/settings/naming-series' target='_blank'>Naming Series</a> choose the 'Naming Series' option."),
|
||||
description: __(
|
||||
"By default, the Supplier Name is set as per the Supplier Name entered. If you want Suppliers to be named by a <a href='https://docs.erpnext.com/docs/user/manual/en/setting-up/settings/naming-series' target='_blank'>Naming Series</a> choose the 'Naming Series' option."
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldname: "buying_price_list",
|
||||
title: "Default Buying Price List",
|
||||
description: __("Configure the default Price List when creating a new Purchase transaction. Item prices will be fetched from this Price List.")
|
||||
description: __(
|
||||
"Configure the default Price List when creating a new Purchase transaction. Item prices will be fetched from this Price List."
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldname: "po_required",
|
||||
title: "Purchase Order Required for Purchase Invoice & Receipt Creation",
|
||||
description: __("If this option is configured 'Yes', ERPNext will prevent you from creating a Purchase Invoice or Receipt without creating a Purchase Order first. This configuration can be overridden for a particular supplier by enabling the 'Allow Purchase Invoice Creation Without Purchase Order' checkbox in the Supplier master.")
|
||||
description: __(
|
||||
"If this option is configured 'Yes', ERPNext will prevent you from creating a Purchase Invoice or Receipt without creating a Purchase Order first. This configuration can be overridden for a particular supplier by enabling the 'Allow Purchase Invoice Creation Without Purchase Order' checkbox in the Supplier master."
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldname: "pr_required",
|
||||
title: "Purchase Receipt Required for Purchase Invoice Creation",
|
||||
description: __("If this option is configured 'Yes', ERPNext will prevent you from creating a Purchase Invoice without creating a Purchase Receipt first. This configuration can be overridden for a particular supplier by enabling the 'Allow Purchase Invoice Creation Without Purchase Receipt' checkbox in the Supplier master.")
|
||||
}
|
||||
description: __(
|
||||
"If this option is configured 'Yes', ERPNext will prevent you from creating a Purchase Invoice without creating a Purchase Receipt first. This configuration can be overridden for a particular supplier by enabling the 'Allow Purchase Invoice Creation Without Purchase Receipt' checkbox in the Supplier master."
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -9,52 +9,52 @@ erpnext.accounts.taxes.setup_tax_validations("Purchase Order");
|
||||
erpnext.buying.setup_buying_controller();
|
||||
|
||||
frappe.ui.form.on("Purchase Order", {
|
||||
setup: function(frm) {
|
||||
|
||||
setup: function (frm) {
|
||||
if (frm.doc.is_old_subcontracting_flow) {
|
||||
frm.set_query("reserve_warehouse", "supplied_items", function() {
|
||||
frm.set_query("reserve_warehouse", "supplied_items", function () {
|
||||
return {
|
||||
filters: {
|
||||
"company": frm.doc.company,
|
||||
"name": ['!=', frm.doc.supplier_warehouse],
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
company: frm.doc.company,
|
||||
name: ["!=", frm.doc.supplier_warehouse],
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
frm.set_indicator_formatter('item_code',
|
||||
function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
|
||||
|
||||
frm.set_query("expense_account", "items", function() {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_expense_account",
|
||||
filters: {'company': frm.doc.company}
|
||||
}
|
||||
frm.set_indicator_formatter("item_code", function (doc) {
|
||||
return doc.qty <= doc.received_qty ? "green" : "orange";
|
||||
});
|
||||
|
||||
frm.set_query("fg_item", "items", function() {
|
||||
frm.set_query("expense_account", "items", function () {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_expense_account",
|
||||
filters: { company: frm.doc.company },
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("fg_item", "items", function () {
|
||||
return {
|
||||
filters: {
|
||||
'is_stock_item': 1,
|
||||
'is_sub_contracted_item': 1,
|
||||
'default_bom': ['!=', '']
|
||||
}
|
||||
}
|
||||
is_stock_item: 1,
|
||||
is_sub_contracted_item: 1,
|
||||
default_bom: ["!=", ""],
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
company: function(frm) {
|
||||
company: function (frm) {
|
||||
erpnext.accounts.dimensions.update_dimension(frm, frm.doctype);
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.is_old_subcontracting_flow) {
|
||||
frm.trigger('get_materials_from_supplier');
|
||||
refresh: function (frm) {
|
||||
if (frm.doc.is_old_subcontracting_flow) {
|
||||
frm.trigger("get_materials_from_supplier");
|
||||
|
||||
$('a.grey-link').each(function () {
|
||||
var id = $(this).children(':first-child').attr('data-label');
|
||||
if (id == 'Duplicate') {
|
||||
$("a.grey-link").each(function () {
|
||||
var id = $(this).children(":first-child").attr("data-label");
|
||||
if (id == "Duplicate") {
|
||||
$(this).remove();
|
||||
return false;
|
||||
}
|
||||
@@ -62,87 +62,91 @@ frappe.ui.form.on("Purchase Order", {
|
||||
}
|
||||
},
|
||||
|
||||
get_materials_from_supplier: function(frm) {
|
||||
get_materials_from_supplier: function (frm) {
|
||||
let po_details = [];
|
||||
|
||||
if (frm.doc.supplied_items && (flt(frm.doc.per_received, 2) == 100 || frm.doc.status === 'Closed')) {
|
||||
frm.doc.supplied_items.forEach(d => {
|
||||
if (frm.doc.supplied_items && (flt(frm.doc.per_received, 2) == 100 || frm.doc.status === "Closed")) {
|
||||
frm.doc.supplied_items.forEach((d) => {
|
||||
if (d.total_supplied_qty && d.total_supplied_qty != d.consumed_qty) {
|
||||
po_details.push(d.name)
|
||||
po_details.push(d.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (po_details && po_details.length) {
|
||||
frm.add_custom_button(__('Return of Components'), () => {
|
||||
frm.call({
|
||||
method: 'erpnext.controllers.subcontracting_controller.get_materials_from_supplier',
|
||||
freeze: true,
|
||||
freeze_message: __('Creating Stock Entry'),
|
||||
args: {
|
||||
subcontract_order: frm.doc.name,
|
||||
rm_details: po_details,
|
||||
order_doctype: cur_frm.doc.doctype
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r && r.message) {
|
||||
const doc = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, __('Create'));
|
||||
frm.add_custom_button(
|
||||
__("Return of Components"),
|
||||
() => {
|
||||
frm.call({
|
||||
method: "erpnext.controllers.subcontracting_controller.get_materials_from_supplier",
|
||||
freeze: true,
|
||||
freeze_message: __("Creating Stock Entry"),
|
||||
args: {
|
||||
subcontract_order: frm.doc.name,
|
||||
rm_details: po_details,
|
||||
order_doctype: cur_frm.doc.doctype,
|
||||
},
|
||||
callback: function (r) {
|
||||
if (r && r.message) {
|
||||
const doc = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
onload: function (frm) {
|
||||
set_schedule_date(frm);
|
||||
if (!frm.doc.transaction_date){
|
||||
frm.set_value('transaction_date', frappe.datetime.get_today())
|
||||
if (!frm.doc.transaction_date) {
|
||||
frm.set_value("transaction_date", frappe.datetime.get_today());
|
||||
}
|
||||
|
||||
erpnext.queries.setup_queries(frm, "Warehouse", function() {
|
||||
erpnext.queries.setup_queries(frm, "Warehouse", function () {
|
||||
return erpnext.queries.warehouse(frm.doc);
|
||||
});
|
||||
|
||||
// On cancel and amending a purchase order with advance payment, reset advance paid amount
|
||||
if (frm.is_new()) {
|
||||
frm.set_value("advance_paid", 0)
|
||||
frm.set_value("advance_paid", 0);
|
||||
}
|
||||
},
|
||||
|
||||
apply_tds: function(frm) {
|
||||
apply_tds: function (frm) {
|
||||
if (!frm.doc.apply_tds) {
|
||||
frm.set_value("tax_withholding_category", '');
|
||||
frm.set_value("tax_withholding_category", "");
|
||||
} else {
|
||||
frm.set_value("tax_withholding_category", frm.supplier_tds);
|
||||
}
|
||||
},
|
||||
|
||||
get_subcontracting_boms_for_finished_goods: function(fg_item) {
|
||||
get_subcontracting_boms_for_finished_goods: function (fg_item) {
|
||||
return frappe.call({
|
||||
method:"erpnext.subcontracting.doctype.subcontracting_bom.subcontracting_bom.get_subcontracting_boms_for_finished_goods",
|
||||
method: "erpnext.subcontracting.doctype.subcontracting_bom.subcontracting_bom.get_subcontracting_boms_for_finished_goods",
|
||||
args: {
|
||||
fg_items: fg_item
|
||||
fg_items: fg_item,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
get_subcontracting_boms_for_service_item: function(service_item) {
|
||||
get_subcontracting_boms_for_service_item: function (service_item) {
|
||||
return frappe.call({
|
||||
method:"erpnext.subcontracting.doctype.subcontracting_bom.subcontracting_bom.get_subcontracting_boms_for_service_item",
|
||||
method: "erpnext.subcontracting.doctype.subcontracting_bom.subcontracting_bom.get_subcontracting_boms_for_service_item",
|
||||
args: {
|
||||
service_item: service_item
|
||||
service_item: service_item,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Purchase Order Item", {
|
||||
schedule_date: function(frm, cdt, cdn) {
|
||||
schedule_date: function (frm, cdt, cdn) {
|
||||
var row = locals[cdt][cdn];
|
||||
if (row.schedule_date) {
|
||||
if(!frm.doc.schedule_date) {
|
||||
if (!frm.doc.schedule_date) {
|
||||
erpnext.utils.copy_value_in_all_rows(frm.doc, cdt, cdn, "items", "schedule_date");
|
||||
} else {
|
||||
set_schedule_date(frm);
|
||||
@@ -150,12 +154,12 @@ frappe.ui.form.on("Purchase Order Item", {
|
||||
}
|
||||
},
|
||||
|
||||
item_code: async function(frm, cdt, cdn) {
|
||||
item_code: async function (frm, cdt, cdn) {
|
||||
if (frm.doc.is_subcontracted && !frm.doc.is_old_subcontracting_flow) {
|
||||
var row = locals[cdt][cdn];
|
||||
|
||||
if (row.item_code && !row.fg_item) {
|
||||
var result = await frm.events.get_subcontracting_boms_for_service_item(row.item_code)
|
||||
var result = await frm.events.get_subcontracting_boms_for_service_item(row.item_code);
|
||||
|
||||
if (result.message && Object.keys(result.message).length) {
|
||||
var finished_goods = Object.keys(result.message);
|
||||
@@ -175,7 +179,7 @@ frappe.ui.form.on("Purchase Order Item", {
|
||||
fieldtype: "Autocomplete",
|
||||
label: __("Finished Good"),
|
||||
options: finished_goods,
|
||||
}
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Select"),
|
||||
primary_action: () => {
|
||||
@@ -198,16 +202,21 @@ frappe.ui.form.on("Purchase Order Item", {
|
||||
}
|
||||
},
|
||||
|
||||
fg_item: async function(frm, cdt, cdn) {
|
||||
fg_item: async function (frm, cdt, cdn) {
|
||||
if (frm.doc.is_subcontracted && !frm.doc.is_old_subcontracting_flow) {
|
||||
var row = locals[cdt][cdn];
|
||||
|
||||
if (row.fg_item) {
|
||||
var result = await frm.events.get_subcontracting_boms_for_finished_goods(row.fg_item)
|
||||
var result = await frm.events.get_subcontracting_boms_for_finished_goods(row.fg_item);
|
||||
|
||||
if (result.message && Object.keys(result.message).length) {
|
||||
frappe.model.set_value(cdt, cdn, "item_code", result.message.service_item);
|
||||
frappe.model.set_value(cdt, cdn, "qty", flt(row.fg_item_qty) * flt(result.message.conversion_factor));
|
||||
frappe.model.set_value(
|
||||
cdt,
|
||||
cdn,
|
||||
"qty",
|
||||
flt(row.fg_item_qty) * flt(result.message.conversion_factor)
|
||||
);
|
||||
frappe.model.set_value(cdt, cdn, "uom", result.message.service_item_uom);
|
||||
}
|
||||
}
|
||||
@@ -219,25 +228,36 @@ frappe.ui.form.on("Purchase Order Item", {
|
||||
var row = locals[cdt][cdn];
|
||||
|
||||
if (row.fg_item) {
|
||||
var result = await frm.events.get_subcontracting_boms_for_finished_goods(row.fg_item)
|
||||
var result = await frm.events.get_subcontracting_boms_for_finished_goods(row.fg_item);
|
||||
|
||||
if (result.message && row.item_code == result.message.service_item && row.uom == result.message.service_item_uom) {
|
||||
frappe.model.set_value(cdt, cdn, "fg_item_qty", flt(row.qty) / flt(result.message.conversion_factor));
|
||||
if (
|
||||
result.message &&
|
||||
row.item_code == result.message.service_item &&
|
||||
row.uom == result.message.service_item_uom
|
||||
) {
|
||||
frappe.model.set_value(
|
||||
cdt,
|
||||
cdn,
|
||||
"fg_item_qty",
|
||||
flt(row.qty) / flt(result.message.conversion_factor)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends erpnext.buying.BuyingController {
|
||||
erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
||||
erpnext.buying.BuyingController
|
||||
) {
|
||||
setup() {
|
||||
this.frm.custom_make_buttons = {
|
||||
'Purchase Receipt': 'Purchase Receipt',
|
||||
'Purchase Invoice': 'Purchase Invoice',
|
||||
'Payment Entry': 'Payment',
|
||||
'Subcontracting Order': 'Subcontracting Order',
|
||||
'Stock Entry': 'Material to Supplier'
|
||||
}
|
||||
"Purchase Receipt": "Purchase Receipt",
|
||||
"Purchase Invoice": "Purchase Invoice",
|
||||
"Payment Entry": "Payment",
|
||||
"Subcontracting Order": "Subcontracting Order",
|
||||
"Stock Entry": "Material to Supplier",
|
||||
};
|
||||
|
||||
super.setup();
|
||||
}
|
||||
@@ -250,110 +270,155 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
|
||||
for (var i in cur_frm.doc.items) {
|
||||
var item = cur_frm.doc.items[i];
|
||||
if(item.delivered_by_supplier !== 1) {
|
||||
if (item.delivered_by_supplier !== 1) {
|
||||
allow_receipt = true;
|
||||
} else {
|
||||
is_drop_ship = true;
|
||||
}
|
||||
|
||||
if(is_drop_ship && allow_receipt) {
|
||||
if (is_drop_ship && allow_receipt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.frm.set_df_property("drop_ship", "hidden", !is_drop_ship);
|
||||
|
||||
if(doc.docstatus == 1) {
|
||||
if (doc.docstatus == 1) {
|
||||
this.frm.fields_dict.items_section.wrapper.addClass("hide-border");
|
||||
if(!this.frm.doc.set_warehouse) {
|
||||
if (!this.frm.doc.set_warehouse) {
|
||||
this.frm.fields_dict.items_section.wrapper.removeClass("hide-border");
|
||||
}
|
||||
|
||||
if(!in_list(["Closed", "Delivered"], doc.status)) {
|
||||
if(this.frm.doc.status !== 'Closed' && flt(this.frm.doc.per_received, 2) < 100 && flt(this.frm.doc.per_billed, 2) < 100) {
|
||||
if (!in_list(["Closed", "Delivered"], doc.status)) {
|
||||
if (
|
||||
this.frm.doc.status !== "Closed" &&
|
||||
flt(this.frm.doc.per_received, 2) < 100 &&
|
||||
flt(this.frm.doc.per_billed, 2) < 100
|
||||
) {
|
||||
if (!this.frm.doc.__onload || this.frm.doc.__onload.can_update_items) {
|
||||
this.frm.add_custom_button(__('Update Items'), () => {
|
||||
this.frm.add_custom_button(__("Update Items"), () => {
|
||||
erpnext.utils.update_child_items({
|
||||
frm: this.frm,
|
||||
child_docname: "items",
|
||||
child_doctype: "Purchase Order Detail",
|
||||
cannot_add_row: false,
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if (this.frm.has_perm("submit")) {
|
||||
if(flt(doc.per_billed, 2) < 100 || flt(doc.per_received, 2) < 100) {
|
||||
if (flt(doc.per_billed, 2) < 100 || flt(doc.per_received, 2) < 100) {
|
||||
if (doc.status != "On Hold") {
|
||||
this.frm.add_custom_button(__('Hold'), () => this.hold_purchase_order(), __("Status"));
|
||||
} else{
|
||||
this.frm.add_custom_button(__('Resume'), () => this.unhold_purchase_order(), __("Status"));
|
||||
this.frm.add_custom_button(
|
||||
__("Hold"),
|
||||
() => this.hold_purchase_order(),
|
||||
__("Status")
|
||||
);
|
||||
} else {
|
||||
this.frm.add_custom_button(
|
||||
__("Resume"),
|
||||
() => this.unhold_purchase_order(),
|
||||
__("Status")
|
||||
);
|
||||
}
|
||||
this.frm.add_custom_button(__('Close'), () => this.close_purchase_order(), __("Status"));
|
||||
this.frm.add_custom_button(
|
||||
__("Close"),
|
||||
() => this.close_purchase_order(),
|
||||
__("Status")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_drop_ship && doc.status!="Delivered") {
|
||||
this.frm.add_custom_button(__('Delivered'),
|
||||
this.delivered_by_supplier, __("Status"));
|
||||
if (is_drop_ship && doc.status != "Delivered") {
|
||||
this.frm.add_custom_button(__("Delivered"), this.delivered_by_supplier, __("Status"));
|
||||
|
||||
this.frm.page.set_inner_btn_group_as_primary(__("Status"));
|
||||
}
|
||||
} else if(in_list(["Closed", "Delivered"], doc.status)) {
|
||||
} else if (in_list(["Closed", "Delivered"], doc.status)) {
|
||||
if (this.frm.has_perm("submit")) {
|
||||
this.frm.add_custom_button(__('Re-open'), () => this.unclose_purchase_order(), __("Status"));
|
||||
this.frm.add_custom_button(
|
||||
__("Re-open"),
|
||||
() => this.unclose_purchase_order(),
|
||||
__("Status")
|
||||
);
|
||||
}
|
||||
}
|
||||
if(doc.status != "Closed") {
|
||||
if (doc.status != "Closed") {
|
||||
if (doc.status != "On Hold") {
|
||||
if(flt(doc.per_received, 2) < 100 && allow_receipt) {
|
||||
cur_frm.add_custom_button(__('Purchase Receipt'), this.make_purchase_receipt, __('Create'));
|
||||
if (flt(doc.per_received, 2) < 100 && allow_receipt) {
|
||||
cur_frm.add_custom_button(
|
||||
__("Purchase Receipt"),
|
||||
this.make_purchase_receipt,
|
||||
__("Create")
|
||||
);
|
||||
if (doc.is_subcontracted) {
|
||||
if (doc.is_old_subcontracting_flow) {
|
||||
if (me.has_unsupplied_items()) {
|
||||
cur_frm.add_custom_button(__('Material to Supplier'), function() { me.make_stock_entry(); }, __("Transfer"));
|
||||
cur_frm.add_custom_button(
|
||||
__("Material to Supplier"),
|
||||
function () {
|
||||
me.make_stock_entry();
|
||||
},
|
||||
__("Transfer")
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cur_frm.add_custom_button(__('Subcontracting Order'), this.make_subcontracting_order, __('Create'));
|
||||
} else {
|
||||
cur_frm.add_custom_button(
|
||||
__("Subcontracting Order"),
|
||||
this.make_subcontracting_order,
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flt(doc.per_billed, 2) < 100)
|
||||
cur_frm.add_custom_button(__('Purchase Invoice'),
|
||||
this.make_purchase_invoice, __('Create'));
|
||||
if (flt(doc.per_billed, 2) < 100)
|
||||
cur_frm.add_custom_button(
|
||||
__("Purchase Invoice"),
|
||||
this.make_purchase_invoice,
|
||||
__("Create")
|
||||
);
|
||||
|
||||
if(flt(doc.per_billed, 2) < 100 && doc.status != "Delivered") {
|
||||
if (flt(doc.per_billed, 2) < 100 && doc.status != "Delivered") {
|
||||
this.frm.add_custom_button(
|
||||
__('Payment'),
|
||||
__("Payment"),
|
||||
() => this.make_payment_entry(),
|
||||
__('Create')
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
if(flt(doc.per_billed, 2) < 100) {
|
||||
this.frm.add_custom_button(__('Payment Request'),
|
||||
function() { me.make_payment_request() }, __('Create'));
|
||||
if (flt(doc.per_billed, 2) < 100) {
|
||||
this.frm.add_custom_button(
|
||||
__("Payment Request"),
|
||||
function () {
|
||||
me.make_payment_request();
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
if (doc.docstatus === 1 && !doc.inter_company_order_reference) {
|
||||
let me = this;
|
||||
let internal = me.frm.doc.is_internal_supplier;
|
||||
if (internal) {
|
||||
let button_label = (me.frm.doc.company === me.frm.doc.represents_company) ? "Internal Sales Order" :
|
||||
"Inter Company Sales Order";
|
||||
let button_label =
|
||||
me.frm.doc.company === me.frm.doc.represents_company
|
||||
? "Internal Sales Order"
|
||||
: "Inter Company Sales Order";
|
||||
|
||||
me.frm.add_custom_button(button_label, function() {
|
||||
me.make_inter_company_order(me.frm);
|
||||
}, __('Create'));
|
||||
me.frm.add_custom_button(
|
||||
button_label,
|
||||
function () {
|
||||
me.make_inter_company_order(me.frm);
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||
cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||
}
|
||||
} else if(doc.docstatus===0) {
|
||||
} else if (doc.docstatus === 0) {
|
||||
cur_frm.cscript.add_from_mappers();
|
||||
}
|
||||
}
|
||||
@@ -362,19 +427,20 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order_based_on_supplier",
|
||||
args: {
|
||||
supplier: this.frm.doc.supplier
|
||||
supplier: this.frm.doc.supplier,
|
||||
},
|
||||
source_doctype: "Material Request",
|
||||
source_name: this.frm.doc.supplier,
|
||||
target: this.frm,
|
||||
setters: {
|
||||
company: this.frm.doc.company
|
||||
company: this.frm.doc.company,
|
||||
},
|
||||
get_query_filters: {
|
||||
docstatus: ["!=", 2],
|
||||
supplier: this.frm.doc.supplier
|
||||
supplier: this.frm.doc.supplier,
|
||||
},
|
||||
get_query_method: "erpnext.stock.doctype.material_request.material_request.get_material_requests_based_on_supplier"
|
||||
get_query_method:
|
||||
"erpnext.stock.doctype.material_request.material_request.get_material_requests_based_on_supplier",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -383,27 +449,27 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
}
|
||||
|
||||
has_unsupplied_items() {
|
||||
return this.frm.doc['supplied_items'].some(item => item.required_qty > item.supplied_qty);
|
||||
return this.frm.doc["supplied_items"].some((item) => item.required_qty > item.supplied_qty);
|
||||
}
|
||||
|
||||
make_stock_entry() {
|
||||
frappe.call({
|
||||
method:"erpnext.controllers.subcontracting_controller.make_rm_stock_entry",
|
||||
method: "erpnext.controllers.subcontracting_controller.make_rm_stock_entry",
|
||||
args: {
|
||||
subcontract_order: cur_frm.doc.name,
|
||||
order_doctype: cur_frm.doc.doctype
|
||||
order_doctype: cur_frm.doc.doctype,
|
||||
},
|
||||
callback: function(r) {
|
||||
callback: function (r) {
|
||||
var doclist = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
make_inter_company_order(frm) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_inter_company_sales_order",
|
||||
frm: frm
|
||||
frm: frm,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -411,134 +477,163 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||
frm: cur_frm,
|
||||
freeze_message: __("Creating Purchase Receipt ...")
|
||||
})
|
||||
freeze_message: __("Creating Purchase Receipt ..."),
|
||||
});
|
||||
}
|
||||
|
||||
make_purchase_invoice() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
||||
frm: cur_frm
|
||||
})
|
||||
frm: cur_frm,
|
||||
});
|
||||
}
|
||||
|
||||
make_subcontracting_order() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_subcontracting_order",
|
||||
frm: cur_frm,
|
||||
freeze_message: __("Creating Subcontracting Order ...")
|
||||
})
|
||||
freeze_message: __("Creating Subcontracting Order ..."),
|
||||
});
|
||||
}
|
||||
|
||||
add_from_mappers() {
|
||||
var me = this;
|
||||
this.frm.add_custom_button(__('Material Request'),
|
||||
function() {
|
||||
this.frm.add_custom_button(
|
||||
__("Material Request"),
|
||||
function () {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order",
|
||||
source_doctype: "Material Request",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
schedule_date: undefined,
|
||||
status: undefined
|
||||
status: undefined,
|
||||
},
|
||||
get_query_filters: {
|
||||
material_request_type: "Purchase",
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 100],
|
||||
company: me.frm.doc.company
|
||||
company: me.frm.doc.company,
|
||||
},
|
||||
allow_child_item_selection: true,
|
||||
child_fieldname: "items",
|
||||
child_columns: ["item_code", "qty", "ordered_qty"]
|
||||
})
|
||||
}, __("Get Items From"));
|
||||
child_columns: ["item_code", "qty", "ordered_qty"],
|
||||
});
|
||||
},
|
||||
__("Get Items From")
|
||||
);
|
||||
|
||||
this.frm.add_custom_button(__('Supplier Quotation'),
|
||||
function() {
|
||||
this.frm.add_custom_button(
|
||||
__("Supplier Quotation"),
|
||||
function () {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
|
||||
source_doctype: "Supplier Quotation",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
supplier: me.frm.doc.supplier,
|
||||
valid_till: undefined
|
||||
valid_till: undefined,
|
||||
},
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
status: ["not in", ["Stopped", "Expired"]],
|
||||
}
|
||||
})
|
||||
}, __("Get Items From"));
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Get Items From")
|
||||
);
|
||||
|
||||
this.frm.add_custom_button(__('Update Rate as per Last Purchase'),
|
||||
function() {
|
||||
this.frm.add_custom_button(
|
||||
__("Update Rate as per Last Purchase"),
|
||||
function () {
|
||||
frappe.call({
|
||||
"method": "get_last_purchase_rate",
|
||||
"doc": me.frm.doc,
|
||||
callback: function(r, rt) {
|
||||
method: "get_last_purchase_rate",
|
||||
doc: me.frm.doc,
|
||||
callback: function (r, rt) {
|
||||
me.frm.dirty();
|
||||
me.frm.cscript.calculate_taxes_and_totals();
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Tools")
|
||||
);
|
||||
|
||||
this.frm.add_custom_button(
|
||||
__("Link to Material Request"),
|
||||
function () {
|
||||
var my_items = [];
|
||||
for (var i in me.frm.doc.items) {
|
||||
if (!me.frm.doc.items[i].material_request) {
|
||||
my_items.push(me.frm.doc.items[i].item_code);
|
||||
}
|
||||
})
|
||||
}, __("Tools"));
|
||||
|
||||
this.frm.add_custom_button(__('Link to Material Request'),
|
||||
function() {
|
||||
var my_items = [];
|
||||
for (var i in me.frm.doc.items) {
|
||||
if(!me.frm.doc.items[i].material_request){
|
||||
my_items.push(me.frm.doc.items[i].item_code);
|
||||
}
|
||||
}
|
||||
frappe.call({
|
||||
method: "erpnext.buying.utils.get_linked_material_requests",
|
||||
args:{
|
||||
items: my_items
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.exc) return;
|
||||
frappe.call({
|
||||
method: "erpnext.buying.utils.get_linked_material_requests",
|
||||
args: {
|
||||
items: my_items,
|
||||
},
|
||||
callback: function (r) {
|
||||
if (r.exc) return;
|
||||
|
||||
var i = 0;
|
||||
var item_length = me.frm.doc.items.length;
|
||||
while (i < item_length) {
|
||||
var qty = me.frm.doc.items[i].qty;
|
||||
(r.message[0] || []).forEach(function(d) {
|
||||
if (d.qty > 0 && qty > 0 && me.frm.doc.items[i].item_code == d.item_code && !me.frm.doc.items[i].material_request_item)
|
||||
{
|
||||
me.frm.doc.items[i].material_request = d.mr_name;
|
||||
me.frm.doc.items[i].material_request_item = d.mr_item;
|
||||
var my_qty = Math.min(qty, d.qty);
|
||||
qty = qty - my_qty;
|
||||
d.qty = d.qty - my_qty;
|
||||
me.frm.doc.items[i].stock_qty = my_qty * me.frm.doc.items[i].conversion_factor;
|
||||
me.frm.doc.items[i].qty = my_qty;
|
||||
var i = 0;
|
||||
var item_length = me.frm.doc.items.length;
|
||||
while (i < item_length) {
|
||||
var qty = me.frm.doc.items[i].qty;
|
||||
(r.message[0] || []).forEach(function (d) {
|
||||
if (
|
||||
d.qty > 0 &&
|
||||
qty > 0 &&
|
||||
me.frm.doc.items[i].item_code == d.item_code &&
|
||||
!me.frm.doc.items[i].material_request_item
|
||||
) {
|
||||
me.frm.doc.items[i].material_request = d.mr_name;
|
||||
me.frm.doc.items[i].material_request_item = d.mr_item;
|
||||
var my_qty = Math.min(qty, d.qty);
|
||||
qty = qty - my_qty;
|
||||
d.qty = d.qty - my_qty;
|
||||
me.frm.doc.items[i].stock_qty =
|
||||
my_qty * me.frm.doc.items[i].conversion_factor;
|
||||
me.frm.doc.items[i].qty = my_qty;
|
||||
|
||||
frappe.msgprint("Assigning " + d.mr_name + " to " + d.item_code + " (row " + me.frm.doc.items[i].idx + ")");
|
||||
if (qty > 0) {
|
||||
frappe.msgprint("Splitting " + qty + " units of " + d.item_code);
|
||||
var new_row = frappe.model.add_child(me.frm.doc, me.frm.doc.items[i].doctype, "items");
|
||||
item_length++;
|
||||
frappe.msgprint(
|
||||
"Assigning " +
|
||||
d.mr_name +
|
||||
" to " +
|
||||
d.item_code +
|
||||
" (row " +
|
||||
me.frm.doc.items[i].idx +
|
||||
")"
|
||||
);
|
||||
if (qty > 0) {
|
||||
frappe.msgprint("Splitting " + qty + " units of " + d.item_code);
|
||||
var new_row = frappe.model.add_child(
|
||||
me.frm.doc,
|
||||
me.frm.doc.items[i].doctype,
|
||||
"items"
|
||||
);
|
||||
item_length++;
|
||||
|
||||
for (var key in me.frm.doc.items[i]) {
|
||||
new_row[key] = me.frm.doc.items[i][key];
|
||||
for (var key in me.frm.doc.items[i]) {
|
||||
new_row[key] = me.frm.doc.items[i][key];
|
||||
}
|
||||
|
||||
new_row.idx = item_length;
|
||||
new_row["stock_qty"] = new_row.conversion_factor * qty;
|
||||
new_row["qty"] = qty;
|
||||
new_row["material_request"] = "";
|
||||
new_row["material_request_item"] = "";
|
||||
}
|
||||
|
||||
new_row.idx = item_length;
|
||||
new_row["stock_qty"] = new_row.conversion_factor * qty;
|
||||
new_row["qty"] = qty;
|
||||
new_row["material_request"] = "";
|
||||
new_row["material_request_item"] = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
i++;
|
||||
}
|
||||
refresh_field("items");
|
||||
}
|
||||
});
|
||||
}, __("Tools"));
|
||||
});
|
||||
i++;
|
||||
}
|
||||
refresh_field("items");
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Tools")
|
||||
);
|
||||
}
|
||||
|
||||
tc_name() {
|
||||
@@ -547,7 +642,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
|
||||
items_add(doc, cdt, cdn) {
|
||||
var row = frappe.get_doc(cdt, cdn);
|
||||
if(doc.schedule_date) {
|
||||
if (doc.schedule_date) {
|
||||
row.schedule_date = doc.schedule_date;
|
||||
refresh_field("schedule_date", cdn, "items");
|
||||
} else {
|
||||
@@ -555,24 +650,24 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
}
|
||||
}
|
||||
|
||||
unhold_purchase_order(){
|
||||
cur_frm.cscript.update_status("Resume", "Draft")
|
||||
unhold_purchase_order() {
|
||||
cur_frm.cscript.update_status("Resume", "Draft");
|
||||
}
|
||||
|
||||
hold_purchase_order(){
|
||||
hold_purchase_order() {
|
||||
var me = this;
|
||||
var d = new frappe.ui.Dialog({
|
||||
title: __('Reason for Hold'),
|
||||
title: __("Reason for Hold"),
|
||||
fields: [
|
||||
{
|
||||
"fieldname": "reason_for_hold",
|
||||
"fieldtype": "Text",
|
||||
"reqd": 1,
|
||||
}
|
||||
fieldname: "reason_for_hold",
|
||||
fieldtype: "Text",
|
||||
reqd: 1,
|
||||
},
|
||||
],
|
||||
primary_action: function() {
|
||||
primary_action: function () {
|
||||
var data = d.get_values();
|
||||
let reason_for_hold = 'Reason for hold: ' + data.reason_for_hold;
|
||||
let reason_for_hold = "Reason for hold: " + data.reason_for_hold;
|
||||
|
||||
frappe.call({
|
||||
method: "frappe.desk.form.utils.add_comment",
|
||||
@@ -581,30 +676,30 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
reference_name: me.frm.docname,
|
||||
content: __(reason_for_hold),
|
||||
comment_email: frappe.session.user,
|
||||
comment_by: frappe.session.user_fullname
|
||||
comment_by: frappe.session.user_fullname,
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
me.update_status('Hold', 'On Hold')
|
||||
callback: function (r) {
|
||||
if (!r.exc) {
|
||||
me.update_status("Hold", "On Hold");
|
||||
d.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
|
||||
unclose_purchase_order(){
|
||||
cur_frm.cscript.update_status('Re-open', 'Submitted')
|
||||
unclose_purchase_order() {
|
||||
cur_frm.cscript.update_status("Re-open", "Submitted");
|
||||
}
|
||||
|
||||
close_purchase_order(){
|
||||
cur_frm.cscript.update_status('Close', 'Closed')
|
||||
close_purchase_order() {
|
||||
cur_frm.cscript.update_status("Close", "Closed");
|
||||
}
|
||||
|
||||
delivered_by_supplier(){
|
||||
cur_frm.cscript.update_status('Deliver', 'Delivered')
|
||||
delivered_by_supplier() {
|
||||
cur_frm.cscript.update_status("Deliver", "Delivered");
|
||||
}
|
||||
|
||||
items_on_form_rendered() {
|
||||
@@ -617,51 +712,55 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e
|
||||
};
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
extend_cscript(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({frm: cur_frm}));
|
||||
extend_cscript(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({ frm: cur_frm }));
|
||||
|
||||
cur_frm.cscript.update_status= function(label, status){
|
||||
cur_frm.cscript.update_status = function (label, status) {
|
||||
frappe.call({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.update_status",
|
||||
args: {status: status, name: cur_frm.doc.name},
|
||||
callback: function(r) {
|
||||
args: { status: status, name: cur_frm.doc.name },
|
||||
callback: function (r) {
|
||||
cur_frm.set_value("status", status);
|
||||
cur_frm.reload_doc();
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, cdt, cdn) {
|
||||
cur_frm.fields_dict["items"].grid.get_field("project").get_query = function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters:[
|
||||
['Project', 'status', 'not in', 'Completed, Cancelled']
|
||||
]
|
||||
}
|
||||
}
|
||||
filters: [["Project", "status", "not in", "Completed, Cancelled"]],
|
||||
};
|
||||
};
|
||||
|
||||
if (cur_frm.doc.is_old_subcontracting_flow) {
|
||||
cur_frm.fields_dict['items'].grid.get_field('bom').get_query = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn]
|
||||
cur_frm.fields_dict["items"].grid.get_field("bom").get_query = function (doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
return {
|
||||
filters: [
|
||||
['BOM', 'item', '=', d.item_code],
|
||||
['BOM', 'is_active', '=', '1'],
|
||||
['BOM', 'docstatus', '=', '1'],
|
||||
['BOM', 'company', '=', doc.company]
|
||||
]
|
||||
}
|
||||
}
|
||||
["BOM", "item", "=", d.item_code],
|
||||
["BOM", "is_active", "=", "1"],
|
||||
["BOM", "docstatus", "=", "1"],
|
||||
["BOM", "company", "=", doc.company],
|
||||
],
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function set_schedule_date(frm) {
|
||||
if(frm.doc.schedule_date){
|
||||
erpnext.utils.copy_value_in_all_rows(frm.doc, frm.doc.doctype, frm.doc.name, "items", "schedule_date");
|
||||
if (frm.doc.schedule_date) {
|
||||
erpnext.utils.copy_value_in_all_rows(
|
||||
frm.doc,
|
||||
frm.doc.doctype,
|
||||
frm.doc.name,
|
||||
"items",
|
||||
"schedule_date"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
frappe.provide("erpnext.buying");
|
||||
|
||||
frappe.ui.form.on("Purchase Order", "is_subcontracted", function(frm) {
|
||||
frappe.ui.form.on("Purchase Order", "is_subcontracted", function (frm) {
|
||||
if (frm.doc.is_old_subcontracting_flow) {
|
||||
erpnext.buying.get_default_bom(frm);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
frappe.listview_settings['Purchase Order'] = {
|
||||
add_fields: ["base_grand_total", "company", "currency", "supplier",
|
||||
"supplier_name", "per_received", "per_billed", "status"],
|
||||
frappe.listview_settings["Purchase Order"] = {
|
||||
add_fields: [
|
||||
"base_grand_total",
|
||||
"company",
|
||||
"currency",
|
||||
"supplier",
|
||||
"supplier_name",
|
||||
"per_received",
|
||||
"per_billed",
|
||||
"status",
|
||||
],
|
||||
get_indicator: function (doc) {
|
||||
if (doc.status === "Closed") {
|
||||
return [__("Closed"), "green", "status,=,Closed"];
|
||||
@@ -10,15 +18,25 @@ frappe.listview_settings['Purchase Order'] = {
|
||||
return [__("Delivered"), "green", "status,=,Closed"];
|
||||
} else if (flt(doc.per_received, 2) < 100 && doc.status !== "Closed") {
|
||||
if (flt(doc.per_billed, 2) < 100) {
|
||||
return [__("To Receive and Bill"), "orange",
|
||||
"per_received,<,100|per_billed,<,100|status,!=,Closed"];
|
||||
return [
|
||||
__("To Receive and Bill"),
|
||||
"orange",
|
||||
"per_received,<,100|per_billed,<,100|status,!=,Closed",
|
||||
];
|
||||
} else {
|
||||
return [__("To Receive"), "orange",
|
||||
"per_received,<,100|per_billed,=,100|status,!=,Closed"];
|
||||
return [__("To Receive"), "orange", "per_received,<,100|per_billed,=,100|status,!=,Closed"];
|
||||
}
|
||||
} else if (flt(doc.per_received, 2) >= 100 && flt(doc.per_billed, 2) < 100 && doc.status !== "Closed") {
|
||||
} else if (
|
||||
flt(doc.per_received, 2) >= 100 &&
|
||||
flt(doc.per_billed, 2) < 100 &&
|
||||
doc.status !== "Closed"
|
||||
) {
|
||||
return [__("To Bill"), "orange", "per_received,=,100|per_billed,<,100|status,!=,Closed"];
|
||||
} else if (flt(doc.per_received, 2) >= 100 && flt(doc.per_billed, 2) == 100 && doc.status !== "Closed") {
|
||||
} else if (
|
||||
flt(doc.per_received, 2) >= 100 &&
|
||||
flt(doc.per_billed, 2) == 100 &&
|
||||
doc.status !== "Closed"
|
||||
) {
|
||||
return [__("Completed"), "green", "per_received,=,100|per_billed,=,100|status,!=,Closed"];
|
||||
}
|
||||
},
|
||||
@@ -26,25 +44,23 @@ frappe.listview_settings['Purchase Order'] = {
|
||||
var method = "erpnext.buying.doctype.purchase_order.purchase_order.close_or_unclose_purchase_orders";
|
||||
|
||||
listview.page.add_menu_item(__("Close"), function () {
|
||||
listview.call_for_selected_items(method, { "status": "Closed" });
|
||||
listview.call_for_selected_items(method, { status: "Closed" });
|
||||
});
|
||||
|
||||
listview.page.add_menu_item(__("Reopen"), function () {
|
||||
listview.call_for_selected_items(method, { "status": "Submitted" });
|
||||
listview.call_for_selected_items(method, { status: "Submitted" });
|
||||
});
|
||||
|
||||
|
||||
listview.page.add_action_item(__("Purchase Invoice"), ()=>{
|
||||
listview.page.add_action_item(__("Purchase Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Purchase Invoice");
|
||||
});
|
||||
|
||||
listview.page.add_action_item(__("Purchase Receipt"), ()=>{
|
||||
listview.page.add_action_item(__("Purchase Receipt"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Purchase Receipt");
|
||||
});
|
||||
|
||||
listview.page.add_action_item(__("Advance Payment"), ()=>{
|
||||
listview.page.add_action_item(__("Advance Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Payment Entry");
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,60 +1,70 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
cur_frm.add_fetch('contact', 'email_id', 'email_id')
|
||||
cur_frm.add_fetch("contact", "email_id", "email_id");
|
||||
|
||||
erpnext.buying.setup_buying_controller();
|
||||
|
||||
frappe.ui.form.on("Request for Quotation",{
|
||||
setup: function(frm) {
|
||||
frappe.ui.form.on("Request for Quotation", {
|
||||
setup: function (frm) {
|
||||
frm.custom_make_buttons = {
|
||||
'Supplier Quotation': 'Create'
|
||||
}
|
||||
"Supplier Quotation": "Create",
|
||||
};
|
||||
|
||||
frm.fields_dict["suppliers"].grid.get_field("contact").get_query = function(doc, cdt, cdn) {
|
||||
frm.fields_dict["suppliers"].grid.get_field("contact").get_query = function (doc, cdt, cdn) {
|
||||
let d = locals[cdt][cdn];
|
||||
return {
|
||||
query: "frappe.contacts.doctype.contact.contact.contact_query",
|
||||
filters: {
|
||||
link_doctype: "Supplier",
|
||||
link_name: d.supplier || ""
|
||||
}
|
||||
link_name: d.supplier || "",
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
frm.set_query('warehouse', 'items', () => ({
|
||||
frm.set_query("warehouse", "items", () => ({
|
||||
filters: {
|
||||
company: frm.doc.company,
|
||||
is_group: 0
|
||||
}
|
||||
is_group: 0,
|
||||
},
|
||||
}));
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
if(!frm.doc.message_for_supplier) {
|
||||
frm.set_value("message_for_supplier", __("Please supply the specified items at the best possible rates"))
|
||||
onload: function (frm) {
|
||||
if (!frm.doc.message_for_supplier) {
|
||||
frm.set_value(
|
||||
"message_for_supplier",
|
||||
__("Please supply the specified items at the best possible rates")
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function(frm, cdt, cdn) {
|
||||
refresh: function (frm, cdt, cdn) {
|
||||
if (frm.doc.docstatus === 1) {
|
||||
frm.add_custom_button(
|
||||
__("Supplier Quotation"),
|
||||
function () {
|
||||
frm.trigger("make_supplier_quotation");
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
|
||||
frm.add_custom_button(__('Supplier Quotation'),
|
||||
function(){ frm.trigger("make_supplier_quotation") }, __("Create"));
|
||||
|
||||
|
||||
frm.add_custom_button(__("Send Emails to Suppliers"), function() {
|
||||
frappe.call({
|
||||
method: 'erpnext.buying.doctype.request_for_quotation.request_for_quotation.send_supplier_emails',
|
||||
freeze: true,
|
||||
args: {
|
||||
rfq_name: frm.doc.name
|
||||
},
|
||||
callback: function(r){
|
||||
frm.reload_doc();
|
||||
}
|
||||
});
|
||||
}, __("Tools"));
|
||||
frm.add_custom_button(
|
||||
__("Send Emails to Suppliers"),
|
||||
function () {
|
||||
frappe.call({
|
||||
method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.send_supplier_emails",
|
||||
freeze: true,
|
||||
args: {
|
||||
rfq_name: frm.doc.name,
|
||||
},
|
||||
callback: function (r) {
|
||||
frm.reload_doc();
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Tools")
|
||||
);
|
||||
|
||||
frm.add_custom_button(
|
||||
__("Download PDF"),
|
||||
@@ -122,13 +132,13 @@ frappe.ui.form.on("Request for Quotation",{
|
||||
var w = window.open(
|
||||
frappe.urllib.get_full_url(
|
||||
"/api/method/erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_pdf?" +
|
||||
new URLSearchParams({
|
||||
name: frm.doc.name,
|
||||
supplier: data.supplier,
|
||||
print_format: data.print_format || "Standard",
|
||||
language: data.language || frappe.boot.lang,
|
||||
letterhead: data.letter_head || frm.doc.letter_head || "",
|
||||
}).toString()
|
||||
new URLSearchParams({
|
||||
name: frm.doc.name,
|
||||
supplier: data.supplier,
|
||||
print_format: data.print_format || "Standard",
|
||||
language: data.language || frappe.boot.lang,
|
||||
letterhead: data.letter_head || frm.doc.letter_head || "",
|
||||
}).toString()
|
||||
)
|
||||
);
|
||||
if (!w) {
|
||||
@@ -147,101 +157,109 @@ frappe.ui.form.on("Request for Quotation",{
|
||||
}
|
||||
},
|
||||
|
||||
make_supplier_quotation: function(frm) {
|
||||
make_supplier_quotation: function (frm) {
|
||||
var doc = frm.doc;
|
||||
var dialog = new frappe.ui.Dialog({
|
||||
title: __("Create Supplier Quotation"),
|
||||
fields: [
|
||||
{ "fieldtype": "Link",
|
||||
"label": __("Supplier"),
|
||||
"fieldname": "supplier",
|
||||
"options": 'Supplier',
|
||||
"reqd": 1,
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: __("Supplier"),
|
||||
fieldname: "supplier",
|
||||
options: "Supplier",
|
||||
reqd: 1,
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: [
|
||||
["Supplier", "name", "in", frm.doc.suppliers.map((row) => {return row.supplier;})]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
[
|
||||
"Supplier",
|
||||
"name",
|
||||
"in",
|
||||
frm.doc.suppliers.map((row) => {
|
||||
return row.supplier;
|
||||
}),
|
||||
],
|
||||
],
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Create"),
|
||||
primary_action: (args) => {
|
||||
if(!args) return;
|
||||
if (!args) return;
|
||||
dialog.hide();
|
||||
|
||||
return frappe.call({
|
||||
type: "GET",
|
||||
method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.make_supplier_quotation_from_rfq",
|
||||
args: {
|
||||
"source_name": doc.name,
|
||||
"for_supplier": args.supplier
|
||||
source_name: doc.name,
|
||||
for_supplier: args.supplier,
|
||||
},
|
||||
freeze: true,
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
callback: function (r) {
|
||||
if (!r.exc) {
|
||||
var doc = frappe.model.sync(r.message);
|
||||
frappe.set_route("Form", r.message.doctype, r.message.name);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
dialog.show()
|
||||
dialog.show();
|
||||
},
|
||||
|
||||
schedule_date(frm) {
|
||||
if(frm.doc.schedule_date){
|
||||
if (frm.doc.schedule_date) {
|
||||
frm.doc.items.forEach((item) => {
|
||||
item.schedule_date = frm.doc.schedule_date;
|
||||
})
|
||||
});
|
||||
}
|
||||
refresh_field("items");
|
||||
},
|
||||
preview: (frm) => {
|
||||
let dialog = new frappe.ui.Dialog({
|
||||
title: __('Preview Email'),
|
||||
title: __("Preview Email"),
|
||||
fields: [
|
||||
{
|
||||
label: __('Supplier'),
|
||||
fieldtype: 'Select',
|
||||
fieldname: 'supplier',
|
||||
options: frm.doc.suppliers.map(row => row.supplier),
|
||||
reqd: 1
|
||||
label: __("Supplier"),
|
||||
fieldtype: "Select",
|
||||
fieldname: "supplier",
|
||||
options: frm.doc.suppliers.map((row) => row.supplier),
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: 'Column Break',
|
||||
fieldname: 'col_break_1',
|
||||
fieldtype: "Column Break",
|
||||
fieldname: "col_break_1",
|
||||
},
|
||||
{
|
||||
label: __('Subject'),
|
||||
fieldtype: 'Data',
|
||||
fieldname: 'subject',
|
||||
label: __("Subject"),
|
||||
fieldtype: "Data",
|
||||
fieldname: "subject",
|
||||
read_only: 1,
|
||||
depends_on: 'subject'
|
||||
depends_on: "subject",
|
||||
},
|
||||
{
|
||||
fieldtype: 'Section Break',
|
||||
fieldname: 'sec_break_1',
|
||||
hide_border: 1
|
||||
fieldtype: "Section Break",
|
||||
fieldname: "sec_break_1",
|
||||
hide_border: 1,
|
||||
},
|
||||
{
|
||||
label: __('Email'),
|
||||
fieldtype: 'HTML',
|
||||
fieldname: 'email_preview'
|
||||
label: __("Email"),
|
||||
fieldtype: "HTML",
|
||||
fieldname: "email_preview",
|
||||
},
|
||||
{
|
||||
fieldtype: 'Section Break',
|
||||
fieldname: 'sec_break_2'
|
||||
fieldtype: "Section Break",
|
||||
fieldname: "sec_break_2",
|
||||
},
|
||||
{
|
||||
label: __('Note'),
|
||||
fieldtype: 'HTML',
|
||||
fieldname: 'note'
|
||||
}
|
||||
]
|
||||
label: __("Note"),
|
||||
fieldtype: "HTML",
|
||||
fieldname: "note",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
dialog.fields_dict["supplier"].df.onchange = () => {
|
||||
@@ -249,74 +267,78 @@ frappe.ui.form.on("Request for Quotation",{
|
||||
supplier: dialog.get_value("supplier"),
|
||||
}).then(({ message }) => {
|
||||
dialog.fields_dict.email_preview.$wrapper.empty();
|
||||
dialog.fields_dict.email_preview.$wrapper.append(
|
||||
message.message
|
||||
);
|
||||
dialog.fields_dict.email_preview.$wrapper.append(message.message);
|
||||
dialog.set_value("subject", message.subject);
|
||||
});
|
||||
};
|
||||
|
||||
dialog.fields_dict.note.$wrapper.append(`<p class="small text-muted">This is a preview of the email to be sent. A PDF of the document will
|
||||
dialog.fields_dict.note.$wrapper
|
||||
.append(`<p class="small text-muted">This is a preview of the email to be sent. A PDF of the document will
|
||||
automatically be attached with the email.</p>`);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
frappe.ui.form.on("Request for Quotation Item", {
|
||||
items_add(frm, cdt, cdn) {
|
||||
if (frm.doc.schedule_date) {
|
||||
frappe.model.set_value(cdt, cdn, 'schedule_date', frm.doc.schedule_date);
|
||||
frappe.model.set_value(cdt, cdn, "schedule_date", frm.doc.schedule_date);
|
||||
}
|
||||
}
|
||||
});
|
||||
frappe.ui.form.on("Request for Quotation Supplier",{
|
||||
supplier: function(frm, cdt, cdn) {
|
||||
var d = locals[cdt][cdn]
|
||||
frappe.call({
|
||||
method:"erpnext.accounts.party.get_party_details",
|
||||
args:{
|
||||
party: d.supplier,
|
||||
party_type: 'Supplier'
|
||||
},
|
||||
callback: function(r){
|
||||
if(r.message){
|
||||
frappe.model.set_value(cdt, cdn, 'contact', r.message.contact_person)
|
||||
frappe.model.set_value(cdt, cdn, 'email_id', r.message.contact_email)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
frappe.ui.form.on("Request for Quotation Supplier", {
|
||||
supplier: function (frm, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
frappe.call({
|
||||
method: "erpnext.accounts.party.get_party_details",
|
||||
args: {
|
||||
party: d.supplier,
|
||||
party_type: "Supplier",
|
||||
},
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
frappe.model.set_value(cdt, cdn, "contact", r.message.contact_person);
|
||||
frappe.model.set_value(cdt, cdn, "email_id", r.message.contact_email);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
erpnext.buying.RequestforQuotationController = class RequestforQuotationController extends erpnext.buying.BuyingController {
|
||||
erpnext.buying.RequestforQuotationController = class RequestforQuotationController extends (
|
||||
erpnext.buying.BuyingController
|
||||
) {
|
||||
refresh() {
|
||||
var me = this;
|
||||
super.refresh();
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
this.frm.add_custom_button(__('Material Request'),
|
||||
function() {
|
||||
if (this.frm.doc.docstatus === 0) {
|
||||
this.frm.add_custom_button(
|
||||
__("Material Request"),
|
||||
function () {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_request_for_quotation",
|
||||
source_doctype: "Material Request",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
schedule_date: undefined,
|
||||
status: undefined
|
||||
status: undefined,
|
||||
},
|
||||
get_query_filters: {
|
||||
material_request_type: "Purchase",
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 100],
|
||||
company: me.frm.doc.company
|
||||
}
|
||||
})
|
||||
}, __("Get Items From"));
|
||||
company: me.frm.doc.company,
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Get Items From")
|
||||
);
|
||||
|
||||
// Get items from Opportunity
|
||||
this.frm.add_custom_button(__('Opportunity'),
|
||||
function() {
|
||||
this.frm.add_custom_button(
|
||||
__("Opportunity"),
|
||||
function () {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_request_for_quotation",
|
||||
source_doctype: "Opportunity",
|
||||
@@ -324,67 +346,79 @@ erpnext.buying.RequestforQuotationController = class RequestforQuotationControll
|
||||
setters: {
|
||||
party_name: undefined,
|
||||
opportunity_from: undefined,
|
||||
status: undefined
|
||||
status: undefined,
|
||||
},
|
||||
get_query_filters: {
|
||||
status: ["not in", ["Closed", "Lost"]],
|
||||
company: me.frm.doc.company
|
||||
}
|
||||
})
|
||||
}, __("Get Items From"));
|
||||
company: me.frm.doc.company,
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Get Items From")
|
||||
);
|
||||
|
||||
// Get items from open Material Requests based on supplier
|
||||
this.frm.add_custom_button(__('Possible Supplier'), function() {
|
||||
// Create a dialog window for the user to pick their supplier
|
||||
var dialog = new frappe.ui.Dialog({
|
||||
title: __('Select Possible Supplier'),
|
||||
fields: [
|
||||
{
|
||||
fieldname: 'supplier',
|
||||
fieldtype:'Link',
|
||||
options:'Supplier',
|
||||
label:'Supplier',
|
||||
reqd:1,
|
||||
description: __("Get Items from Material Requests against this Supplier")
|
||||
}
|
||||
],
|
||||
primary_action_label: __("Get Items"),
|
||||
primary_action: (args) => {
|
||||
if(!args) return;
|
||||
dialog.hide();
|
||||
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_item_from_material_requests_based_on_supplier",
|
||||
source_name: args.supplier,
|
||||
target: me.frm,
|
||||
setters: {
|
||||
company: me.frm.doc.company
|
||||
this.frm.add_custom_button(
|
||||
__("Possible Supplier"),
|
||||
function () {
|
||||
// Create a dialog window for the user to pick their supplier
|
||||
var dialog = new frappe.ui.Dialog({
|
||||
title: __("Select Possible Supplier"),
|
||||
fields: [
|
||||
{
|
||||
fieldname: "supplier",
|
||||
fieldtype: "Link",
|
||||
options: "Supplier",
|
||||
label: "Supplier",
|
||||
reqd: 1,
|
||||
description: __("Get Items from Material Requests against this Supplier"),
|
||||
},
|
||||
get_query_filters: {
|
||||
material_request_type: "Purchase",
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 100]
|
||||
}
|
||||
});
|
||||
dialog.hide();
|
||||
}
|
||||
});
|
||||
],
|
||||
primary_action_label: __("Get Items"),
|
||||
primary_action: (args) => {
|
||||
if (!args) return;
|
||||
dialog.hide();
|
||||
|
||||
dialog.show();
|
||||
}, __("Get Items From"));
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_item_from_material_requests_based_on_supplier",
|
||||
source_name: args.supplier,
|
||||
target: me.frm,
|
||||
setters: {
|
||||
company: me.frm.doc.company,
|
||||
},
|
||||
get_query_filters: {
|
||||
material_request_type: "Purchase",
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 100],
|
||||
},
|
||||
});
|
||||
dialog.hide();
|
||||
},
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
},
|
||||
__("Get Items From")
|
||||
);
|
||||
|
||||
// Link Material Requests
|
||||
this.frm.add_custom_button(__('Link to Material Requests'),
|
||||
function() {
|
||||
this.frm.add_custom_button(
|
||||
__("Link to Material Requests"),
|
||||
function () {
|
||||
erpnext.buying.link_to_mrs(me.frm);
|
||||
}, __("Tools"));
|
||||
},
|
||||
__("Tools")
|
||||
);
|
||||
|
||||
// Get Suppliers
|
||||
this.frm.add_custom_button(__('Get Suppliers'),
|
||||
function() {
|
||||
this.frm.add_custom_button(
|
||||
__("Get Suppliers"),
|
||||
function () {
|
||||
me.get_suppliers_button(me.frm);
|
||||
}, __("Tools"));
|
||||
},
|
||||
__("Tools")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,70 +430,75 @@ erpnext.buying.RequestforQuotationController = class RequestforQuotationControll
|
||||
this.get_terms();
|
||||
}
|
||||
|
||||
get_suppliers_button (frm) {
|
||||
get_suppliers_button(frm) {
|
||||
var doc = frm.doc;
|
||||
var dialog = new frappe.ui.Dialog({
|
||||
title: __("Get Suppliers"),
|
||||
fields: [
|
||||
{
|
||||
"fieldtype": "Select", "label": __("Get Suppliers By"),
|
||||
"fieldname": "search_type",
|
||||
"options": ["Supplier Group", "Tag"],
|
||||
"reqd": 1,
|
||||
fieldtype: "Select",
|
||||
label: __("Get Suppliers By"),
|
||||
fieldname: "search_type",
|
||||
options: ["Supplier Group", "Tag"],
|
||||
reqd: 1,
|
||||
onchange() {
|
||||
if(dialog.get_value('search_type') == 'Tag'){
|
||||
frappe.call({
|
||||
method: 'erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_supplier_tag',
|
||||
}).then(r => {
|
||||
dialog.set_df_property("tag", "options", r.message)
|
||||
});
|
||||
if (dialog.get_value("search_type") == "Tag") {
|
||||
frappe
|
||||
.call({
|
||||
method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_supplier_tag",
|
||||
})
|
||||
.then((r) => {
|
||||
dialog.set_df_property("tag", "options", r.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldtype": "Link", "label": __("Supplier Group"),
|
||||
"fieldname": "supplier_group",
|
||||
"options": "Supplier Group",
|
||||
"reqd": 0,
|
||||
"depends_on": "eval:doc.search_type == 'Supplier Group'"
|
||||
fieldtype: "Link",
|
||||
label: __("Supplier Group"),
|
||||
fieldname: "supplier_group",
|
||||
options: "Supplier Group",
|
||||
reqd: 0,
|
||||
depends_on: "eval:doc.search_type == 'Supplier Group'",
|
||||
},
|
||||
{
|
||||
"fieldtype": "Select", "label": __("Tag"),
|
||||
"fieldname": "tag",
|
||||
"reqd": 0,
|
||||
"depends_on": "eval:doc.search_type == 'Tag'",
|
||||
}
|
||||
fieldtype: "Select",
|
||||
label: __("Tag"),
|
||||
fieldname: "tag",
|
||||
reqd: 0,
|
||||
depends_on: "eval:doc.search_type == 'Tag'",
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Add Suppliers"),
|
||||
primary_action : (args) => {
|
||||
if(!args) return;
|
||||
primary_action: (args) => {
|
||||
if (!args) return;
|
||||
dialog.hide();
|
||||
|
||||
//Remove blanks
|
||||
for (var j = 0; j < frm.doc.suppliers.length; j++) {
|
||||
if(!Object.prototype.hasOwnProperty.call(frm.doc.suppliers[j], "supplier")) {
|
||||
if (!Object.prototype.hasOwnProperty.call(frm.doc.suppliers[j], "supplier")) {
|
||||
frm.get_field("suppliers").grid.grid_rows[j].remove();
|
||||
}
|
||||
}
|
||||
|
||||
function load_suppliers(r) {
|
||||
if(r.message) {
|
||||
if (r.message) {
|
||||
for (var i = 0; i < r.message.length; i++) {
|
||||
var exists = false;
|
||||
let supplier = "";
|
||||
if (r.message[i].constructor === Array){
|
||||
if (r.message[i].constructor === Array) {
|
||||
supplier = r.message[i][0];
|
||||
} else {
|
||||
supplier = r.message[i].name;
|
||||
}
|
||||
|
||||
for (var j = 0; j < doc.suppliers.length;j++) {
|
||||
for (var j = 0; j < doc.suppliers.length; j++) {
|
||||
if (supplier === doc.suppliers[j].supplier) {
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
if(!exists) {
|
||||
var d = frm.add_child('suppliers');
|
||||
if (!exists) {
|
||||
var d = frm.add_child("suppliers");
|
||||
d.supplier = supplier;
|
||||
frm.script_manager.trigger("supplier", d.doctype, d.name);
|
||||
}
|
||||
@@ -473,10 +512,10 @@ erpnext.buying.RequestforQuotationController = class RequestforQuotationControll
|
||||
type: "GET",
|
||||
method: "frappe.desk.doctype.tag.tag.get_tagged_docs",
|
||||
args: {
|
||||
"doctype": "Supplier",
|
||||
"tag": args.tag
|
||||
doctype: "Supplier",
|
||||
tag: args.tag,
|
||||
},
|
||||
callback: load_suppliers
|
||||
callback: load_suppliers,
|
||||
});
|
||||
} else if (args.supplier_group) {
|
||||
return frappe.call({
|
||||
@@ -485,13 +524,12 @@ erpnext.buying.RequestforQuotationController = class RequestforQuotationControll
|
||||
doctype: "Supplier",
|
||||
order_by: "name",
|
||||
fields: ["name"],
|
||||
filters: [["Supplier", "supplier_group", "=", args.supplier_group]]
|
||||
|
||||
filters: [["Supplier", "supplier_group", "=", args.supplier_group]],
|
||||
},
|
||||
callback: load_suppliers
|
||||
callback: load_suppliers,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
@@ -499,4 +537,4 @@ erpnext.buying.RequestforQuotationController = class RequestforQuotationControll
|
||||
};
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
extend_cscript(cur_frm.cscript, new erpnext.buying.RequestforQuotationController({frm: cur_frm}));
|
||||
extend_cscript(cur_frm.cscript, new erpnext.buying.RequestforQuotationController({ frm: cur_frm }));
|
||||
|
||||
@@ -3,65 +3,65 @@
|
||||
|
||||
frappe.ui.form.on("Supplier", {
|
||||
setup: function (frm) {
|
||||
frm.set_query('default_price_list', { 'buying': 1 });
|
||||
frm.set_query("default_price_list", { buying: 1 });
|
||||
if (frm.doc.__islocal == 1) {
|
||||
frm.set_value("represents_company", "");
|
||||
}
|
||||
frm.set_query('account', 'accounts', function (doc, cdt, cdn) {
|
||||
frm.set_query("account", "accounts", function (doc, cdt, cdn) {
|
||||
let d = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
'account_type': 'Payable',
|
||||
'root_type': 'Liability',
|
||||
'company': d.company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
account_type: "Payable",
|
||||
root_type: "Liability",
|
||||
company: d.company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('advance_account', 'accounts', function (doc, cdt, cdn) {
|
||||
frm.set_query("advance_account", "accounts", function (doc, cdt, cdn) {
|
||||
let d = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
"account_type": "Payable",
|
||||
"root_type": "Asset",
|
||||
"company": d.company,
|
||||
"is_group": 0
|
||||
}
|
||||
}
|
||||
account_type: "Payable",
|
||||
root_type: "Asset",
|
||||
company: d.company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("default_bank_account", function() {
|
||||
frm.set_query("default_bank_account", function () {
|
||||
return {
|
||||
filters: {
|
||||
"is_company_account":1
|
||||
}
|
||||
}
|
||||
is_company_account: 1,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("supplier_primary_contact", function(doc) {
|
||||
frm.set_query("supplier_primary_contact", function (doc) {
|
||||
return {
|
||||
query: "erpnext.buying.doctype.supplier.supplier.get_supplier_primary_contact",
|
||||
filters: {
|
||||
"supplier": doc.name
|
||||
}
|
||||
supplier: doc.name,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("supplier_primary_address", function(doc) {
|
||||
frm.set_query("supplier_primary_address", function (doc) {
|
||||
return {
|
||||
filters: {
|
||||
"link_doctype": "Supplier",
|
||||
"link_name": doc.name
|
||||
}
|
||||
link_doctype: "Supplier",
|
||||
link_name: doc.name,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("user", "portal_users", function(doc) {
|
||||
frm.set_query("user", "portal_users", function (doc) {
|
||||
return {
|
||||
filters: {
|
||||
"ignore_user_type": true,
|
||||
}
|
||||
ignore_user_type: true,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
@@ -74,65 +74,94 @@ frappe.ui.form.on("Supplier", {
|
||||
}
|
||||
|
||||
if (frm.doc.__islocal) {
|
||||
hide_field(['address_html','contact_html']);
|
||||
hide_field(["address_html", "contact_html"]);
|
||||
frappe.contacts.clear_address_and_contact(frm);
|
||||
}
|
||||
else {
|
||||
unhide_field(['address_html','contact_html']);
|
||||
} else {
|
||||
unhide_field(["address_html", "contact_html"]);
|
||||
frappe.contacts.render_address_and_contact(frm);
|
||||
|
||||
// custom buttons
|
||||
frm.add_custom_button(__('Accounting Ledger'), function () {
|
||||
frappe.set_route('query-report', 'General Ledger',
|
||||
{ party_type: 'Supplier', party: frm.doc.name, party_name: frm.doc.supplier_name });
|
||||
}, __("View"));
|
||||
frm.add_custom_button(
|
||||
__("Accounting Ledger"),
|
||||
function () {
|
||||
frappe.set_route("query-report", "General Ledger", {
|
||||
party_type: "Supplier",
|
||||
party: frm.doc.name,
|
||||
party_name: frm.doc.supplier_name,
|
||||
});
|
||||
},
|
||||
__("View")
|
||||
);
|
||||
|
||||
frm.add_custom_button(__('Accounts Payable'), function () {
|
||||
frappe.set_route('query-report', 'Accounts Payable', { party_type: "Supplier", party: frm.doc.name });
|
||||
}, __("View"));
|
||||
frm.add_custom_button(
|
||||
__("Accounts Payable"),
|
||||
function () {
|
||||
frappe.set_route("query-report", "Accounts Payable", {
|
||||
party_type: "Supplier",
|
||||
party: frm.doc.name,
|
||||
});
|
||||
},
|
||||
__("View")
|
||||
);
|
||||
|
||||
frm.add_custom_button(__('Bank Account'), function () {
|
||||
erpnext.utils.make_bank_account(frm.doc.doctype, frm.doc.name);
|
||||
}, __('Create'));
|
||||
frm.add_custom_button(
|
||||
__("Bank Account"),
|
||||
function () {
|
||||
erpnext.utils.make_bank_account(frm.doc.doctype, frm.doc.name);
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
|
||||
frm.add_custom_button(__('Pricing Rule'), function () {
|
||||
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
|
||||
}, __('Create'));
|
||||
frm.add_custom_button(
|
||||
__("Pricing Rule"),
|
||||
function () {
|
||||
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
|
||||
frm.add_custom_button(__('Get Supplier Group Details'), function () {
|
||||
frm.trigger("get_supplier_group_details");
|
||||
}, __('Actions'));
|
||||
frm.add_custom_button(
|
||||
__("Get Supplier Group Details"),
|
||||
function () {
|
||||
frm.trigger("get_supplier_group_details");
|
||||
},
|
||||
__("Actions")
|
||||
);
|
||||
|
||||
if (cint(frappe.defaults.get_default("enable_common_party_accounting"))) {
|
||||
frm.add_custom_button(__('Link with Customer'), function () {
|
||||
frm.trigger('show_party_link_dialog');
|
||||
}, __('Actions'));
|
||||
frm.add_custom_button(
|
||||
__("Link with Customer"),
|
||||
function () {
|
||||
frm.trigger("show_party_link_dialog");
|
||||
},
|
||||
__("Actions")
|
||||
);
|
||||
}
|
||||
|
||||
// indicators
|
||||
erpnext.utils.set_party_dashboard_indicators(frm);
|
||||
}
|
||||
},
|
||||
get_supplier_group_details: function(frm) {
|
||||
get_supplier_group_details: function (frm) {
|
||||
frappe.call({
|
||||
method: "get_supplier_group_details",
|
||||
doc: frm.doc,
|
||||
callback: function() {
|
||||
callback: function () {
|
||||
frm.refresh();
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
supplier_primary_address: function(frm) {
|
||||
supplier_primary_address: function (frm) {
|
||||
if (frm.doc.supplier_primary_address) {
|
||||
frappe.call({
|
||||
method: 'frappe.contacts.doctype.address.address.get_address_display',
|
||||
method: "frappe.contacts.doctype.address.address.get_address_display",
|
||||
args: {
|
||||
"address_dict": frm.doc.supplier_primary_address
|
||||
address_dict: frm.doc.supplier_primary_address,
|
||||
},
|
||||
callback: function(r) {
|
||||
callback: function (r) {
|
||||
frm.set_value("primary_address", r.message);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
if (!frm.doc.supplier_primary_address) {
|
||||
@@ -140,56 +169,60 @@ frappe.ui.form.on("Supplier", {
|
||||
}
|
||||
},
|
||||
|
||||
supplier_primary_contact: function(frm) {
|
||||
supplier_primary_contact: function (frm) {
|
||||
if (!frm.doc.supplier_primary_contact) {
|
||||
frm.set_value("mobile_no", "");
|
||||
frm.set_value("email_id", "");
|
||||
}
|
||||
},
|
||||
|
||||
is_internal_supplier: function(frm) {
|
||||
is_internal_supplier: function (frm) {
|
||||
if (frm.doc.is_internal_supplier == 1) {
|
||||
frm.toggle_reqd("represents_company", true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
frm.toggle_reqd("represents_company", false);
|
||||
}
|
||||
},
|
||||
show_party_link_dialog: function(frm) {
|
||||
show_party_link_dialog: function (frm) {
|
||||
const dialog = new frappe.ui.Dialog({
|
||||
title: __('Select a Customer'),
|
||||
fields: [{
|
||||
fieldtype: 'Link', label: __('Customer'),
|
||||
options: 'Customer', fieldname: 'customer', reqd: 1
|
||||
}],
|
||||
primary_action: function({ customer }) {
|
||||
title: __("Select a Customer"),
|
||||
fields: [
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: __("Customer"),
|
||||
options: "Customer",
|
||||
fieldname: "customer",
|
||||
reqd: 1,
|
||||
},
|
||||
],
|
||||
primary_action: function ({ customer }) {
|
||||
frappe.call({
|
||||
method: 'erpnext.accounts.doctype.party_link.party_link.create_party_link',
|
||||
method: "erpnext.accounts.doctype.party_link.party_link.create_party_link",
|
||||
args: {
|
||||
primary_role: 'Supplier',
|
||||
primary_role: "Supplier",
|
||||
primary_party: frm.doc.name,
|
||||
secondary_party: customer
|
||||
secondary_party: customer,
|
||||
},
|
||||
freeze: true,
|
||||
callback: function() {
|
||||
callback: function () {
|
||||
dialog.hide();
|
||||
frappe.msgprint({
|
||||
message: __('Successfully linked to Customer'),
|
||||
alert: true
|
||||
message: __("Successfully linked to Customer"),
|
||||
alert: true,
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
dialog.hide();
|
||||
frappe.msgprint({
|
||||
message: __('Linking to Customer Failed. Please try again.'),
|
||||
title: __('Linking Failed'),
|
||||
indicator: 'red'
|
||||
message: __("Linking to Customer Failed. Please try again."),
|
||||
title: __("Linking Failed"),
|
||||
indicator: "red",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
primary_action_label: __('Create Link')
|
||||
primary_action_label: __("Create Link"),
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
frappe.listview_settings['Supplier'] = {
|
||||
frappe.listview_settings["Supplier"] = {
|
||||
add_fields: ["supplier_name", "supplier_group", "image", "on_hold"],
|
||||
get_indicator: function(doc) {
|
||||
if(cint(doc.on_hold)) {
|
||||
get_indicator: function (doc) {
|
||||
if (cint(doc.on_hold)) {
|
||||
return [__("On Hold"), "red"];
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
erpnext.buying.setup_buying_controller();
|
||||
erpnext.buying.SupplierQuotationController = class SupplierQuotationController extends erpnext.buying.BuyingController {
|
||||
erpnext.buying.SupplierQuotationController = class SupplierQuotationController extends (
|
||||
erpnext.buying.BuyingController
|
||||
) {
|
||||
setup() {
|
||||
this.frm.custom_make_buttons = {
|
||||
'Purchase Order': 'Purchase Order',
|
||||
'Quotation': 'Quotation'
|
||||
}
|
||||
"Purchase Order": "Purchase Order",
|
||||
Quotation: "Quotation",
|
||||
};
|
||||
|
||||
super.setup();
|
||||
}
|
||||
@@ -17,89 +19,90 @@ erpnext.buying.SupplierQuotationController = class SupplierQuotationController e
|
||||
super.refresh();
|
||||
|
||||
if (this.frm.doc.__islocal && !this.frm.doc.valid_till) {
|
||||
this.frm.set_value('valid_till', frappe.datetime.add_months(this.frm.doc.transaction_date, 1));
|
||||
this.frm.set_value("valid_till", frappe.datetime.add_months(this.frm.doc.transaction_date, 1));
|
||||
}
|
||||
if (this.frm.doc.docstatus === 1) {
|
||||
cur_frm.add_custom_button(__("Purchase Order"), this.make_purchase_order,
|
||||
__('Create'));
|
||||
cur_frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||
cur_frm.add_custom_button(__("Quotation"), this.make_quotation,
|
||||
__('Create'));
|
||||
}
|
||||
else if (this.frm.doc.docstatus===0) {
|
||||
|
||||
this.frm.add_custom_button(__('Material Request'),
|
||||
function() {
|
||||
cur_frm.add_custom_button(__("Purchase Order"), this.make_purchase_order, __("Create"));
|
||||
cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||
cur_frm.add_custom_button(__("Quotation"), this.make_quotation, __("Create"));
|
||||
} else if (this.frm.doc.docstatus === 0) {
|
||||
this.frm.add_custom_button(
|
||||
__("Material Request"),
|
||||
function () {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.stock.doctype.material_request.material_request.make_supplier_quotation",
|
||||
source_doctype: "Material Request",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
schedule_date: undefined,
|
||||
status: undefined
|
||||
status: undefined,
|
||||
},
|
||||
get_query_filters: {
|
||||
material_request_type: "Purchase",
|
||||
docstatus: 1,
|
||||
status: ["!=", "Stopped"],
|
||||
per_ordered: ["<", 100],
|
||||
company: me.frm.doc.company
|
||||
}
|
||||
})
|
||||
}, __("Get Items From"));
|
||||
company: me.frm.doc.company,
|
||||
},
|
||||
});
|
||||
},
|
||||
__("Get Items From")
|
||||
);
|
||||
|
||||
// Link Material Requests
|
||||
this.frm.add_custom_button(__('Link to Material Requests'),
|
||||
function() {
|
||||
this.frm.add_custom_button(
|
||||
__("Link to Material Requests"),
|
||||
function () {
|
||||
erpnext.buying.link_to_mrs(me.frm);
|
||||
}, __("Tools"));
|
||||
},
|
||||
__("Tools")
|
||||
);
|
||||
|
||||
this.frm.add_custom_button(__("Request for Quotation"),
|
||||
function() {
|
||||
if (!me.frm.doc.supplier) {
|
||||
frappe.throw({message:__("Please select a Supplier"), title:__("Mandatory")})
|
||||
}
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.make_supplier_quotation_from_rfq",
|
||||
source_doctype: "Request for Quotation",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
transaction_date: null
|
||||
},
|
||||
get_query_filters: {
|
||||
supplier: me.frm.doc.supplier,
|
||||
company: me.frm.doc.company
|
||||
},
|
||||
get_query_method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_rfq_containing_supplier"
|
||||
|
||||
})
|
||||
}, __("Get Items From"));
|
||||
this.frm.add_custom_button(
|
||||
__("Request for Quotation"),
|
||||
function () {
|
||||
if (!me.frm.doc.supplier) {
|
||||
frappe.throw({ message: __("Please select a Supplier"), title: __("Mandatory") });
|
||||
}
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.make_supplier_quotation_from_rfq",
|
||||
source_doctype: "Request for Quotation",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
transaction_date: null,
|
||||
},
|
||||
get_query_filters: {
|
||||
supplier: me.frm.doc.supplier,
|
||||
company: me.frm.doc.company,
|
||||
},
|
||||
get_query_method:
|
||||
"erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_rfq_containing_supplier",
|
||||
});
|
||||
},
|
||||
__("Get Items From")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
make_purchase_order() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
|
||||
frm: cur_frm
|
||||
})
|
||||
frm: cur_frm,
|
||||
});
|
||||
}
|
||||
make_quotation() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_quotation",
|
||||
frm: cur_frm
|
||||
})
|
||||
|
||||
frm: cur_frm,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
extend_cscript(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm}));
|
||||
extend_cscript(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({ frm: cur_frm }));
|
||||
|
||||
cur_frm.fields_dict['items'].grid.get_field('project').get_query =
|
||||
function(doc, cdt, cdn) {
|
||||
return{
|
||||
filters:[
|
||||
['Project', 'status', 'not in', 'Completed, Cancelled']
|
||||
]
|
||||
}
|
||||
}
|
||||
cur_frm.fields_dict["items"].grid.get_field("project").get_query = function (doc, cdt, cdn) {
|
||||
return {
|
||||
filters: [["Project", "status", "not in", "Completed, Cancelled"]],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
frappe.listview_settings['Supplier Quotation'] = {
|
||||
frappe.listview_settings["Supplier Quotation"] = {
|
||||
add_fields: ["supplier", "base_grand_total", "status", "company", "currency"],
|
||||
get_indicator: function(doc) {
|
||||
if(doc.status==="Ordered") {
|
||||
get_indicator: function (doc) {
|
||||
if (doc.status === "Ordered") {
|
||||
return [__("Ordered"), "green", "status,=,Ordered"];
|
||||
} else if(doc.status==="Rejected") {
|
||||
} else if (doc.status === "Rejected") {
|
||||
return [__("Lost"), "gray", "status,=,Lost"];
|
||||
} else if(doc.status==="Expired") {
|
||||
} else if (doc.status === "Expired") {
|
||||
return [__("Expired"), "gray", "status,=,Expired"];
|
||||
}
|
||||
},
|
||||
|
||||
onload: function(listview) {
|
||||
listview.page.add_action_item(__("Purchase Order"), ()=>{
|
||||
onload: function (listview) {
|
||||
listview.page.add_action_item(__("Purchase Order"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Supplier Quotation", "Purchase Order");
|
||||
});
|
||||
|
||||
listview.page.add_action_item(__("Purchase Invoice"), ()=>{
|
||||
listview.page.add_action_item(__("Purchase Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Supplier Quotation", "Purchase Invoice");
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,55 +2,51 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Supplier Scorecard", {
|
||||
setup: function(frm) {
|
||||
if (frm.doc.indicator_color !== "") {
|
||||
frm.set_indicator_formatter("status", function(doc) {
|
||||
setup: function (frm) {
|
||||
if (frm.doc.indicator_color !== "") {
|
||||
frm.set_indicator_formatter("status", function (doc) {
|
||||
return doc.indicator_color.toLowerCase();
|
||||
});
|
||||
}
|
||||
},
|
||||
onload: function(frm) {
|
||||
if (frm.doc.__unsaved == 1) {
|
||||
onload: function (frm) {
|
||||
if (frm.doc.__unsaved == 1) {
|
||||
loadAllStandings(frm);
|
||||
}
|
||||
},
|
||||
load_criteria: function(frm) {
|
||||
load_criteria: function (frm) {
|
||||
frappe.call({
|
||||
method: "erpnext.buying.doctype.supplier_scorecard_criteria.supplier_scorecard_criteria.get_criteria_list",
|
||||
callback: function(r) {
|
||||
frm.set_value('criteria', []);
|
||||
for (var i = 0; i < r.message.length; i++)
|
||||
{
|
||||
callback: function (r) {
|
||||
frm.set_value("criteria", []);
|
||||
for (var i = 0; i < r.message.length; i++) {
|
||||
var row = frm.add_child("criteria");
|
||||
row.criteria_name = r.message[i].name;
|
||||
frm.script_manager.trigger("criteria_name", row.doctype, row.name);
|
||||
}
|
||||
refresh_field("criteria");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Supplier Scorecard Scoring Standing", {
|
||||
|
||||
standing_name: function(frm, cdt, cdn) {
|
||||
standing_name: function (frm, cdt, cdn) {
|
||||
var d = frappe.get_doc(cdt, cdn);
|
||||
if (d.standing_name) {
|
||||
return frm.call({
|
||||
method: "erpnext.buying.doctype.supplier_scorecard_standing.supplier_scorecard_standing.get_scoring_standing",
|
||||
child: d,
|
||||
args: {
|
||||
standing_name: d.standing_name
|
||||
}
|
||||
standing_name: d.standing_name,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Supplier Scorecard Scoring Criteria", {
|
||||
|
||||
criteria_name: function(frm, cdt, cdn) {
|
||||
criteria_name: function (frm, cdt, cdn) {
|
||||
var d = frappe.get_doc(cdt, cdn);
|
||||
if (d.criteria_name) {
|
||||
return frm.call({
|
||||
@@ -58,36 +54,34 @@ frappe.ui.form.on("Supplier Scorecard Scoring Criteria", {
|
||||
args: {
|
||||
fieldname: "weight",
|
||||
doctype: "Supplier Scorecard Criteria",
|
||||
filters: {name: d.criteria_name}
|
||||
filters: { name: d.criteria_name },
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.message){
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
d.weight = r.message.weight;
|
||||
frm.refresh_field('criteria', 'weight');
|
||||
frm.refresh_field("criteria", "weight");
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var loadAllStandings = function(frm) {
|
||||
var loadAllStandings = function (frm) {
|
||||
frappe.call({
|
||||
method: "erpnext.buying.doctype.supplier_scorecard_standing.supplier_scorecard_standing.get_standings_list",
|
||||
callback: function(r) {
|
||||
for (var j = 0; j < frm.doc.standings.length; j++)
|
||||
{
|
||||
if(!Object.prototype.hasOwnProperty.call(frm.doc.standings[j], "standing_name")) {
|
||||
callback: function (r) {
|
||||
for (var j = 0; j < frm.doc.standings.length; j++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(frm.doc.standings[j], "standing_name")) {
|
||||
frm.get_field("standings").grid.grid_rows[j].remove();
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < r.message.length; i++)
|
||||
{
|
||||
for (var i = 0; i < r.message.length; i++) {
|
||||
var new_row = frm.add_child("standings");
|
||||
new_row.standing_name = r.message[i].name;
|
||||
frm.script_manager.trigger("standing_name", new_row.doctype, new_row.name);
|
||||
}
|
||||
refresh_field("standings");
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.listview_settings["Supplier Scorecard"] = {
|
||||
add_fields: ["indicator_color", "status"],
|
||||
get_indicator: function(doc) {
|
||||
|
||||
get_indicator: function (doc) {
|
||||
if (doc.indicator_color) {
|
||||
return [__(doc.status), doc.indicator_color.toLowerCase(), "status,=," + doc.status];
|
||||
} else {
|
||||
return [__("Unknown"), "gray", "status,=,''"];
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Supplier Scorecard Criteria", {
|
||||
refresh: function() {}
|
||||
refresh: function () {},
|
||||
});
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Supplier Scorecard Period", {
|
||||
onload: function(frm) {
|
||||
onload: function (frm) {
|
||||
let criteria_grid = frm.get_field("criteria").grid;
|
||||
criteria_grid.toggle_enable("criteria_name", false);
|
||||
criteria_grid.toggle_enable("weight", false);
|
||||
criteria_grid.toggle_display("max_score", true);
|
||||
criteria_grid.toggle_display("formula", true);
|
||||
criteria_grid.toggle_display("score", true);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.ui.form.on("Supplier Scorecard Standing", {
|
||||
refresh: function() {
|
||||
|
||||
}
|
||||
refresh: function () {},
|
||||
});
|
||||
|
||||
@@ -2,7 +2,5 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Supplier Scorecard Variable", {
|
||||
refresh: function() {
|
||||
|
||||
}
|
||||
refresh: function () {},
|
||||
});
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Procurement Tracker"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
fieldname: "company",
|
||||
label: __("Company"),
|
||||
@@ -30,10 +29,10 @@ frappe.query_reports["Procurement Tracker"] = {
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||
},
|
||||
{
|
||||
fieldname:"to_date",
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,49 +1,48 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Purchase Analytics"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
fieldname: "tree_type",
|
||||
label: __("Tree Type"),
|
||||
fieldtype: "Select",
|
||||
options: ["Supplier Group","Supplier","Item Group","Item"],
|
||||
options: ["Supplier Group", "Supplier", "Item Group", "Item"],
|
||||
default: "Supplier",
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname: "doc_type",
|
||||
label: __("based_on"),
|
||||
fieldtype: "Select",
|
||||
options: ["Purchase Order","Purchase Receipt","Purchase Invoice"],
|
||||
options: ["Purchase Order", "Purchase Receipt", "Purchase Invoice"],
|
||||
default: "Purchase Invoice",
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname: "value_quantity",
|
||||
label: __("Value Or Qty"),
|
||||
fieldtype: "Select",
|
||||
options: [
|
||||
{ "value": "Value", "label": __("Value") },
|
||||
{ "value": "Quantity", "label": __("Quantity") },
|
||||
{ value: "Value", label: __("Value") },
|
||||
{ value: "Quantity", label: __("Quantity") },
|
||||
],
|
||||
default: "Value",
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname:"to_date",
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname: "company",
|
||||
@@ -51,22 +50,21 @@ frappe.query_reports["Purchase Analytics"] = {
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname: "range",
|
||||
label: __("Range"),
|
||||
fieldtype: "Select",
|
||||
options: [
|
||||
{ "value": "Weekly", "label": __("Weekly") },
|
||||
{ "value": "Monthly", "label": __("Monthly") },
|
||||
{ "value": "Quarterly", "label": __("Quarterly") },
|
||||
{ "value": "Yearly", "label": __("Yearly") }
|
||||
{ value: "Weekly", label: __("Weekly") },
|
||||
{ value: "Monthly", label: __("Monthly") },
|
||||
{ value: "Quarterly", label: __("Quarterly") },
|
||||
{ value: "Yearly", label: __("Yearly") },
|
||||
],
|
||||
default: "Monthly",
|
||||
reqd: 1
|
||||
}
|
||||
|
||||
reqd: 1,
|
||||
},
|
||||
],
|
||||
get_datatable_options(options) {
|
||||
return Object.assign(options, {
|
||||
@@ -75,34 +73,26 @@ frappe.query_reports["Purchase Analytics"] = {
|
||||
onCheckRow: function (data) {
|
||||
if (!data) return;
|
||||
|
||||
const data_doctype = $(
|
||||
data[2].html
|
||||
)[0].attributes.getNamedItem("data-doctype").value;
|
||||
const data_doctype = $(data[2].html)[0].attributes.getNamedItem("data-doctype").value;
|
||||
const tree_type = frappe.query_report.filters[0].value;
|
||||
if (data_doctype != tree_type) return;
|
||||
|
||||
let row_name = data[2].content;
|
||||
let length = data.length;
|
||||
let row_values = '';
|
||||
let row_values = "";
|
||||
|
||||
if (tree_type == "Supplier") {
|
||||
row_values = data
|
||||
.slice(4, length - 1)
|
||||
.map(function (column) {
|
||||
return column.content;
|
||||
});
|
||||
row_values = data.slice(4, length - 1).map(function (column) {
|
||||
return column.content;
|
||||
});
|
||||
} else if (tree_type == "Item") {
|
||||
row_values = data
|
||||
.slice(5, length - 1)
|
||||
.map(function (column) {
|
||||
return column.content;
|
||||
});
|
||||
row_values = data.slice(5, length - 1).map(function (column) {
|
||||
return column.content;
|
||||
});
|
||||
} else {
|
||||
row_values = data
|
||||
.slice(3, length - 1)
|
||||
.map(function (column) {
|
||||
return column.content;
|
||||
});
|
||||
row_values = data.slice(3, length - 1).map(function (column) {
|
||||
return column.content;
|
||||
});
|
||||
}
|
||||
|
||||
let entry = {
|
||||
@@ -113,13 +103,13 @@ frappe.query_reports["Purchase Analytics"] = {
|
||||
let raw_data = frappe.query_report.chart.data;
|
||||
let new_datasets = raw_data.datasets;
|
||||
|
||||
let element_found = new_datasets.some((element, index, array)=>{
|
||||
if(element.name == row_name){
|
||||
array.splice(index, 1)
|
||||
return true
|
||||
let element_found = new_datasets.some((element, index, array) => {
|
||||
if (element.name == row_name) {
|
||||
array.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!element_found) {
|
||||
new_datasets.push(entry);
|
||||
@@ -128,12 +118,14 @@ frappe.query_reports["Purchase Analytics"] = {
|
||||
labels: raw_data.labels,
|
||||
datasets: new_datasets,
|
||||
};
|
||||
const new_options = Object.assign({}, frappe.query_report.chart_options, {data: new_data});
|
||||
const new_options = Object.assign({}, frappe.query_report.chart_options, {
|
||||
data: new_data,
|
||||
});
|
||||
frappe.query_report.render_chart(new_options);
|
||||
|
||||
frappe.query_report.raw_chart_data = new_data;
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,80 +1,79 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Purchase Order Analysis"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname": "company",
|
||||
"label": __("Company"),
|
||||
"fieldtype": "Link",
|
||||
"width": "80",
|
||||
"options": "Company",
|
||||
"reqd": 1,
|
||||
"default": frappe.defaults.get_default("company")
|
||||
fieldname: "company",
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
width: "80",
|
||||
options: "Company",
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_default("company"),
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
width: "80",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.get_today()
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
width: "80",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.get_today(),
|
||||
},
|
||||
{
|
||||
"fieldname":"project",
|
||||
"label": __("Project"),
|
||||
"fieldtype": "Link",
|
||||
"width": "80",
|
||||
"options": "Project"
|
||||
fieldname: "project",
|
||||
label: __("Project"),
|
||||
fieldtype: "Link",
|
||||
width: "80",
|
||||
options: "Project",
|
||||
},
|
||||
{
|
||||
"fieldname": "name",
|
||||
"label": __("Purchase Order"),
|
||||
"fieldtype": "Link",
|
||||
"width": "80",
|
||||
"options": "Purchase Order",
|
||||
"get_query": () =>{
|
||||
fieldname: "name",
|
||||
label: __("Purchase Order"),
|
||||
fieldtype: "Link",
|
||||
width: "80",
|
||||
options: "Purchase Order",
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: { "docstatus": 1 }
|
||||
}
|
||||
}
|
||||
filters: { docstatus: 1 },
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "status",
|
||||
"label": __("Status"),
|
||||
"fieldtype": "MultiSelectList",
|
||||
"width": "80",
|
||||
get_data: function(txt) {
|
||||
let status = ["To Bill", "To Receive", "To Receive and Bill", "Completed"]
|
||||
let options = []
|
||||
for (let option of status){
|
||||
fieldname: "status",
|
||||
label: __("Status"),
|
||||
fieldtype: "MultiSelectList",
|
||||
width: "80",
|
||||
get_data: function (txt) {
|
||||
let status = ["To Bill", "To Receive", "To Receive and Bill", "Completed"];
|
||||
let options = [];
|
||||
for (let option of status) {
|
||||
options.push({
|
||||
"value": option,
|
||||
"label": __(option),
|
||||
"description": ""
|
||||
})
|
||||
value: option,
|
||||
label: __(option),
|
||||
description: "",
|
||||
});
|
||||
}
|
||||
return options
|
||||
}
|
||||
return options;
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "group_by_po",
|
||||
"label": __("Group by Purchase Order"),
|
||||
"fieldtype": "Check",
|
||||
"default": 0
|
||||
}
|
||||
fieldname: "group_by_po",
|
||||
label: __("Group by Purchase Order"),
|
||||
fieldtype: "Check",
|
||||
default: 0,
|
||||
},
|
||||
],
|
||||
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
formatter: function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
let format_fields = ["received_qty", "billed_amount"];
|
||||
|
||||
@@ -82,5 +81,5 @@ frappe.query_reports["Purchase Order Analysis"] = {
|
||||
value = "<span style='color:green'>" + value + "</span>";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() {
|
||||
frappe.require("assets/erpnext/js/purchase_trends_filters.js", function () {
|
||||
frappe.query_reports["Purchase Order Trends"] = {
|
||||
filters: erpnext.get_purchase_trends_filters()
|
||||
}
|
||||
filters: erpnext.get_purchase_trends_filters(),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,76 +1,75 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Requested Items to Order and Receive"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
"fieldname": "company",
|
||||
"label": __("Company"),
|
||||
"fieldtype": "Link",
|
||||
"width": "80",
|
||||
"options": "Company",
|
||||
"reqd": 1,
|
||||
"default": frappe.defaults.get_default("company")
|
||||
fieldname: "company",
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
width: "80",
|
||||
options: "Company",
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_default("company"),
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
width: "80",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.get_today()
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
width: "80",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.get_today(),
|
||||
},
|
||||
{
|
||||
"fieldname": "material_request",
|
||||
"label": __("Material Request"),
|
||||
"fieldtype": "Link",
|
||||
"width": "80",
|
||||
"options": "Material Request",
|
||||
"get_query": () => {
|
||||
fieldname: "material_request",
|
||||
label: __("Material Request"),
|
||||
fieldtype: "Link",
|
||||
width: "80",
|
||||
options: "Material Request",
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: {
|
||||
"docstatus": 1,
|
||||
"material_request_type": "Purchase",
|
||||
"per_received": ["<", 100]
|
||||
}
|
||||
}
|
||||
}
|
||||
docstatus: 1,
|
||||
material_request_type: "Purchase",
|
||||
per_received: ["<", 100],
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "item_code",
|
||||
"label": __("Item"),
|
||||
"fieldtype": "Link",
|
||||
"width": "80",
|
||||
"options": "Item",
|
||||
"get_query": () => {
|
||||
fieldname: "item_code",
|
||||
label: __("Item"),
|
||||
fieldtype: "Link",
|
||||
width: "80",
|
||||
options: "Item",
|
||||
get_query: () => {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query"
|
||||
}
|
||||
}
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "group_by_mr",
|
||||
"label": __("Group by Material Request"),
|
||||
"fieldtype": "Check",
|
||||
"default": 0
|
||||
}
|
||||
fieldname: "group_by_mr",
|
||||
label: __("Group by Material Request"),
|
||||
fieldtype: "Check",
|
||||
default: 0,
|
||||
},
|
||||
],
|
||||
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
formatter: function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (column.fieldname == "ordered_qty" && data && data.ordered_qty > 0) {
|
||||
value = "<span style='color:green'>" + value + "</span>";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,42 +1,41 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Subcontract Order Summary"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
label: __("Company"),
|
||||
fieldname: "company",
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
label: __("From Date"),
|
||||
fieldname: "from_date",
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
label: __("To Date"),
|
||||
fieldname: "to_date",
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.get_today(),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
label: __("Order Type"),
|
||||
fieldname: "order_type",
|
||||
fieldtype: "Select",
|
||||
options: ["Purchase Order", "Subcontracting Order"],
|
||||
default: "Subcontracting Order"
|
||||
default: "Subcontracting Order",
|
||||
},
|
||||
{
|
||||
label: __("Subcontract Order"),
|
||||
fieldname: "name",
|
||||
fieldtype: "Data"
|
||||
}
|
||||
]
|
||||
};
|
||||
fieldtype: "Data",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Subcontracted Item To Be Received"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
label: __("Order Type"),
|
||||
fieldname: "order_type",
|
||||
fieldtype: "Select",
|
||||
options: ["Purchase Order", "Subcontracting Order"],
|
||||
default: "Subcontracting Order"
|
||||
default: "Subcontracting Order",
|
||||
},
|
||||
{
|
||||
fieldname: "supplier",
|
||||
label: __("Supplier"),
|
||||
fieldtype: "Link",
|
||||
options: "Supplier",
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname:"from_date",
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname:"to_date",
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.get_today(),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
|
||||
frappe.query_reports["Subcontracted Raw Materials To Be Transferred"] = {
|
||||
"filters": [
|
||||
filters: [
|
||||
{
|
||||
label: __("Order Type"),
|
||||
fieldname: "order_type",
|
||||
fieldtype: "Select",
|
||||
options: ["Purchase Order", "Subcontracting Order"],
|
||||
default: "Subcontracting Order"
|
||||
default: "Subcontracting Order",
|
||||
},
|
||||
{
|
||||
fieldname: "supplier",
|
||||
label: __("Supplier"),
|
||||
fieldtype: "Link",
|
||||
options: "Supplier",
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname:"from_date",
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldname:"to_date",
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
default: frappe.datetime.get_today(),
|
||||
reqd: 1
|
||||
reqd: 1,
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
@@ -9,23 +9,23 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
|
||||
options: "Company",
|
||||
fieldname: "company",
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
"reqd": 1
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
"fieldname":"from_date",
|
||||
"label": __("From Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
fieldtype: "Date",
|
||||
width: "80",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To Date"),
|
||||
"fieldtype": "Date",
|
||||
"width": "80",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.get_today()
|
||||
fieldname: "to_date",
|
||||
label: __("To Date"),
|
||||
fieldtype: "Date",
|
||||
width: "80",
|
||||
reqd: 1,
|
||||
default: frappe.datetime.get_today(),
|
||||
},
|
||||
{
|
||||
default: "",
|
||||
@@ -34,34 +34,34 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
|
||||
fieldname: "item_code",
|
||||
fieldtype: "Link",
|
||||
get_query: () => {
|
||||
let quote = frappe.query_report.get_filter_value('supplier_quotation');
|
||||
let quote = frappe.query_report.get_filter_value("supplier_quotation");
|
||||
if (quote != "") {
|
||||
return {
|
||||
query: "erpnext.stock.doctype.quality_inspection.quality_inspection.item_query",
|
||||
filters: {
|
||||
"from": "Supplier Quotation Item",
|
||||
"parent": quote
|
||||
}
|
||||
}
|
||||
from: "Supplier Quotation Item",
|
||||
parent: quote,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldname: "supplier",
|
||||
label: __("Supplier"),
|
||||
fieldtype: "MultiSelectList",
|
||||
get_data: function(txt) {
|
||||
return frappe.db.get_link_options('Supplier', txt);
|
||||
}
|
||||
get_data: function (txt) {
|
||||
return frappe.db.get_link_options("Supplier", txt);
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldtype: "MultiSelectList",
|
||||
label: __("Supplier Quotation"),
|
||||
fieldname: "supplier_quotation",
|
||||
default: "",
|
||||
get_data: function(txt) {
|
||||
return frappe.db.get_link_options('Supplier Quotation', txt, {'docstatus': ["<", 2]});
|
||||
}
|
||||
get_data: function (txt) {
|
||||
return frappe.db.get_link_options("Supplier Quotation", txt, { docstatus: ["<", 2] });
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
@@ -70,37 +70,36 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
|
||||
fieldname: "request_for_quotation",
|
||||
default: "",
|
||||
get_query: () => {
|
||||
return { filters: { "docstatus": ["<", 2] } }
|
||||
}
|
||||
return { filters: { docstatus: ["<", 2] } };
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname":"group_by",
|
||||
"label": __("Group by"),
|
||||
"fieldtype": "Select",
|
||||
"options": [__("Group by Supplier"), __("Group by Item")],
|
||||
"default": __("Group by Supplier")
|
||||
fieldname: "group_by",
|
||||
label: __("Group by"),
|
||||
fieldtype: "Select",
|
||||
options: [__("Group by Supplier"), __("Group by Item")],
|
||||
default: __("Group by Supplier"),
|
||||
},
|
||||
{
|
||||
fieldtype: "Check",
|
||||
label: __("Include Expired"),
|
||||
fieldname: "include_expired",
|
||||
default: 0
|
||||
}
|
||||
default: 0,
|
||||
},
|
||||
],
|
||||
|
||||
formatter: (value, row, column, data, default_formatter) => {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if(column.fieldname === "valid_till" && data.valid_till){
|
||||
if(frappe.datetime.get_diff(data.valid_till, frappe.datetime.nowdate()) <= 1){
|
||||
if (column.fieldname === "valid_till" && data.valid_till) {
|
||||
if (frappe.datetime.get_diff(data.valid_till, frappe.datetime.nowdate()) <= 1) {
|
||||
value = `<div style="color:red">${value}</div>`;
|
||||
}
|
||||
else if (frappe.datetime.get_diff(data.valid_till, frappe.datetime.nowdate()) <= 7){
|
||||
} else if (frappe.datetime.get_diff(data.valid_till, frappe.datetime.nowdate()) <= 7) {
|
||||
value = `<div style="color:darkorange">${value}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
if(column.fieldname === "price_per_unit" && data.price_per_unit && data.min && data.min === 1){
|
||||
if (column.fieldname === "price_per_unit" && data.price_per_unit && data.min && data.min === 1) {
|
||||
value = `<div style="color:green">${value}</div>`;
|
||||
}
|
||||
return value;
|
||||
@@ -108,48 +107,53 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
|
||||
|
||||
onload: (report) => {
|
||||
// Create a button for setting the default supplier
|
||||
report.page.add_inner_button(__("Select Default Supplier"), () => {
|
||||
let reporter = frappe.query_reports["Supplier Quotation Comparison"];
|
||||
|
||||
//Always make a new one so that the latest values get updated
|
||||
reporter.make_default_supplier_dialog(report);
|
||||
}, __("Tools"));
|
||||
report.page.add_inner_button(
|
||||
__("Select Default Supplier"),
|
||||
() => {
|
||||
let reporter = frappe.query_reports["Supplier Quotation Comparison"];
|
||||
|
||||
//Always make a new one so that the latest values get updated
|
||||
reporter.make_default_supplier_dialog(report);
|
||||
},
|
||||
__("Tools")
|
||||
);
|
||||
},
|
||||
make_default_supplier_dialog: (report) => {
|
||||
// Get the name of the item to change
|
||||
if(!report.data) return;
|
||||
if (!report.data) return;
|
||||
|
||||
let filters = report.get_values();
|
||||
let item_code = filters.item_code;
|
||||
|
||||
// Get a list of the suppliers (with a blank as well) for the user to select
|
||||
let suppliers = $.map(report.data, (row, idx)=>{ return row.supplier_name })
|
||||
let suppliers = $.map(report.data, (row, idx) => {
|
||||
return row.supplier_name;
|
||||
});
|
||||
|
||||
// Create a dialog window for the user to pick their supplier
|
||||
let dialog = new frappe.ui.Dialog({
|
||||
title: __('Select Default Supplier'),
|
||||
title: __("Select Default Supplier"),
|
||||
fields: [
|
||||
{
|
||||
reqd: 1,
|
||||
label: 'Supplier',
|
||||
fieldtype: 'Link',
|
||||
options: 'Supplier',
|
||||
fieldname: 'supplier',
|
||||
label: "Supplier",
|
||||
fieldtype: "Link",
|
||||
options: "Supplier",
|
||||
fieldname: "supplier",
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: {
|
||||
'name': ['in', suppliers]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
name: ["in", suppliers],
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
dialog.set_primary_action(__("Set Default Supplier"), () => {
|
||||
let values = dialog.get_values();
|
||||
if(values) {
|
||||
if (values) {
|
||||
// Set the default_supplier field of the appropriate Item to the selected supplier
|
||||
frappe.call({
|
||||
method: "frappe.client.set_value",
|
||||
@@ -163,10 +167,10 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
|
||||
callback: (r) => {
|
||||
frappe.msgprint(__("Successfully Set Supplier"));
|
||||
dialog.hide();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user