Merge branch 'version-13-hotfix' of https://github.com/frappe/erpnext into dynamic_gst_rates

This commit is contained in:
Deepesh Garg
2021-06-10 18:56:39 +05:30
503 changed files with 2108 additions and 11728 deletions

View File

@@ -259,11 +259,19 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
if(!in_list(["Delivery Note", "Sales Invoice", "Purchase Receipt", "Purchase Invoice"], this.frm.doc.doctype)) {
return;
}
var me = this;
var inspection_type = in_list(["Purchase Receipt", "Purchase Invoice"], this.frm.doc.doctype)
const me = this;
if (!this.frm.is_new() && this.frm.doc.docstatus === 0) {
this.frm.add_custom_button(__("Quality Inspection(s)"), () => {
me.make_quality_inspection();
}, __("Create"));
this.frm.page.set_inner_btn_group_as_primary(__('Create'));
}
const inspection_type = in_list(["Purchase Receipt", "Purchase Invoice"], this.frm.doc.doctype)
? "Incoming" : "Outgoing";
var quality_inspection_field = this.frm.get_docfield("items", "quality_inspection");
let quality_inspection_field = this.frm.get_docfield("items", "quality_inspection");
quality_inspection_field.get_route_options_for_new_doc = function(row) {
if(me.frm.is_new()) return;
return {
@@ -278,7 +286,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}
this.frm.set_query("quality_inspection", "items", function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
let d = locals[cdt][cdn];
return {
filters: {
docstatus: 1,
@@ -1891,6 +1899,130 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
});
},
make_quality_inspection: function () {
let data = [];
const fields = [
{
label: "Items",
fieldtype: "Table",
fieldname: "items",
cannot_add_rows: true,
in_place_edit: true,
data: data,
get_data: () => {
return data;
},
fields: [
{
fieldtype: "Data",
fieldname: "docname",
hidden: true
},
{
fieldtype: "Read Only",
fieldname: "item_code",
label: __("Item Code"),
in_list_view: true
},
{
fieldtype: "Read Only",
fieldname: "item_name",
label: __("Item Name"),
in_list_view: true
},
{
fieldtype: "Float",
fieldname: "qty",
label: __("Accepted Quantity"),
in_list_view: true,
read_only: true
},
{
fieldtype: "Float",
fieldname: "sample_size",
label: __("Sample Size"),
reqd: true,
in_list_view: true
},
{
fieldtype: "Data",
fieldname: "description",
label: __("Description"),
hidden: true
},
{
fieldtype: "Data",
fieldname: "serial_no",
label: __("Serial No"),
hidden: true
},
{
fieldtype: "Data",
fieldname: "batch_no",
label: __("Batch No"),
hidden: true
}
]
}
];
const me = this;
const dialog = new frappe.ui.Dialog({
title: __("Select Items for Quality Inspection"),
fields: fields,
primary_action: function () {
const data = dialog.get_values();
frappe.call({
method: "erpnext.controllers.stock_controller.make_quality_inspections",
args: {
doctype: me.frm.doc.doctype,
docname: me.frm.doc.name,
items: data.items
},
freeze: true,
callback: function (r) {
if (r.message.length > 0) {
if (r.message.length === 1) {
frappe.set_route("Form", "Quality Inspection", r.message[0]);
} else {
frappe.route_options = {
"reference_type": me.frm.doc.doctype,
"reference_name": me.frm.doc.name
};
frappe.set_route("List", "Quality Inspection");
}
}
dialog.hide();
}
});
},
primary_action_label: __("Create")
});
this.frm.doc.items.forEach(item => {
if (!item.quality_inspection) {
let dialog_items = dialog.fields_dict.items;
dialog_items.df.data.push({
"docname": item.name,
"item_code": item.item_code,
"item_name": item.item_name,
"qty": item.qty,
"description": item.description,
"serial_no": item.serial_no,
"batch_no": item.batch_no
});
dialog_items.grid.refresh();
}
});
data = dialog.fields_dict.items.df.data;
if (!data.length) {
frappe.msgprint(__("All items in this document already have a linked Quality Inspection."));
} else {
dialog.show();
}
},
get_method_for_payment: function(){
var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
if(cur_frm.doc.__onload && cur_frm.doc.__onload.make_payment_via_journal_entry){

View File

@@ -20,10 +20,8 @@ class Quiz {
}
make(data) {
if (data.duration) {
const timer_display = document.createElement("div");
timer_display.classList.add("lms-timer", "float-right", "font-weight-bold");
document.getElementsByClassName("lms-title")[0].appendChild(timer_display);
if (data.is_time_bound) {
$(".lms-timer").removeClass("hide");
if (!data.activity || (data.activity && !data.activity.is_complete)) {
this.initialiseTimer(data.duration);
this.is_time_bound = true;
@@ -118,7 +116,7 @@ class Quiz {
quiz_response: this.get_selected(),
course: this.course,
program: this.program,
time_taken: this.is_time_bound ? this.time_taken : ""
time_taken: this.is_time_bound ? this.time_taken : 0
}).then(res => {
this.submit_btn.remove()
if (!res.message) {
@@ -237,4 +235,4 @@ class Question {
this.options = option_list
this.wrapper.appendChild(options_wrapper)
}
}
}