Deprecating subscriber doctype (#15695)
* Depricating subscriber doctype
* Removed naming series
diff --git a/erpnext/accounts/doctype/subscriber/__init__.py b/erpnext/accounts/doctype/subscriber/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/accounts/doctype/subscriber/__init__.py
+++ /dev/null
diff --git a/erpnext/accounts/doctype/subscriber/subscriber.js b/erpnext/accounts/doctype/subscriber/subscriber.js
deleted file mode 100644
index f5ea804..0000000
--- a/erpnext/accounts/doctype/subscriber/subscriber.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
-// For license information, please see license.txt
diff --git a/erpnext/accounts/doctype/subscriber/subscriber.json b/erpnext/accounts/doctype/subscriber/subscriber.json
deleted file mode 100644
index 3fb7fdb..0000000
--- a/erpnext/accounts/doctype/subscriber/subscriber.json
+++ /dev/null
@@ -1,129 +0,0 @@
-{
- "allow_copy": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "field:subscriber_name",
- "beta": 0,
- "creation": "2018-02-24 11:17:46.809140",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
- "engine": "InnoDB",
- "fields": [
- {
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "customer",
- "fieldtype": "Link",
- "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": "Customer",
- "length": 0,
- "no_copy": 0,
- "options": "Customer",
- "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,
- "translatable": 0,
- "unique": 0
- },
- {
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "customer.customer_name",
- "fieldname": "subscriber_name",
- "fieldtype": "Data",
- "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": "Subscriber 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,
- "translatable": 0,
- "unique": 1
- }
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-07-11 15:13:30.056470",
- "modified_by": "Administrator",
- "module": "Accounts",
- "name": "Subscriber",
- "name_case": "",
- "owner": "Administrator",
- "permissions": [
- {
- "amend": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "System 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/accounts/doctype/subscriber/subscriber.py b/erpnext/accounts/doctype/subscriber/subscriber.py
deleted file mode 100644
index 03eb0f5..0000000
--- a/erpnext/accounts/doctype/subscriber/subscriber.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2018, 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 Subscriber(Document):
- pass
diff --git a/erpnext/accounts/doctype/subscriber/subscriber_dashboard.py b/erpnext/accounts/doctype/subscriber/subscriber_dashboard.py
deleted file mode 100644
index 3120384..0000000
--- a/erpnext/accounts/doctype/subscriber/subscriber_dashboard.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from frappe import _
-
-def get_data():
- return {
- 'heatmap': True,
- 'heatmap_message': _('This is based on transactions against this Subscriber. See timeline below for details'),
- 'fieldname': 'subscriber',
- 'transactions': [
- {
- 'label': _('Subscriptions'),
- 'items': ['Subscription']
- }
- ]
- }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/subscriber/test_subscriber.js b/erpnext/accounts/doctype/subscriber/test_subscriber.js
deleted file mode 100644
index 1fd4a1e..0000000
--- a/erpnext/accounts/doctype/subscriber/test_subscriber.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/* eslint-disable */
-// rename this file from _test_[name] to test_[name] to activate
-// and remove above this line
-
-QUnit.test("test: Subscriber", function (assert) {
- let done = assert.async();
-
- // number of asserts
- assert.expect(1);
-
- frappe.run_serially([
- // insert a new Subscriber
- () => frappe.tests.make('Subscriber', [
- // values to be set
- {key: 'value'}
- ]),
- () => {
- assert.equal(cur_frm.doc.key, 'value');
- },
- () => done()
- ]);
-
-});
diff --git a/erpnext/accounts/doctype/subscriber/test_subscriber.py b/erpnext/accounts/doctype/subscriber/test_subscriber.py
deleted file mode 100644
index 3e2fc07..0000000
--- a/erpnext/accounts/doctype/subscriber/test_subscriber.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
-# See license.txt
-from __future__ import unicode_literals
-
-import unittest
-
-class TestSubscriber(unittest.TestCase):
- pass
diff --git a/erpnext/accounts/doctype/subscription/subscription.json b/erpnext/accounts/doctype/subscription/subscription.json
index aa29907..c930516 100644
--- a/erpnext/accounts/doctype/subscription/subscription.json
+++ b/erpnext/accounts/doctype/subscription/subscription.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -20,7 +21,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "subscriber",
+ "fieldname": "customer",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -29,10 +30,10 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
- "label": "Subscriber",
+ "label": "Customer",
"length": 0,
"no_copy": 0,
- "options": "Subscriber",
+ "options": "Customer",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -846,7 +847,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-10-04 10:29:03.338893",
+ "modified": "2018-10-14 10:38:55.545540",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Subscription",
@@ -922,4 +923,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py
index 7fb6b7a..2bb2c00 100644
--- a/erpnext/accounts/doctype/subscription/subscription.py
+++ b/erpnext/accounts/doctype/subscription/subscription.py
@@ -239,7 +239,7 @@
invoice = frappe.new_doc('Sales Invoice')
invoice.set_posting_time = 1
invoice.posting_date = self.current_invoice_start
- invoice.customer = self.get_customer(self.subscriber)
+ invoice.customer = self.customer
# Subscription is better suited for service items. I won't update `update_stock`
# for that reason
@@ -282,13 +282,6 @@
return invoice
- @staticmethod
- def get_customer(subscriber_name):
- """
- Returns the `Customer` linked to the `Subscriber`
- """
- return frappe.db.get_value('Subscriber', subscriber_name, 'customer')
-
def get_items_from_plans(self, plans, prorate=0):
"""
Returns the `Item`s linked to `Subscription Plan`
@@ -297,7 +290,7 @@
prorate_factor = get_prorata_factor(self.current_invoice_end, self.current_invoice_start)
items = []
- customer = self.get_customer(self.subscriber)
+ customer = self.customer
for plan in plans:
item_code = frappe.db.get_value("Subscription Plan", plan.plan, "item")
if not prorate:
diff --git a/erpnext/patches/v11_0/remove_subscriber_doctype.py b/erpnext/patches/v11_0/remove_subscriber_doctype.py
new file mode 100644
index 0000000..4e50c35
--- /dev/null
+++ b/erpnext/patches/v11_0/remove_subscriber_doctype.py
@@ -0,0 +1,15 @@
+import frappe
+from frappe.model.utils.rename_field import rename_field
+
+def execute():
+ """ copy subscribe field to customer """
+ frappe.reload_doc("accounts","doctype","subscription")
+
+ if frappe.db.exists("DocType", "Subscriber"):
+ if frappe.db.has_column('Subscription','subscriber'):
+ frappe.db.sql("""
+ update `tabSubscription` s1
+ set customer=(select customer from tabSubscriber where name=s1.subscriber)
+ """)
+
+ frappe.delete_doc("DocType", "Subscriber")
\ No newline at end of file
diff --git a/erpnext/selling/doctype/customer/customer_dashboard.py b/erpnext/selling/doctype/customer/customer_dashboard.py
index 9b905f8..bf01363 100644
--- a/erpnext/selling/doctype/customer/customer_dashboard.py
+++ b/erpnext/selling/doctype/customer/customer_dashboard.py
@@ -25,6 +25,10 @@
{
'label': _('Pricing'),
'items': ['Pricing Rule']
+ },
+ {
+ 'label': _('Subscriptions'),
+ 'items': ['Subscription']
}
]
}
\ No newline at end of file