Merge branch 'develop' into missing_pos_invoice_json

This commit is contained in:
Deepesh Garg 2022-02-28 08:40:48 +05:30 committed by GitHub
commit 6a4975f9f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 86 additions and 63 deletions

View File

@ -3,6 +3,10 @@
frappe.provide("education"); frappe.provide("education");
frappe.ui.form.on('Student Attendance Tool', { frappe.ui.form.on('Student Attendance Tool', {
setup: (frm) => {
frm.students_area = $('<div>')
.appendTo(frm.fields_dict.students_html.wrapper);
},
onload: function(frm) { onload: function(frm) {
frm.set_query("student_group", function() { frm.set_query("student_group", function() {
return { return {
@ -34,6 +38,7 @@ frappe.ui.form.on('Student Attendance Tool', {
student_group: function(frm) { student_group: function(frm) {
if ((frm.doc.student_group && frm.doc.date) || frm.doc.course_schedule) { if ((frm.doc.student_group && frm.doc.date) || frm.doc.course_schedule) {
frm.students_area.find('.student-attendance-checks').html(`<div style='padding: 2rem 0'>Fetching...</div>`);
var method = "erpnext.education.doctype.student_attendance_tool.student_attendance_tool.get_student_attendance_records"; var method = "erpnext.education.doctype.student_attendance_tool.student_attendance_tool.get_student_attendance_records";
frappe.call({ frappe.call({
@ -62,10 +67,6 @@ frappe.ui.form.on('Student Attendance Tool', {
}, },
get_students: function(frm, students) { get_students: function(frm, students) {
if (!frm.students_area) {
frm.students_area = $('<div>')
.appendTo(frm.fields_dict.students_html.wrapper);
}
students = students || []; students = students || [];
frm.students_editor = new education.StudentsEditor(frm, frm.students_area, students); frm.students_editor = new education.StudentsEditor(frm, frm.students_area, students);
} }
@ -163,16 +164,26 @@ education.StudentsEditor = class StudentsEditor {
); );
}); });
var htmls = students.map(function(student) { // make html grid of students
return frappe.render_template("student_button", { let student_html = '';
student: student.student, for (let student of students) {
student_name: student.student_name, student_html += `<div class="col-sm-3">
group_roll_number: student.group_roll_number, <div class="checkbox">
status: student.status <label>
}) <input
}); type="checkbox"
data-group_roll_number="${student.group_roll_number}"
data-student="${student.student}"
data-student-name="${student.student_name}"
class="students-check"
${student.status==='Present' ? 'checked' : ''}>
${student.group_roll_number} - ${student.student_name}
</label>
</div>
</div>`;
}
$(htmls.join("")).appendTo(me.wrapper); $(`<div class='student-attendance-checks'>${student_html}</div>`).appendTo(me.wrapper);
} }
show_empty_state() { show_empty_state() {

View File

@ -24,24 +24,24 @@ def get_student_attendance_records(based_on, date=None, student_group=None, cour
student_list = frappe.get_all("Student Group Student", fields=["student", "student_name", "group_roll_number"], student_list = frappe.get_all("Student Group Student", fields=["student", "student_name", "group_roll_number"],
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number") filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
table = frappe.qb.DocType("Student Attendance") StudentAttendance = frappe.qb.DocType("Student Attendance")
if course_schedule: if course_schedule:
student_attendance_list = ( student_attendance_list = (
frappe.qb.from_(table) frappe.qb.from_(StudentAttendance)
.select(table.student, table.status) .select(StudentAttendance.student, StudentAttendance.status)
.where( .where(
(table.course_schedule == course_schedule) (StudentAttendance.course_schedule == course_schedule)
) )
).run(as_dict=True) ).run(as_dict=True)
else: else:
student_attendance_list = ( student_attendance_list = (
frappe.qb.from_(table) frappe.qb.from_(StudentAttendance)
.select(table.student, table.status) .select(StudentAttendance.student, StudentAttendance.status)
.where( .where(
(table.student_group == student_group) (StudentAttendance.student_group == student_group)
& (table.date == date) & (StudentAttendance.date == date)
& (table.course_schedule == "") | (table.course_schedule.isnull()) & ((StudentAttendance.course_schedule == "") | (StudentAttendance.course_schedule.isnull()))
) )
).run(as_dict=True) ).run(as_dict=True)

View File

@ -9,6 +9,7 @@ from erpnext.manufacturing.doctype.production_plan.production_plan import (
get_sales_orders, get_sales_orders,
get_warehouse_list, get_warehouse_list,
) )
from erpnext.manufacturing.doctype.work_order.work_order import OverProductionError
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.stock.doctype.item.test_item import create_item from erpnext.stock.doctype.item.test_item import create_item
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
@ -466,26 +467,29 @@ class TestProductionPlan(ERPNextTestCase):
bom = make_bom(item=item, raw_materials=raw_materials) bom = make_bom(item=item, raw_materials=raw_materials)
# Create Production Plan # Create Production Plan
pln = create_production_plan(item_code=bom.item, planned_qty=10) pln = create_production_plan(item_code=bom.item, planned_qty=5)
# All the created Work Orders # All the created Work Orders
wo_list = [] wo_list = []
# Create and Submit 1st Work Order for 5 qty # Create and Submit 1st Work Order for 3 qty
create_work_order(item, pln, 5) create_work_order(item, pln, 3)
pln.reload()
self.assertEqual(pln.po_items[0].ordered_qty, 3)
# Create and Submit 2nd Work Order for 2 qty
create_work_order(item, pln, 2)
pln.reload() pln.reload()
self.assertEqual(pln.po_items[0].ordered_qty, 5) self.assertEqual(pln.po_items[0].ordered_qty, 5)
# Create and Submit 2nd Work Order for 3 qty # Overproduction
create_work_order(item, pln, 3) self.assertRaises(OverProductionError, create_work_order, item=item, pln=pln, qty=2)
pln.reload()
self.assertEqual(pln.po_items[0].ordered_qty, 8)
# Cancel 1st Work Order # Cancel 1st Work Order
wo1 = frappe.get_doc("Work Order", wo_list[0]) wo1 = frappe.get_doc("Work Order", wo_list[0])
wo1.cancel() wo1.cancel()
pln.reload() pln.reload()
self.assertEqual(pln.po_items[0].ordered_qty, 3) self.assertEqual(pln.po_items[0].ordered_qty, 2)
# Cancel 2nd Work Order # Cancel 2nd Work Order
wo2 = frappe.get_doc("Work Order", wo_list[1]) wo2 = frappe.get_doc("Work Order", wo_list[1])

View File

@ -636,6 +636,21 @@ class WorkOrder(Document):
if not self.qty > 0: if not self.qty > 0:
frappe.throw(_("Quantity to Manufacture must be greater than 0.")) frappe.throw(_("Quantity to Manufacture must be greater than 0."))
if self.production_plan and self.production_plan_item:
qty_dict = frappe.db.get_value("Production Plan Item", self.production_plan_item, ["planned_qty", "ordered_qty"], as_dict=1)
allowance_qty =flt(frappe.db.get_single_value("Manufacturing Settings",
"overproduction_percentage_for_work_order"))/100 * qty_dict.get("planned_qty", 0)
max_qty = qty_dict.get("planned_qty", 0) + allowance_qty - qty_dict.get("ordered_qty", 0)
if max_qty < 1:
frappe.throw(_("Cannot produce more item for {0}")
.format(self.production_item), OverProductionError)
elif self.qty > max_qty:
frappe.throw(_("Cannot produce more than {0} items for {1}")
.format(max_qty, self.production_item), OverProductionError)
def validate_transfer_against(self): def validate_transfer_against(self):
if not self.docstatus == 1: if not self.docstatus == 1:
# let user configure operations until they're ready to submit # let user configure operations until they're ready to submit

View File

@ -1,17 +0,0 @@
<div class="col-sm-3">
<div class="checkbox">
<label>
<input
type="checkbox"
data-group_roll_number="{{group_roll_number}}"
data-student="{{student}}"
data-student-name="{{student_name}}"
class="students-check"
{% if status === "Present" %}
checked
{% endif %}
>
{{ group_roll_number }} - {{ student_name }}
</label>
</div>
</div>

View File

@ -16,7 +16,6 @@ import "./templates/item_quick_entry.html";
import "./utils/item_quick_entry"; import "./utils/item_quick_entry";
import "./utils/customer_quick_entry"; import "./utils/customer_quick_entry";
import "./utils/supplier_quick_entry"; import "./utils/supplier_quick_entry";
import "./education/student_button.html";
import "./education/assessment_result_tool.html"; import "./education/assessment_result_tool.html";
import "./call_popup/call_popup"; import "./call_popup/call_popup";
import "./utils/dimension_tree_filter"; import "./utils/dimension_tree_filter";

View File

@ -304,12 +304,13 @@ erpnext.HierarchyChart = class {
} }
get_child_nodes(node_id) { get_child_nodes(node_id) {
let me = this;
return new Promise(resolve => { return new Promise(resolve => {
frappe.call({ frappe.call({
method: this.method, method: me.method,
args: { args: {
parent: node_id, parent: node_id,
company: this.company company: me.company
} }
}).then(r => resolve(r.message)); }).then(r => resolve(r.message));
}); });
@ -350,12 +351,13 @@ erpnext.HierarchyChart = class {
} }
get_all_nodes() { get_all_nodes() {
let me = this;
return new Promise(resolve => { return new Promise(resolve => {
frappe.call({ frappe.call({
method: 'erpnext.utilities.hierarchy_chart.get_all_nodes', method: 'erpnext.utilities.hierarchy_chart.get_all_nodes',
args: { args: {
method: this.method, method: me.method,
company: this.company company: me.company
}, },
callback: (r) => { callback: (r) => {
resolve(r.message); resolve(r.message);
@ -427,8 +429,8 @@ erpnext.HierarchyChart = class {
add_connector(parent_id, child_id) { add_connector(parent_id, child_id) {
// using pure javascript for better performance // using pure javascript for better performance
const parent_node = document.querySelector(`#${parent_id}`); const parent_node = document.getElementById(`${parent_id}`);
const child_node = document.querySelector(`#${child_id}`); const child_node = document.getElementById(`${child_id}`);
let path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');

View File

@ -235,7 +235,7 @@ erpnext.HierarchyChartMobile = class {
let me = this; let me = this;
return new Promise(resolve => { return new Promise(resolve => {
frappe.call({ frappe.call({
method: this.method, method: me.method,
args: { args: {
parent: node_id, parent: node_id,
company: me.company, company: me.company,
@ -286,8 +286,8 @@ erpnext.HierarchyChartMobile = class {
} }
add_connector(parent_id, child_id) { add_connector(parent_id, child_id) {
const parent_node = document.querySelector(`#${parent_id}`); const parent_node = document.getElementById(`${parent_id}`);
const child_node = document.querySelector(`#${child_id}`); const child_node = document.getElementById(`${child_id}`);
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
@ -518,7 +518,8 @@ erpnext.HierarchyChartMobile = class {
level.nextAll('li').remove(); level.nextAll('li').remove();
let node_object = this.nodes[node.id]; let node_object = this.nodes[node.id];
let current_node = level.find(`#${node.id}`).detach(); let current_node = level.find(`[id="${node.id}"]`).detach();
current_node.removeClass('active-child active-path'); current_node.removeClass('active-child active-path');
node_object.expanded = 0; node_object.expanded = 0;

View File

@ -629,6 +629,12 @@ frappe.ui.form.on('Stock Entry Detail', {
frm.events.set_serial_no(frm, cdt, cdn, () => { frm.events.set_serial_no(frm, cdt, cdn, () => {
frm.events.get_warehouse_details(frm, cdt, cdn); frm.events.get_warehouse_details(frm, cdt, cdn);
}); });
// set allow_zero_valuation_rate to 0 if s_warehouse is selected.
let item = frappe.get_doc(cdt, cdn);
if (item.s_warehouse) {
item.allow_zero_valuation_rate = 0;
}
}, },
t_warehouse: function(frm, cdt, cdn) { t_warehouse: function(frm, cdt, cdn) {

View File

@ -1,7 +1,7 @@
{ {
"actions": [], "actions": [],
"autoname": "hash", "autoname": "hash",
"creation": "2013-03-29 18:22:12", "creation": "2022-02-05 00:17:49.860824",
"doctype": "DocType", "doctype": "DocType",
"document_type": "Other", "document_type": "Other",
"editable_grid": 1, "editable_grid": 1,
@ -340,13 +340,13 @@
"label": "More Information" "label": "More Information"
}, },
{ {
"allow_on_submit": 1,
"default": "0", "default": "0",
"fieldname": "allow_zero_valuation_rate", "fieldname": "allow_zero_valuation_rate",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Allow Zero Valuation Rate", "label": "Allow Zero Valuation Rate",
"no_copy": 1, "no_copy": 1,
"print_hide": 1 "print_hide": 1,
"read_only_depends_on": "eval:doc.s_warehouse"
}, },
{ {
"allow_on_submit": 1, "allow_on_submit": 1,
@ -556,12 +556,14 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2021-06-22 16:47:11.268975", "modified": "2022-02-26 00:51:24.963653",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Stock Entry Detail", "name": "Stock Entry Detail",
"naming_rule": "Random",
"owner": "Administrator", "owner": "Administrator",
"permissions": [], "permissions": [],
"sort_field": "modified", "sort_field": "modified",
"sort_order": "ASC" "sort_order": "ASC",
"states": []
} }