[fix] paging for item group
This commit is contained in:
parent
f92f04bffc
commit
3aa315040f
@ -20,7 +20,13 @@ frappe.ui.form.on("Item Group", {
|
|||||||
frm.trigger("set_root_readonly");
|
frm.trigger("set_root_readonly");
|
||||||
frm.add_custom_button(__("Item Group Tree"), function() {
|
frm.add_custom_button(__("Item Group Tree"), function() {
|
||||||
frappe.set_route("Tree", "Item Group");
|
frappe.set_route("Tree", "Item Group");
|
||||||
}, "icon-sitemap");
|
});
|
||||||
|
|
||||||
|
if(!frm.is_new()) {
|
||||||
|
frm.add_custom_button(__("Items"), function() {
|
||||||
|
frappe.set_route("List", "Item", {"item_group": frm.doc.name});
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
set_root_readonly: function(frm) {
|
set_root_readonly: function(frm) {
|
||||||
|
@ -60,13 +60,15 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
|||||||
|
|
||||||
def get_context(self, context):
|
def get_context(self, context):
|
||||||
context.show_search=True
|
context.show_search=True
|
||||||
|
context.page_length = 6
|
||||||
context.search_link = '/product_search'
|
context.search_link = '/product_search'
|
||||||
|
|
||||||
start = int(frappe.form_dict.start or 0)
|
start = int(frappe.form_dict.start or 0)
|
||||||
if start < 0:
|
if start < 0:
|
||||||
start = 0
|
start = 0
|
||||||
context.update({
|
context.update({
|
||||||
"items": get_product_list_for_group(product_group = self.name, start=start, limit=24, search=frappe.form_dict.get("search")),
|
"items": get_product_list_for_group(product_group = self.name, start=start,
|
||||||
|
limit=context.page_length, search=frappe.form_dict.get("search")),
|
||||||
"parent_groups": get_parent_item_groups(self.name),
|
"parent_groups": get_parent_item_groups(self.name),
|
||||||
"title": self.name,
|
"title": self.name,
|
||||||
"products_as_list": cint(frappe.db.get_single_value('Website Settings', 'products_as_list'))
|
"products_as_list": cint(frappe.db.get_single_value('Website Settings', 'products_as_list'))
|
||||||
|
@ -455,16 +455,18 @@ class Item(WebsiteGenerator):
|
|||||||
|
|
||||||
def cant_change(self):
|
def cant_change(self):
|
||||||
if not self.get("__islocal"):
|
if not self.get("__islocal"):
|
||||||
vals = frappe.db.get_value("Item", self.name, ["has_serial_no", "is_stock_item",
|
to_check = ("has_serial_no", "is_stock_item",
|
||||||
"valuation_method", "has_batch_no", "is_fixed_asset"], as_dict=True)
|
"valuation_method", "has_batch_no", "is_fixed_asset")
|
||||||
|
|
||||||
if vals and ((self.is_stock_item != vals.is_stock_item) or
|
vals = frappe.db.get_value("Item", self.name, to_check, as_dict=True)
|
||||||
vals.has_serial_no != self.has_serial_no or
|
|
||||||
vals.has_batch_no != self.has_batch_no or
|
if vals:
|
||||||
cstr(vals.valuation_method) != cstr(self.valuation_method)):
|
for key in to_check:
|
||||||
if self.check_if_linked_document_exists():
|
if self.get(key) != vals.get(key):
|
||||||
frappe.throw(_("As there are existing transactions for this item, \
|
if not self.check_if_linked_document_exists():
|
||||||
you can not change the values of 'Has Serial No', 'Has Batch No', 'Is Stock Item' and 'Valuation Method'"))
|
break # no linked document, allowed
|
||||||
|
else:
|
||||||
|
frappe.throw(_("As there are existing transactions for this item, you can not change the value of {0}").format(frappe.bold(self.meta.get_label(key))))
|
||||||
|
|
||||||
if vals and not self.is_fixed_asset and self.is_fixed_asset != vals.is_fixed_asset:
|
if vals and not self.is_fixed_asset and self.is_fixed_asset != vals.is_fixed_asset:
|
||||||
asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1)
|
asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1)
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="text-center item-group-nav-buttons">
|
<div class="text-center item-group-nav-buttons">
|
||||||
{% if frappe.form_dict.start|int > 0 %}
|
{% if frappe.form_dict.start|int > 0 %}
|
||||||
<a class="btn btn-default" href="{{ pathname }}?start={{ frappe.form_dict.start|int - 24 }}">Prev</a>
|
<a class="btn btn-default" href="/{{ pathname }}?start={{ frappe.form_dict.start|int - page_length }}">Prev</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if items|length == 24 %}
|
{% if items|length == page_length %}
|
||||||
<a class="btn btn-default" href="{{ pathname }}?start={{ frappe.form_dict.start|int + 24 }}">Next</a>
|
<a class="btn btn-default" href="/{{ pathname }}?start={{ frappe.form_dict.start|int + page_length }}">Next</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user