[fix] item variants not directly shown in website due to route clash
This commit is contained in:
parent
c2690425e3
commit
174c3478a1
@ -359,3 +359,4 @@ erpnext.patches.v7_1.set_currency_exchange_date
|
|||||||
erpnext.patches.v7_1.set_sales_person_status
|
erpnext.patches.v7_1.set_sales_person_status
|
||||||
erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items
|
erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items
|
||||||
execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statment'})
|
execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statment'})
|
||||||
|
erpnext.patches.v7_2.update_website_for_variant
|
||||||
|
0
erpnext/patches/v7_2/__init__.py
Normal file
0
erpnext/patches/v7_2/__init__.py
Normal file
12
erpnext/patches/v7_2/update_website_for_variant.py
Normal file
12
erpnext/patches/v7_2/update_website_for_variant.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
# variant must have show_in_website = 0
|
||||||
|
frappe.reload_doctype('Item')
|
||||||
|
frappe.db.sql('''
|
||||||
|
update tabItem set
|
||||||
|
show_variant_in_website = 1,
|
||||||
|
show_in_website = 0
|
||||||
|
where
|
||||||
|
show_in_website=1
|
||||||
|
and ifnull(variant_of, "")!=""''')
|
@ -2274,6 +2274,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"depends_on": "eval:!doc.variant_of",
|
||||||
"fieldname": "show_in_website",
|
"fieldname": "show_in_website",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -2296,6 +2297,35 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"depends_on": "variant_of",
|
||||||
|
"fieldname": "show_variant_in_website",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Show in Website (Variant)",
|
||||||
|
"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,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -2683,7 +2713,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 1,
|
"max_attachments": 1,
|
||||||
"modified": "2016-12-13 02:19:54.507883",
|
"modified": "2016-12-27 12:17:44.227302",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Item",
|
"name": "Item",
|
||||||
|
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import erpnext
|
import erpnext
|
||||||
import json
|
import json
|
||||||
import urllib
|
|
||||||
import itertools
|
import itertools
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from frappe.utils import cstr, flt, cint, getdate, now_datetime, formatdate, strip
|
from frappe.utils import cstr, flt, cint, getdate, now_datetime, formatdate, strip
|
||||||
@ -238,19 +237,12 @@ class Item(WebsiteGenerator):
|
|||||||
def get_context(self, context):
|
def get_context(self, context):
|
||||||
context.show_search=True
|
context.show_search=True
|
||||||
context.search_link = '/product_search'
|
context.search_link = '/product_search'
|
||||||
if self.variant_of:
|
|
||||||
# redirect to template page!
|
|
||||||
template_item = frappe.get_doc("Item", self.variant_of)
|
|
||||||
frappe.flags.redirect_location = template_item.route + "?variant=" + urllib.quote(self.name)
|
|
||||||
raise frappe.Redirect
|
|
||||||
|
|
||||||
context.parent_groups = get_parent_item_groups(self.item_group) + \
|
context.parent_groups = get_parent_item_groups(self.item_group) + \
|
||||||
[{"name": self.name}]
|
[{"name": self.name}]
|
||||||
|
|
||||||
self.set_variant_context(context)
|
self.set_variant_context(context)
|
||||||
|
|
||||||
self.set_attribute_context(context)
|
self.set_attribute_context(context)
|
||||||
|
|
||||||
self.set_disabled_attributes(context)
|
self.set_disabled_attributes(context)
|
||||||
|
|
||||||
context.parents = self.get_parents(context)
|
context.parents = self.get_parents(context)
|
||||||
@ -264,7 +256,8 @@ class Item(WebsiteGenerator):
|
|||||||
# load variants
|
# load variants
|
||||||
# also used in set_attribute_context
|
# also used in set_attribute_context
|
||||||
context.variants = frappe.get_all("Item",
|
context.variants = frappe.get_all("Item",
|
||||||
filters={"variant_of": self.name, "show_in_website": 1}, order_by="name asc")
|
filters={"variant_of": self.name, "show_variant_in_website": 1},
|
||||||
|
order_by="name asc")
|
||||||
|
|
||||||
variant = frappe.form_dict.variant
|
variant = frappe.form_dict.variant
|
||||||
if not variant and context.variants:
|
if not variant and context.variants:
|
||||||
@ -597,6 +590,11 @@ class Item(WebsiteGenerator):
|
|||||||
def update_template_item(self):
|
def update_template_item(self):
|
||||||
"""Set Show in Website for Template Item if True for its Variant"""
|
"""Set Show in Website for Template Item if True for its Variant"""
|
||||||
if self.variant_of and self.show_in_website:
|
if self.variant_of and self.show_in_website:
|
||||||
|
self.show_variant_in_website = 1
|
||||||
|
self.show_in_website = 0
|
||||||
|
|
||||||
|
if self.show_variant_in_website:
|
||||||
|
# show template
|
||||||
template_item = frappe.get_doc("Item", self.variant_of)
|
template_item = frappe.get_doc("Item", self.variant_of)
|
||||||
|
|
||||||
if not template_item.show_in_website:
|
if not template_item.show_in_website:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user