diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 2109792ef0..f9516335d4 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import frappe -__version__ = '7.2.1' +__version__ = '7.2.2' def get_default_company(user=None): '''Get default company for user''' diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 57e0faa8ed..6268fe3af3 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -270,6 +270,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }); } } + else this.frm.trigger("refresh") }, amount: function(){ diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 15cc8420fc..ef1e2c12a9 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -359,3 +359,4 @@ erpnext.patches.v7_1.set_currency_exchange_date erpnext.patches.v7_1.set_sales_person_status erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statment'}) +erpnext.patches.v7_2.update_website_for_variant diff --git a/erpnext/patches/v7_2/__init__.py b/erpnext/patches/v7_2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/v7_2/update_website_for_variant.py b/erpnext/patches/v7_2/update_website_for_variant.py new file mode 100644 index 0000000000..639569883e --- /dev/null +++ b/erpnext/patches/v7_2/update_website_for_variant.py @@ -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, "")!=""''') \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 5c62e34936..ee42ae59dd 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -2274,6 +2274,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "depends_on": "eval:!doc.variant_of", "fieldname": "show_in_website", "fieldtype": "Check", "hidden": 0, @@ -2296,6 +2297,35 @@ "set_only_once": 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, "bold": 0, @@ -2683,7 +2713,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2016-12-21 16:19:05.997203", + "modified": "2016-12-27 12:17:44.227302", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 98d0ebcfac..b721029629 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe import erpnext import json -import urllib import itertools from frappe import msgprint, _ from frappe.utils import cstr, flt, cint, getdate, now_datetime, formatdate, strip @@ -238,19 +237,12 @@ class Item(WebsiteGenerator): def get_context(self, context): context.show_search=True 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) + \ [{"name": self.name}] self.set_variant_context(context) - self.set_attribute_context(context) - self.set_disabled_attributes(context) context.parents = self.get_parents(context) @@ -264,7 +256,8 @@ class Item(WebsiteGenerator): # load variants # also used in set_attribute_context 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 if not variant and context.variants: @@ -565,12 +558,12 @@ class Item(WebsiteGenerator): existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock") frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1) - repost_stock_for_warehouses = frappe.db.sql_list("""select distinct warehouse + repost_stock_for_warehouses = frappe.db.sql_list("""select distinct warehouse from tabBin where item_code=%s""", new_name) - + # Delete all existing bins to avoid duplicate bins for the same item and warehouse frappe.db.sql("delete from `tabBin` where item_code=%s", new_name) - + for warehouse in repost_stock_for_warehouses: repost_stock(new_name, warehouse) @@ -597,6 +590,11 @@ class Item(WebsiteGenerator): def update_template_item(self): """Set Show in Website for Template Item if True for its Variant""" 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) if not template_item.show_in_website: