mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-01 23:53:21 +00:00
Merge branch 'develop' into remove-nonprofit
This commit is contained in:
@@ -1,270 +1,111 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:brand",
|
||||
"beta": 0,
|
||||
"creation": "2013-02-22 01:27:54",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Setup",
|
||||
"editable_grid": 0,
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:brand",
|
||||
"creation": "2013-02-22 01:27:54",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Setup",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"brand",
|
||||
"image",
|
||||
"description",
|
||||
"defaults",
|
||||
"brand_defaults"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 1,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "brand",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Brand Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "brand",
|
||||
"oldfieldtype": "Data",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"allow_in_quick_entry": 1,
|
||||
"fieldname": "brand",
|
||||
"fieldtype": "Data",
|
||||
"label": "Brand Name",
|
||||
"oldfieldname": "brand",
|
||||
"oldfieldtype": "Data",
|
||||
"reqd": 1,
|
||||
"unique": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Description",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Text",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text",
|
||||
"in_list_view": 1,
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Text",
|
||||
"width": "300px"
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "defaults",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Defaults",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
"fieldname": "defaults",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Defaults"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "brand_defaults",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Brand Defaults",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Item Default",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"fieldname": "brand_defaults",
|
||||
"fieldtype": "Table",
|
||||
"label": "Brand Defaults",
|
||||
"options": "Item Default"
|
||||
},
|
||||
{
|
||||
"fieldname": "image",
|
||||
"fieldtype": "Attach Image",
|
||||
"hidden": 1,
|
||||
"label": "Image"
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"icon": "fa fa-certificate",
|
||||
"idx": 1,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-10-23 23:18:06.067612",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Brand",
|
||||
"owner": "Administrator",
|
||||
],
|
||||
"icon": "fa fa-certificate",
|
||||
"idx": 1,
|
||||
"image_field": "image",
|
||||
"links": [],
|
||||
"modified": "2021-03-01 15:57:30.005783",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Brand",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 0,
|
||||
"import": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Item Manager",
|
||||
"set_user_permissions": 0,
|
||||
"share": 1,
|
||||
"submit": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"import": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Item Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 1,
|
||||
"export": 0,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Stock User",
|
||||
"set_user_permissions": 0,
|
||||
"share": 0,
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
"email": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Stock User"
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 1,
|
||||
"export": 0,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Sales User",
|
||||
"set_user_permissions": 0,
|
||||
"share": 0,
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
"email": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Sales User"
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 1,
|
||||
"export": 0,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Purchase User",
|
||||
"set_user_permissions": 0,
|
||||
"share": 0,
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
"email": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Purchase User"
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 1,
|
||||
"export": 0,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Accounts User",
|
||||
"set_user_permissions": 0,
|
||||
"share": 0,
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
"email": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Accounts User"
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_order": "ASC",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "ASC"
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:company_name",
|
||||
"creation": "2013-04-10 08:35:39",
|
||||
"creation": "2022-01-25 10:29:55.938239",
|
||||
"description": "Legal Entity / Subsidiary with a separate Chart of Accounts belonging to the Organization.",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Setup",
|
||||
@@ -77,13 +77,13 @@
|
||||
"default_finance_book",
|
||||
"auto_accounting_for_stock_settings",
|
||||
"enable_perpetual_inventory",
|
||||
"enable_perpetual_inventory_for_non_stock_items",
|
||||
"enable_provisional_accounting_for_non_stock_items",
|
||||
"default_inventory_account",
|
||||
"stock_adjustment_account",
|
||||
"default_in_transit_warehouse",
|
||||
"column_break_32",
|
||||
"stock_received_but_not_billed",
|
||||
"service_received_but_not_billed",
|
||||
"default_provisional_account",
|
||||
"expenses_included_in_valuation",
|
||||
"fixed_asset_defaults",
|
||||
"accumulated_depreciation_account",
|
||||
@@ -684,20 +684,6 @@
|
||||
"label": "Default Buying Terms",
|
||||
"options": "Terms and Conditions"
|
||||
},
|
||||
{
|
||||
"fieldname": "service_received_but_not_billed",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Service Received But Not Billed",
|
||||
"no_copy": 1,
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enable_perpetual_inventory_for_non_stock_items",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Perpetual Inventory For Non Stock Items"
|
||||
},
|
||||
{
|
||||
"fieldname": "default_in_transit_warehouse",
|
||||
"fieldtype": "Link",
|
||||
@@ -741,6 +727,20 @@
|
||||
"fieldname": "section_break_28",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Chart of Accounts"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enable_provisional_accounting_for_non_stock_items",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Provisional Accounting For Non Stock Items"
|
||||
},
|
||||
{
|
||||
"fieldname": "default_provisional_account",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Default Provisional Account",
|
||||
"no_copy": 1,
|
||||
"options": "Account"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-building",
|
||||
@@ -748,7 +748,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2021-10-04 12:09:25.833133",
|
||||
"modified": "2022-01-25 10:33:16.826067",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
@@ -809,5 +809,6 @@
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "ASC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import frappe.defaults
|
||||
from frappe import _
|
||||
from frappe.cache_manager import clear_defaults_cache
|
||||
from frappe.contacts.address_and_contact import load_address_and_contact
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
from frappe.utils import cint, formatdate, get_timestamp, today
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
|
||||
@@ -45,7 +46,7 @@ class Company(NestedSet):
|
||||
self.validate_currency()
|
||||
self.validate_coa_input()
|
||||
self.validate_perpetual_inventory()
|
||||
self.validate_perpetual_inventory_for_non_stock_items()
|
||||
self.validate_provisional_account_for_non_stock_items()
|
||||
self.check_country_change()
|
||||
self.check_parent_changed()
|
||||
self.set_chart_of_accounts()
|
||||
@@ -187,11 +188,14 @@ class Company(NestedSet):
|
||||
frappe.msgprint(_("Set default inventory account for perpetual inventory"),
|
||||
alert=True, indicator='orange')
|
||||
|
||||
def validate_perpetual_inventory_for_non_stock_items(self):
|
||||
def validate_provisional_account_for_non_stock_items(self):
|
||||
if not self.get("__islocal"):
|
||||
if cint(self.enable_perpetual_inventory_for_non_stock_items) == 1 and not self.service_received_but_not_billed:
|
||||
frappe.throw(_("Set default {0} account for perpetual inventory for non stock items").format(
|
||||
frappe.bold('Service Received But Not Billed')))
|
||||
if cint(self.enable_provisional_accounting_for_non_stock_items) == 1 and not self.default_provisional_account:
|
||||
frappe.throw(_("Set default {0} account for non stock items").format(
|
||||
frappe.bold('Provisional Account')))
|
||||
|
||||
make_property_setter("Purchase Receipt", "provisional_expense_account", "hidden",
|
||||
not self.enable_provisional_accounting_for_non_stock_items, "Check", validate_fields_for_doctype=False)
|
||||
|
||||
def check_country_change(self):
|
||||
frappe.flags.country_change = False
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
import copy
|
||||
from urllib.parse import quote
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import cint, cstr, nowdate
|
||||
from frappe.utils import cint
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
from frappe.website.utils import clear_cache
|
||||
from frappe.website.website_generator import WebsiteGenerator
|
||||
from six.moves.urllib.parse import quote
|
||||
|
||||
from erpnext.shopping_cart.filters import ProductFiltersBuilder
|
||||
from erpnext.shopping_cart.product_info import set_product_info_for_website
|
||||
from erpnext.shopping_cart.product_query import ProductQuery
|
||||
from erpnext.utilities.product import get_qty_in_stock
|
||||
from erpnext.e_commerce.product_data_engine.filters import ProductFiltersBuilder
|
||||
|
||||
|
||||
class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
@@ -67,30 +63,11 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
self.delete_child_item_groups_key()
|
||||
|
||||
def get_context(self, context):
|
||||
context.show_search=True
|
||||
context.page_length = cint(frappe.db.get_single_value('Products Settings', 'products_per_page')) or 6
|
||||
context.show_search = True
|
||||
context.body_class = "product-page"
|
||||
context.page_length = cint(frappe.db.get_single_value('E Commerce Settings', 'products_per_page')) or 6
|
||||
context.search_link = '/product_search'
|
||||
|
||||
if frappe.form_dict:
|
||||
search = frappe.form_dict.search
|
||||
field_filters = frappe.parse_json(frappe.form_dict.field_filters)
|
||||
attribute_filters = frappe.parse_json(frappe.form_dict.attribute_filters)
|
||||
start = frappe.parse_json(frappe.form_dict.start)
|
||||
else:
|
||||
search = None
|
||||
attribute_filters = None
|
||||
field_filters = {}
|
||||
start = 0
|
||||
|
||||
if not field_filters:
|
||||
field_filters = {}
|
||||
|
||||
# Ensure the query remains within current item group & sub group
|
||||
field_filters['item_group'] = [ig[0] for ig in get_child_groups(self.name)]
|
||||
|
||||
engine = ProductQuery()
|
||||
context.items = engine.query(attribute_filters, field_filters, search, start, item_group=self.name)
|
||||
|
||||
filter_engine = ProductFiltersBuilder(self.name)
|
||||
|
||||
context.field_filters = filter_engine.get_field_filters()
|
||||
@@ -114,15 +91,16 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
values[f"slide_{index + 1}_image"] = slide.image
|
||||
values[f"slide_{index + 1}_title"] = slide.heading
|
||||
values[f"slide_{index + 1}_subtitle"] = slide.description
|
||||
values[f"slide_{index + 1}_theme"] = slide.theme or "Light"
|
||||
values[f"slide_{index + 1}_content_align"] = slide.content_align or "Centre"
|
||||
values[f"slide_{index + 1}_primary_action_label"] = slide.label
|
||||
values[f"slide_{index + 1}_theme"] = slide.get("theme") or "Light"
|
||||
values[f"slide_{index + 1}_content_align"] = slide.get("content_align") or "Centre"
|
||||
values[f"slide_{index + 1}_primary_action"] = slide.url
|
||||
|
||||
context.slideshow = values
|
||||
|
||||
context.breadcrumbs = 0
|
||||
context.no_breadcrumbs = False
|
||||
context.title = self.website_title or self.name
|
||||
context.name = self.name
|
||||
context.item_group_name = self.item_group_name
|
||||
|
||||
return context
|
||||
|
||||
@@ -133,91 +111,24 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
from erpnext.stock.doctype.item.item import validate_item_default_company_links
|
||||
validate_item_default_company_links(self.item_group_defaults)
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_product_list_for_group(product_group=None, start=0, limit=10, search=None):
|
||||
if product_group:
|
||||
item_group = frappe.get_cached_doc('Item Group', product_group)
|
||||
if item_group.is_group:
|
||||
# return child item groups if the type is of "Is Group"
|
||||
return get_child_groups_for_list_in_html(item_group, start, limit, search)
|
||||
def get_child_groups_for_website(item_group_name, immediate=False):
|
||||
"""Returns child item groups *excluding* passed group."""
|
||||
item_group = frappe.get_cached_value("Item Group", item_group_name, ["lft", "rgt"], as_dict=1)
|
||||
filters = {
|
||||
"lft": [">", item_group.lft],
|
||||
"rgt": ["<", item_group.rgt],
|
||||
"show_in_website": 1
|
||||
}
|
||||
|
||||
child_groups = ", ".join(frappe.db.escape(i[0]) for i in get_child_groups(product_group))
|
||||
if immediate:
|
||||
filters["parent_item_group"] = item_group_name
|
||||
|
||||
# base query
|
||||
query = """select I.name, I.item_name, I.item_code, I.route, I.image, I.website_image, I.thumbnail, I.item_group,
|
||||
I.description, I.web_long_description as website_description, I.is_stock_item,
|
||||
case when (S.actual_qty - S.reserved_qty) > 0 then 1 else 0 end as in_stock, I.website_warehouse,
|
||||
I.has_batch_no
|
||||
from `tabItem` I
|
||||
left join tabBin S on I.item_code = S.item_code and I.website_warehouse = S.warehouse
|
||||
where I.show_in_website = 1
|
||||
and I.disabled = 0
|
||||
and (I.end_of_life is null or I.end_of_life='0000-00-00' or I.end_of_life > %(today)s)
|
||||
and (I.variant_of = '' or I.variant_of is null)
|
||||
and (I.item_group in ({child_groups})
|
||||
or I.name in (select parent from `tabWebsite Item Group` where item_group in ({child_groups})))
|
||||
""".format(child_groups=child_groups)
|
||||
# search term condition
|
||||
if search:
|
||||
query += """ and (I.web_long_description like %(search)s
|
||||
or I.item_name like %(search)s
|
||||
or I.name like %(search)s)"""
|
||||
search = "%" + cstr(search) + "%"
|
||||
|
||||
query += """order by I.weightage desc, in_stock desc, I.modified desc limit %s, %s""" % (cint(start), cint(limit))
|
||||
|
||||
data = frappe.db.sql(query, {"product_group": product_group,"search": search, "today": nowdate()}, as_dict=1)
|
||||
data = adjust_qty_for_expired_items(data)
|
||||
|
||||
if cint(frappe.db.get_single_value("Shopping Cart Settings", "enabled")):
|
||||
for item in data:
|
||||
set_product_info_for_website(item)
|
||||
|
||||
return data
|
||||
|
||||
def get_child_groups_for_list_in_html(item_group, start, limit, search):
|
||||
search_filters = None
|
||||
if search_filters:
|
||||
search_filters = [
|
||||
dict(name = ('like', '%{}%'.format(search))),
|
||||
dict(description = ('like', '%{}%'.format(search)))
|
||||
]
|
||||
data = frappe.db.get_all('Item Group',
|
||||
fields = ['name', 'route', 'description', 'image'],
|
||||
filters = dict(
|
||||
show_in_website = 1,
|
||||
parent_item_group = item_group.name,
|
||||
lft = ('>', item_group.lft),
|
||||
rgt = ('<', item_group.rgt),
|
||||
),
|
||||
or_filters = search_filters,
|
||||
order_by = 'weightage desc, name asc',
|
||||
start = start,
|
||||
limit = limit
|
||||
return frappe.get_all(
|
||||
"Item Group",
|
||||
filters=filters,
|
||||
fields=["name", "route"]
|
||||
)
|
||||
|
||||
return data
|
||||
|
||||
def adjust_qty_for_expired_items(data):
|
||||
adjusted_data = []
|
||||
|
||||
for item in data:
|
||||
if item.get('has_batch_no') and item.get('website_warehouse'):
|
||||
stock_qty_dict = get_qty_in_stock(
|
||||
item.get('name'), 'website_warehouse', item.get('website_warehouse'))
|
||||
qty = stock_qty_dict.stock_qty[0][0] if stock_qty_dict.stock_qty else 0
|
||||
item['in_stock'] = 1 if qty else 0
|
||||
adjusted_data.append(item)
|
||||
|
||||
return adjusted_data
|
||||
|
||||
|
||||
def get_child_groups(item_group_name):
|
||||
item_group = frappe.get_doc("Item Group", item_group_name)
|
||||
return frappe.db.sql("""select name
|
||||
from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s
|
||||
and show_in_website = 1""", {"lft": item_group.lft, "rgt": item_group.rgt})
|
||||
|
||||
def get_child_item_groups(item_group_name):
|
||||
item_group = frappe.get_cached_value("Item Group",
|
||||
item_group_name, ["lft", "rgt"], as_dict=1)
|
||||
@@ -233,31 +144,33 @@ def get_item_for_list_in_html(context):
|
||||
if (context.get("website_image") or "").startswith("files/"):
|
||||
context["website_image"] = "/" + quote(context["website_image"])
|
||||
|
||||
context["show_availability_status"] = cint(frappe.db.get_single_value('Products Settings',
|
||||
context["show_availability_status"] = cint(frappe.db.get_single_value('E Commerce Settings',
|
||||
'show_availability_status'))
|
||||
|
||||
products_template = 'templates/includes/products_as_list.html'
|
||||
|
||||
return frappe.get_template(products_template).render(context)
|
||||
|
||||
def get_group_item_count(item_group):
|
||||
child_groups = ", ".join('"' + i[0] + '"' for i in get_child_groups(item_group))
|
||||
return frappe.db.sql("""select count(*) from `tabItem`
|
||||
where docstatus = 0 and show_in_website = 1
|
||||
and (item_group in (%s)
|
||||
or name in (select parent from `tabWebsite Item Group`
|
||||
where item_group in (%s))) """ % (child_groups, child_groups))[0][0]
|
||||
|
||||
def get_parent_item_groups(item_group_name, from_item=False):
|
||||
base_nav_page = {"name": _("Shop by Category"), "route":"/shop-by-category"}
|
||||
|
||||
if from_item and frappe.request.environ.get("HTTP_REFERER"):
|
||||
# base page after 'Home' will vary on Item page
|
||||
last_page = frappe.request.environ["HTTP_REFERER"].split('/')[-1]
|
||||
if last_page and last_page in ("shop-by-category", "all-products"):
|
||||
base_nav_page_title = " ".join(last_page.split("-")).title()
|
||||
base_nav_page = {"name": _(base_nav_page_title), "route":"/"+last_page}
|
||||
|
||||
def get_parent_item_groups(item_group_name):
|
||||
base_parents = [
|
||||
{"name": frappe._("Home"), "route":"/"},
|
||||
{"name": frappe._("All Products"), "route":"/all-products"},
|
||||
{"name": _("Home"), "route":"/"},
|
||||
base_nav_page,
|
||||
]
|
||||
|
||||
if not item_group_name:
|
||||
return base_parents
|
||||
|
||||
item_group = frappe.get_doc("Item Group", item_group_name)
|
||||
item_group = frappe.db.get_value("Item Group", item_group_name, ["lft", "rgt"], as_dict=1)
|
||||
parent_groups = frappe.db.sql("""select name, route from `tabItem Group`
|
||||
where lft <= %s and rgt >= %s
|
||||
and show_in_website=1
|
||||
|
||||
@@ -189,7 +189,7 @@ def add_non_standard_user_types():
|
||||
|
||||
user_type_limit = {}
|
||||
for user_type, data in user_types.items():
|
||||
user_type_limit.setdefault(frappe.scrub(user_type), 10)
|
||||
user_type_limit.setdefault(frappe.scrub(user_type), 20)
|
||||
|
||||
update_site_config('user_type_doctype_limit', user_type_limit)
|
||||
|
||||
@@ -204,15 +204,33 @@ def get_user_types_data():
|
||||
'apply_user_permission_on': 'Employee',
|
||||
'user_id_field': 'user_id',
|
||||
'doctypes': {
|
||||
'Salary Slip': ['read'],
|
||||
# masters
|
||||
'Holiday List': ['read'],
|
||||
'Employee': ['read', 'write'],
|
||||
# payroll
|
||||
'Salary Slip': ['read'],
|
||||
'Employee Benefit Application': ['read', 'write', 'create', 'delete'],
|
||||
# expenses
|
||||
'Expense Claim': ['read', 'write', 'create', 'delete'],
|
||||
'Employee Advance': ['read', 'write', 'create', 'delete'],
|
||||
# leave and attendance
|
||||
'Leave Application': ['read', 'write', 'create', 'delete'],
|
||||
'Attendance Request': ['read', 'write', 'create', 'delete'],
|
||||
'Compensatory Leave Request': ['read', 'write', 'create', 'delete'],
|
||||
# tax
|
||||
'Employee Tax Exemption Declaration': ['read', 'write', 'create', 'delete'],
|
||||
'Employee Tax Exemption Proof Submission': ['read', 'write', 'create', 'delete'],
|
||||
'Timesheet': ['read', 'write', 'create', 'delete', 'submit', 'cancel', 'amend']
|
||||
# projects
|
||||
'Timesheet': ['read', 'write', 'create', 'delete', 'submit', 'cancel', 'amend'],
|
||||
# trainings
|
||||
'Training Program': ['read'],
|
||||
'Training Feedback': ['read', 'write', 'create', 'delete', 'submit', 'cancel', 'amend'],
|
||||
# shifts
|
||||
'Shift Request': ['read', 'write', 'create', 'delete', 'submit', 'cancel', 'amend'],
|
||||
# misc
|
||||
'Employee Grievance': ['read', 'write', 'create', 'delete'],
|
||||
'Employee Referral': ['read', 'write', 'create', 'delete'],
|
||||
'Travel Request': ['read', 'write', 'create', 'delete']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"add_more_button": 0,
|
||||
"app": "ERPNext",
|
||||
"creation": "2019-12-04 19:21:39.995776",
|
||||
"docstatus": 0,
|
||||
"doctype": "Onboarding Slide",
|
||||
"domains": [],
|
||||
"help_links": [],
|
||||
"idx": 0,
|
||||
"image_src": "",
|
||||
"is_completed": 0,
|
||||
"max_count": 3,
|
||||
"modified": "2019-12-09 17:53:53.849953",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Welcome back to ERPNext!",
|
||||
"owner": "Administrator",
|
||||
"slide_desc": "<p>Let's continue where you left from!</p>",
|
||||
"slide_fields": [],
|
||||
"slide_module": "Setup",
|
||||
"slide_order": 0,
|
||||
"slide_title": "Welcome back to ERPNext!",
|
||||
"slide_type": "Continue"
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"add_more_button": 0,
|
||||
"app": "ERPNext",
|
||||
"creation": "2019-11-26 17:01:26.671859",
|
||||
"docstatus": 0,
|
||||
"doctype": "Onboarding Slide",
|
||||
"domains": [],
|
||||
"help_links": [],
|
||||
"idx": 0,
|
||||
"image_src": "",
|
||||
"is_completed": 0,
|
||||
"max_count": 0,
|
||||
"modified": "2019-12-22 21:26:28.414597",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Welcome to ERPNext!",
|
||||
"owner": "Administrator",
|
||||
"slide_desc": "<div class=\"text center\">Setting up an ERP can be overwhelming. But don't worry, we have got your back! This wizard will help you onboard to ERPNext in a short time!</div>",
|
||||
"slide_fields": [],
|
||||
"slide_module": "Setup",
|
||||
"slide_order": 1,
|
||||
"slide_title": "Welcome to ERPNext!",
|
||||
"slide_type": "Information"
|
||||
}
|
||||
@@ -29,10 +29,10 @@ def create_fiscal_year_and_company(args):
|
||||
'domain': args.get('domains')[0]
|
||||
}).insert()
|
||||
|
||||
def enable_shopping_cart(args):
|
||||
def enable_shopping_cart(args): # nosemgrep
|
||||
# Needs price_lists
|
||||
frappe.get_doc({
|
||||
"doctype": "Shopping Cart Settings",
|
||||
"doctype": "E Commerce Settings",
|
||||
"enabled": 1,
|
||||
'company': args.get('company_name') ,
|
||||
'price_list': frappe.db.get_value("Price List", {"selling": 1}),
|
||||
|
||||
@@ -533,8 +533,8 @@ def create_bank_account(args):
|
||||
# bank account same as a CoA entry
|
||||
pass
|
||||
|
||||
def update_shopping_cart_settings(args):
|
||||
shopping_cart = frappe.get_doc("Shopping Cart Settings")
|
||||
def update_shopping_cart_settings(args): # nosemgrep
|
||||
shopping_cart = frappe.get_doc("E Commerce Settings")
|
||||
shopping_cart.update({
|
||||
"enabled": 1,
|
||||
'company': args.company_name,
|
||||
|
||||
Reference in New Issue
Block a user