From d0823adf42fc625dc12a2c550c41f442fa8e8fb7 Mon Sep 17 00:00:00 2001
From: Makarand Bauskar An error occured while creating recurring {{ type }} {{ name }} for {{ party }}. This could be because of some invalid Email Addresses in the {{ type }}. To stop sending repetitive error notifications from the system, we have unchecked
-"Convert into Recurring" field in the {{ type }} {{ name }}. Please correct the {{ type }} and make the {{ type }} recurring again. To stop sending repetitive error notifications from the system, we have checked "Disabled" field in the subscription {{ subscription}} for the {{ type }} {{ name }}. Please correct the {{ type }} and unchcked "Disabled" in the {{ subscription }} for making recurring again. It is necessary to take this action today itself for the above mentioned recurring {{ type }}
to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field
-of this {{ type }} for generating the recurring {{ type }}.
+
+#### Scenario
+
+Subscription for your hosted ERPNext account requires yearly renewal. We use Sales Invoice for generating proforma invoices. To automate proforma invoicing for renewal, we set original Sales Invoice on the subscription form. Recurring proforma invoice is created automatically just before customer's account is about to expire, and requires renewal. This recurring Proforma Invoice is also emailed automatically to the customer.
+
+To set the subscription for the sales invoice
+Goto Subscription > select base doctype "Sales Invoice" > select base docname "Invoice No" > Save
+
+
+
+**From Date and To Date**: This defines contract period with the customer.
+
+**Repeat on Day**: If frequency is set as Monthly, then it will be day of the month on which recurring invoice will be generated.
+
+**Notify By Email**: If you want to notify the user about auto recurring invoice.
+
+**Print Format**: Select a print format to define document view which should be emailed to customer.
+
+**Disabled**: It will stop to make auto recurring documents against the subscription
\ No newline at end of file
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 0e3aa79b36..6f95f7ef64 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -184,7 +184,7 @@ doc_events = {
scheduler_events = {
"hourly": [
- "erpnext.subscription.doctype.subscription.subscription.make_subscription_entry",
+ "erpnext.accounts.doctype.subscription.subscription.make_subscription_entry",
'erpnext.hr.doctype.daily_work_summary_settings.daily_work_summary_settings.trigger_emails'
],
"daily": [
diff --git a/erpnext/modules.txt b/erpnext/modules.txt
index 0579cc2119..1edff10ca5 100644
--- a/erpnext/modules.txt
+++ b/erpnext/modules.txt
@@ -14,5 +14,4 @@ Hub Node
Portal
Maintenance
Schools
-Regional
-Subscription
\ No newline at end of file
+Regional
\ No newline at end of file
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 92def8ded3..8b28a28c9b 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -439,6 +439,7 @@ erpnext.patches.v8_7.set_offline_in_pos_settings #11-09-17
erpnext.patches.v8_9.add_setup_progress_actions
erpnext.patches.v8_9.rename_company_sales_target_field
erpnext.patches.v8_8.set_bom_rate_as_per_uom
+erpnext.patches.v9_0.remove_subscription_module
erpnext.patches.v8_7.make_subscription_from_recurring_data
erpnext.patches.v8_9.set_print_zero_amount_taxes
erpnext.patches.v8_9.set_default_customer_group
diff --git a/erpnext/patches/v8_7/make_subscription_from_recurring_data.py b/erpnext/patches/v8_7/make_subscription_from_recurring_data.py
index 03d8eb4193..89eca1a0ec 100644
--- a/erpnext/patches/v8_7/make_subscription_from_recurring_data.py
+++ b/erpnext/patches/v8_7/make_subscription_from_recurring_data.py
@@ -6,7 +6,7 @@ import frappe
from frappe.utils import today
def execute():
- frappe.reload_doc('subscription', 'doctype', 'subscription')
+ frappe.reload_doc('accounts', 'doctype', 'subscription')
frappe.reload_doc('selling', 'doctype', 'sales_order')
frappe.reload_doc('buying', 'doctype', 'purchase_order')
frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
diff --git a/erpnext/patches/v9_0/__init__.py b/erpnext/patches/v9_0/__init__.py
new file mode 100644
index 0000000000..baffc48825
--- /dev/null
+++ b/erpnext/patches/v9_0/__init__.py
@@ -0,0 +1 @@
+from __future__ import unicode_literals
diff --git a/erpnext/patches/v9_0/remove_subscription_module.py b/erpnext/patches/v9_0/remove_subscription_module.py
new file mode 100644
index 0000000000..493873f3e8
--- /dev/null
+++ b/erpnext/patches/v9_0/remove_subscription_module.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ if frappe.db.exists('Module Def', 'Subscription'):
+ frappe.db.sql(""" delete from `tabModule Def` where name = 'Subscription'""")
\ No newline at end of file
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 8a47df6371..721f216888 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -129,7 +129,7 @@ $.extend(erpnext.utils, {
make_subscription: function(doctype, docname) {
frappe.call({
- method: "erpnext.subscription.doctype.subscription.subscription.make_subscription",
+ method: "erpnext.accounts.doctype.subscription.subscription.make_subscription",
args: {
doctype: doctype,
docname: docname
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 5f828900d5..8720482549 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -13,7 +13,7 @@ from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
from frappe.desk.notifications import clear_doctype_notifications
from frappe.contacts.doctype.address.address import get_company_address
from erpnext.controllers.selling_controller import SellingController
-from erpnext.subscription.doctype.subscription.subscription import month_map, get_next_date
+from erpnext.accounts.doctype.subscription.subscription import get_next_schedule_date
form_grid_templates = {
"items": "templates/form_grid/item_grid.html"
@@ -347,8 +347,7 @@ class SalesOrder(SellingController):
return items
def on_recurring(self, reference_doc, subscription_doc):
- mcount = month_map[subscription_doc.frequency]
- self.set("delivery_date", get_next_date(reference_doc.delivery_date, mcount,
+ self.set("delivery_date", get_next_schedule_date(reference_doc.delivery_date, subscription_doc.frequency,
cint(subscription_doc.repeat_on_day)))
for d in self.get("items"):
@@ -356,7 +355,7 @@ class SalesOrder(SellingController):
{"parent": reference_doc.name, "item_code": d.item_code, "idx": d.idx}, "delivery_date")
d.set("delivery_date",
- get_next_date(reference_delivery_date, mcount, cint(subscription_doc.repeat_on_day)))
+ get_next_schedule_date(reference_delivery_date, subscription_doc.frequency, cint(subscription_doc.repeat_on_day)))
def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context
diff --git a/erpnext/subscription/__init__.py b/erpnext/subscription/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/subscription/doctype/__init__.py b/erpnext/subscription/doctype/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/subscription/doctype/subscription/__init__.py b/erpnext/subscription/doctype/subscription/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/templates/emails/recurring_document_failed.html b/erpnext/templates/emails/recurring_document_failed.html
index 9b88731178..ea48034f41 100644
--- a/erpnext/templates/emails/recurring_document_failed.html
+++ b/erpnext/templates/emails/recurring_document_failed.html
@@ -1,12 +1,11 @@
-
Recurring {{ type }} Failed
+{{_("Recurring")}} {{ type }} {{ _("Failed")}}
[This email is autogenerated]
From 6cea73b8344777502b6a7d50855c6b4e27557040 Mon Sep 17 00:00:00 2001 From: rohitwaghchaureNDr8Oo@uG;rHNVX%jjW;HODIip(j?h1D*DBL9z^(kk
zjSCqY35ugV>{6PcqnQTEVqE8Y9x0N0he8HqCwd43(+
WR-o
zyJ@Q)6o+NK*klo=%O9TKox+vVN@rgvp5MxwwKEm^KY+^+4ItCM{9iv|+_?k(0k%Lc
zE0Fm$B#^OZ6ZASkAoJ^0${E|;Fz)YXnJxf$n0Bf8m+pFhBVyG*x0Bqmvfr8SK+yjJ
zaXLL9@2OV#yyEV3yuZiHejR|P_r@USxpttCpT7bN-A;1zeD;J@j;5oShKA>x)|Ja9
zJA8?M0r~$pZN2c8R;9f4`Vu~uYTSBd$@E9jUF-exJ+a(O$iNSZR_8r{e4^O&bu|9l
zhv$6Hp5JKeO-BmH_HA*oj1ddUh*73n@7GbRM^oh^BD$J6
P!{9VZWYZ05l|5MddCo5!xG8(_4uM5M=%sn_S
ARA(`C+g1@v$V6qAgmG&YWASeufxrUKqm!ZY0+aT|R
zc}=3m(#F3WTv%}w8JI_LQv1F;aB^v{5Kz)a@8+%}(I1nd
`zcgi$gkL&p$g?Z79`~s2ETWZwkKCXYaVBmq`hPa7&
zzPV2gzF6(xGirY6$z
+4U0I1gvyLOoC56-R({?3RecZU~?SR
z6N1rosTs(Xm|B}WO}x}Xcgy{t;as!lRXG<|72TsJz>90-bshcW1fOhUTc1a08tbXc
z$o^NhtroWP$&%QqwZxN1Enl*1uX*yVAlmA#rKIuZj77ro=UWq(tcf9#BD25SFc@Bt
zT~PX)p7U4$bBxuo{9=LqIjINuR-B6+kS!m2z?wtQx8c~y%uiPnuOtmrn@EK?OuKot
zAcsc@H;lJS4{nqm2;)To(V;T5IVR0*{m%j1O8pC69ocak3vKetjQpg^q8s?79$I(h
zhMGz)S1+S$M~1UE2!uPMZ^F+?F1FEF57{FTPmd40gm}F4qKlLZD=a^c5h7Wi?frbd
z!Q$lmgkrPXcUJqg)%UY{(mx@b?}MOwOao5{{XQ8WkPGI&2K0sI96WvH-Pmz|#|A}k
zh`sb=^UP$%K!KmF&GY=XFW;|!&UF>W^dwaE{Nv0|-cD+;g_Ci-g
zOq+xu$HTqOXP@ivI$RvpJXJDJDZ5fLmU7*k*&|E(mN~bnn7jb{g>7Q4TO!T&qxY+n
zUwlQP4sCT!O7O&G=`eyyrh&e+tW@#-`@8dz|KThEqJ(%A2JdgcNPg}V-gP$qG&!O`
zRKn~9`|jxVPlClH0{{`uZxPP_|LFfBCMIN#D*q^7n?hbrT>DU=BX6_FDYfhQaTFi7
zUb1V$6^x01zWHt5J#8hwK`h
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 7837f8c73e..03b93c0cb2 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -97,6 +97,12 @@ frappe.ui.form.on("Item", {
}
frappe.set_route('Form', 'Item', new_item.name);
});
+
+ if(frm.doc.has_variants) {
+ frm.add_custom_button(__("Item Variant Settings"), function() {
+ frappe.set_route("Form", "Item Variant Settings");
+ }, __("View"));
+ }
},
validate: function(frm){
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index f2ea1d88bc..a810665997 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -100,6 +100,7 @@ class Item(WebsiteGenerator):
def on_update(self):
invalidate_cache_for_item(self)
self.validate_name_with_item_group()
+ self.update_variants()
self.update_item_price()
self.update_template_item()
@@ -607,9 +608,24 @@ class Item(WebsiteGenerator):
if not template_item.show_in_website:
template_item.show_in_website = 1
+ template_item.flags.dont_update_variants = True
template_item.flags.ignore_permissions = True
template_item.save()
+ def update_variants(self):
+ if self.flags.dont_update_variants:
+ return
+ if self.has_variants:
+ updated = []
+ variants = frappe.db.get_all("Item", fields=["item_code"], filters={"variant_of": self.name })
+ for d in variants:
+ variant = frappe.get_doc("Item", d)
+ copy_attributes_to_variant(self, variant)
+ variant.save()
+ updated.append(d.item_code)
+ if updated:
+ frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
+
def validate_has_variants(self):
if not self.has_variants and frappe.db.get_value("Item", self.name, "has_variants"):
if frappe.db.exists("Item", {"variant_of": self.name}):
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index 2a8e4344af..34e3af6102 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -119,6 +119,37 @@ class TestItem(unittest.TestCase):
variant.item_code = "_Test Variant Item-L-duplicate"
self.assertRaises(ItemVariantExistsError, variant.save)
+ def test_copy_fields_from_template_to_variants(self):
+ fields = [{'field_name': 'item_group'}, {'field_name': 'is_stock_item'}]
+ allow_fields = [d.get('field_name') for d in fields]
+ set_item_variant_settings(fields)
+
+ if not frappe.db.get_value('Item Attribute Value',
+ {'parent': 'Test Size', 'attribute_value': 'Extra Large'}, 'name'):
+ item_attribute = frappe.get_doc('Item Attribute', 'Test Size')
+ item_attribute.append('item_attribute_values', {
+ 'attribute_value' : 'Extra Large',
+ 'abbr': 'XL'
+ })
+ item_attribute.save()
+
+ variant = create_variant("_Test Variant Item", {"Test Size": "Extra Large"})
+ variant.item_code = "_Test Variant Item-XL"
+ variant.item_name = "_Test Variant Item-XL"
+ variant.save()
+
+ template = frappe.get_doc('Item', '_Test Variant Item')
+ template.item_group = "_Test Item Group D"
+ template.save()
+
+ variant = frappe.get_doc('Item', '_Test Variant Item-XL')
+ for fieldname in allow_fields:
+ self.assertEquals(template.get(fieldname), variant.get(fieldname))
+
+ template = frappe.get_doc('Item', '_Test Variant Item')
+ template.item_group = "_Test Item Group Desktops"
+ template.save()
+
def test_make_item_variant_with_numeric_values(self):
# cleanup
for d in frappe.db.get_all('Item', filters={'variant_of':
@@ -194,6 +225,9 @@ class TestItem(unittest.TestCase):
{"item_code": "Test Item for Merging 2", "warehouse": "_Test Warehouse 1 - _TC"}))
def test_item_variant_by_manufacturer(self):
+ fields = [{'field_name': 'description'}, {'field_name': 'variant_based_on'}]
+ set_item_variant_settings(fields)
+
if frappe.db.exists('Item', '_Test Variant Mfg'):
frappe.delete_doc('Item', '_Test Variant Mfg')
if frappe.db.exists('Item', '_Test Variant Mfg-1'):
@@ -227,6 +261,10 @@ class TestItem(unittest.TestCase):
self.assertEquals(variant.manufacturer, 'MSG1')
self.assertEquals(variant.manufacturer_part_no, '007')
+def set_item_variant_settings(fields):
+ doc = frappe.get_doc('Item Variant Settings')
+ doc.set('fields', fields)
+ doc.save()
def make_item_variant():
if not frappe.db.exists("Item", "_Test Variant Item-S"):
diff --git a/erpnext/stock/doctype/item_variant_settings/__init__.py b/erpnext/stock/doctype/item_variant_settings/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js
new file mode 100644
index 0000000000..cd7d8a4085
--- /dev/null
+++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js
@@ -0,0 +1,18 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Item Variant Settings', {
+ setup: function(frm) {
+ const allow_fields = [];
+ frappe.model.with_doctype('Item', () => {
+ frappe.get_meta('Item').fields.forEach(d => {
+ if(!in_list(['HTML', 'Section Break', 'Column Break', 'Button'], d.fieldtype) && !d.no_copy) {
+ allow_fields.push(d.fieldname);
+ }
+ });
+
+ const child = frappe.meta.get_docfield("Variant Field", "field_name", frm.doc.name);
+ child.options = allow_fields;
+ });
+ }
+});
diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json
new file mode 100644
index 0000000000..226a07ca6f
--- /dev/null
+++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json
@@ -0,0 +1,143 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2017-08-29 16:38:31.173830",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "variant_fields",
+ "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": "Variant Fields",
+ "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_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "fields",
+ "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": "Fields",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Variant Field",
+ "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
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 1,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2017-08-29 16:38:49.467749",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Item Variant Settings",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "apply_user_permissions": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 0,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 0,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "apply_user_permissions": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 0,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 0,
+ "role": "Item Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
new file mode 100644
index 0000000000..26e08d119d
--- /dev/null
+++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+
+class ItemVariantSettings(Document):
+ pass
diff --git a/erpnext/stock/doctype/item_variant_settings/test_item_variant_settings.js b/erpnext/stock/doctype/item_variant_settings/test_item_variant_settings.js
new file mode 100644
index 0000000000..3b3bf94f37
--- /dev/null
+++ b/erpnext/stock/doctype/item_variant_settings/test_item_variant_settings.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Item Variant Settings", function (assert) {
+ let done = assert.async();
+
+ // number of asserts
+ assert.expect(1);
+
+ frappe.run_serially([
+ // insert a new Item Variant Settings
+ () => frappe.tests.make('Item Variant Settings', [
+ // values to be set
+ {key: 'value'}
+ ]),
+ () => {
+ assert.equal(cur_frm.doc.key, 'value');
+ },
+ () => done()
+ ]);
+
+});
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index 7fa232e6f7..4bcbcc4b6f 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -11,6 +11,7 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
from erpnext.stock.doctype.stock_ledger_entry.stock_ledger_entry import StockFreezeError
from erpnext.stock.stock_ledger import get_previous_sle
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import create_stock_reconciliation
+from erpnext.stock.doctype.item.test_item import set_item_variant_settings
from frappe.tests.test_permissions import set_user_permission_doctypes
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.accounts.doctype.account.test_account import get_inventory_account
@@ -79,6 +80,19 @@ class TestStockEntry(unittest.TestCase):
self._test_auto_material_request("_Test Item", material_request_type="Transfer")
def test_auto_material_request_for_variant(self):
+ fields = [{'field_name': 'reorder_levels'}]
+ set_item_variant_settings(fields)
+ template = frappe.get_doc("Item", "_Test Variant Item")
+
+ if not template.reorder_levels:
+ template.append('reorder_levels', {
+ "material_request_type": "Purchase",
+ "warehouse": "_Test Warehouse - _TC",
+ "warehouse_reorder_level": 20,
+ "warehouse_reorder_qty": 20
+ })
+
+ template.save()
self._test_auto_material_request("_Test Variant Item-S")
def test_auto_material_request_for_warehouse_group(self):
diff --git a/erpnext/stock/doctype/variant_field/__init__.py b/erpnext/stock/doctype/variant_field/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/erpnext/stock/doctype/variant_field/test_variant_field.js b/erpnext/stock/doctype/variant_field/test_variant_field.js
new file mode 100644
index 0000000000..2600a10fe0
--- /dev/null
+++ b/erpnext/stock/doctype/variant_field/test_variant_field.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Variant Field", function (assert) {
+ let done = assert.async();
+
+ // number of asserts
+ assert.expect(1);
+
+ frappe.run_serially([
+ // insert a new Variant Field
+ () => frappe.tests.make('Variant Field', [
+ // values to be set
+ {key: 'value'}
+ ]),
+ () => {
+ assert.equal(cur_frm.doc.key, 'value');
+ },
+ () => done()
+ ]);
+
+});
diff --git a/erpnext/stock/doctype/variant_field/test_variant_field.py b/erpnext/stock/doctype/variant_field/test_variant_field.py
new file mode 100644
index 0000000000..53024bdac1
--- /dev/null
+++ b/erpnext/stock/doctype/variant_field/test_variant_field.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import unittest
+
+class TestVariantField(unittest.TestCase):
+ pass
diff --git a/erpnext/stock/doctype/variant_field/variant_field.js b/erpnext/stock/doctype/variant_field/variant_field.js
new file mode 100644
index 0000000000..13db3f9272
--- /dev/null
+++ b/erpnext/stock/doctype/variant_field/variant_field.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Variant Field', {
+ refresh: function() {
+
+ }
+});
diff --git a/erpnext/stock/doctype/variant_field/variant_field.json b/erpnext/stock/doctype/variant_field/variant_field.json
new file mode 100644
index 0000000000..ae9088486f
--- /dev/null
+++ b/erpnext/stock/doctype/variant_field/variant_field.json
@@ -0,0 +1,72 @@
+{
+ "allow_copy": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2017-08-29 16:33:33.978574",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "field_name",
+ "fieldtype": "Select",
+ "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": "Field Name",
+ "length": 0,
+ "no_copy": 0,
+ "options": "",
+ "permlevel": 0,
+ "precision": "",
+ "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,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2017-08-29 17:19:20.353197",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Variant Field",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/variant_field/variant_field.py b/erpnext/stock/doctype/variant_field/variant_field.py
new file mode 100644
index 0000000000..a77301e0e5
--- /dev/null
+++ b/erpnext/stock/doctype/variant_field/variant_field.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from frappe.model.document import Document
+
+class VariantField(Document):
+ pass
From 5b05335e89a581ddb74176effd956ba9084fef7c Mon Sep 17 00:00:00 2001
From: Rohit Waghchaure
" % fileurl)
+def set_no_copy_fields_in_variant_settings():
+ # set no copy fields of an item doctype to item variant settings
+ doc = frappe.get_doc('Item Variant Settings')
+ doc.set_default_fields()
+ doc.save()
+
def create_logo(args):
if args.get("attach_logo"):
attach_logo = args.get("attach_logo").split(",")
diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js
index cd7d8a4085..77ccfd0cc0 100644
--- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js
+++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js
@@ -4,9 +4,12 @@
frappe.ui.form.on('Item Variant Settings', {
setup: function(frm) {
const allow_fields = [];
+ const exclude_fields = ["item_code", "item_name", "show_in_website", "show_variant_in_website", "standard_rate"];
+
frappe.model.with_doctype('Item', () => {
frappe.get_meta('Item').fields.forEach(d => {
- if(!in_list(['HTML', 'Section Break', 'Column Break', 'Button'], d.fieldtype) && !d.no_copy) {
+ if(!in_list(['HTML', 'Section Break', 'Column Break', 'Button'], d.fieldtype)
+ && !d.no_copy && !in_list(exclude_fields, d.fieldname)) {
allow_fields.push(d.fieldname);
}
});
diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json
index 226a07ca6f..a29137c762 100644
--- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json
+++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.json
@@ -18,7 +18,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "variant_fields",
+ "fieldname": "copy_fields_to_variant",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -27,7 +27,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Variant Fields",
+ "label": "Copy Fields to Variant",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -84,8 +84,8 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
- "modified": "2017-08-29 16:38:49.467749",
- "modified_by": "Administrator",
+ "modified": "2017-09-11 12:05:16.288601",
+ "modified_by": "rohit@erpnext.com",
"module": "Stock",
"name": "Item Variant Settings",
"name_case": "",
diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
index 26e08d119d..1cc7c21520 100644
--- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
+++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
@@ -3,7 +3,18 @@
# For license information, please see license.txt
from __future__ import unicode_literals
+import frappe
from frappe.model.document import Document
class ItemVariantSettings(Document):
- pass
+ def set_default_fields(self):
+ self.fields = []
+ fields = frappe.get_meta('Item').fields
+ exclude_fields = ["item_code", "item_name", "show_in_website", "show_variant_in_website", "standard_rate"]
+
+ for d in fields:
+ if not d.no_copy and d.fieldname not in exclude_fields and \
+ d.fieldtype not in ['HTML', 'Section Break', 'Column Break', 'Button']:
+ self.append('fields', {
+ 'field_name': d.fieldname
+ })
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_variant_settings/test_item_variant_settings.py b/erpnext/stock/doctype/item_variant_settings/test_item_variant_settings.py
new file mode 100644
index 0000000000..9a800c07fc
--- /dev/null
+++ b/erpnext/stock/doctype/item_variant_settings/test_item_variant_settings.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import unittest
+
+class TestItemVariantSettings(unittest.TestCase):
+ pass
From 2851dfad9974c9a49feee8f05a4adb6971c5cceb Mon Sep 17 00:00:00 2001
From: Nabin Hait