Merge pull request #7412 from nabinhait/hotfix
Allow fetching same items multiple times from source doc if all qty not processed
This commit is contained in:
commit
f0c41b5709
@ -55,7 +55,8 @@ class Task(Document):
|
||||
def update_depends_on(self):
|
||||
depends_on_tasks = ""
|
||||
for d in self.depends_on:
|
||||
depends_on_tasks += d.task + ","
|
||||
if d.task:
|
||||
depends_on_tasks += d.task + ","
|
||||
self.depends_on_tasks = depends_on_tasks
|
||||
|
||||
def on_update(self):
|
||||
|
@ -153,22 +153,37 @@ erpnext.utils.map_current_doc = function(opts) {
|
||||
frappe.get_meta(items_doctype).fields.forEach(function(d) {
|
||||
if(d.options===opts.source_doctype) link_fieldname = d.fieldname; });
|
||||
|
||||
// search in existing items if the source_name is already set
|
||||
// search in existing items if the source_name is already set and full qty fetched
|
||||
var already_set = false;
|
||||
|
||||
var item_qty_map = {};
|
||||
|
||||
$.each(cur_frm.doc.items, function(i, d) {
|
||||
if(d[link_fieldname]==opts.source_name) {
|
||||
already_set = true;
|
||||
return false;
|
||||
if (item_qty_map[d.item_code])
|
||||
item_qty_map[d.item_code] += flt(d.qty);
|
||||
else
|
||||
item_qty_map[d.item_code] = flt(d.qty);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(already_set) {
|
||||
frappe.msgprint(__("You have already selected items from {0} {1}",
|
||||
[opts.source_doctype, opts.source_name]));
|
||||
return;
|
||||
}
|
||||
frappe.model.with_doc(opts.source_doctype, opts.source_name, function(r) {
|
||||
var source_doc = frappe.model.get_doc(opts.source_doctype, opts.source_name);
|
||||
$.each(source_doc.items || [], function(i, row) {
|
||||
if(row.qty > flt(item_qty_map[row.item_code])) {
|
||||
already_set = false;
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
if(already_set) {
|
||||
frappe.msgprint(__("You have already selected items from {0} {1}",
|
||||
[opts.source_doctype, opts.source_name]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import get_datetime
|
||||
from frappe.utils import getdate
|
||||
from frappe.model.document import Document
|
||||
|
||||
class AcademicTerm(Document):
|
||||
@ -18,16 +18,18 @@ class AcademicTerm(Document):
|
||||
self.title = self.academic_year + " ({})".format(self.term_name) if self.term_name else ""
|
||||
|
||||
#Check that start of academic year is earlier than end of academic year
|
||||
if self.term_start_date and self.term_end_date and self.term_start_date > self.term_end_date:
|
||||
if self.term_start_date and self.term_end_date \
|
||||
and getdate(self.term_start_date) > getdate(self.term_end_date):
|
||||
frappe.throw(_("The Term End Date cannot be earlier than the Term Start Date. Please correct the dates and try again."))
|
||||
|
||||
"""Check that the start of the term is not before the start of the academic year and end of term is not after
|
||||
the end of the academic year"""
|
||||
# Check that the start of the term is not before the start of the academic year
|
||||
# and end of term is not after the end of the academic year"""
|
||||
|
||||
year = frappe.get_doc("Academic Year",self.academic_year)
|
||||
if self.term_start_date and get_datetime(year.year_start_date) and (self.term_start_date < get_datetime(year.year_start_date)):
|
||||
if self.term_start_date and getdate(year.year_start_date) and (getdate(self.term_start_date) < getdate(year.year_start_date)):
|
||||
frappe.throw(_("The Term Start Date cannot be earlier than the Year Start Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))
|
||||
|
||||
if self.term_end_date and get_datetime(year.year_end_date) and (self.term_end_date > get_datetime(year.year_end_date)):
|
||||
if self.term_end_date and getdate(year.year_end_date) and (getdate(self.term_end_date) > getdate(year.year_end_date)):
|
||||
frappe.throw(_("The Term End Date cannot be later than the Year End Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user