From 0cbb9b54fa1edb9809c43113caf680dfba88c8a2 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 <42651287+deepeshgarg007@users.noreply.github.com> Date: Tue, 16 Oct 2018 14:39:16 +0530 Subject: [PATCH] Deprecating subscriber doctype (#15695) * Depricating subscriber doctype * Removed naming series --- .../accounts/doctype/subscriber/__init__.py | 0 .../accounts/doctype/subscriber/subscriber.js | 2 - .../doctype/subscriber/subscriber.json | 129 ------------------ .../accounts/doctype/subscriber/subscriber.py | 9 -- .../subscriber/subscriber_dashboard.py | 14 -- .../doctype/subscriber/test_subscriber.js | 23 ---- .../doctype/subscriber/test_subscriber.py | 9 -- .../doctype/subscription/subscription.json | 11 +- .../doctype/subscription/subscription.py | 11 +- .../v11_0/remove_subscriber_doctype.py | 15 ++ .../doctype/customer/customer_dashboard.py | 4 + 11 files changed, 27 insertions(+), 200 deletions(-) delete mode 100644 erpnext/accounts/doctype/subscriber/__init__.py delete mode 100644 erpnext/accounts/doctype/subscriber/subscriber.js delete mode 100644 erpnext/accounts/doctype/subscriber/subscriber.json delete mode 100644 erpnext/accounts/doctype/subscriber/subscriber.py delete mode 100644 erpnext/accounts/doctype/subscriber/subscriber_dashboard.py delete mode 100644 erpnext/accounts/doctype/subscriber/test_subscriber.js delete mode 100644 erpnext/accounts/doctype/subscriber/test_subscriber.py create mode 100644 erpnext/patches/v11_0/remove_subscriber_doctype.py diff --git a/erpnext/accounts/doctype/subscriber/__init__.py b/erpnext/accounts/doctype/subscriber/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/accounts/doctype/subscriber/subscriber.js b/erpnext/accounts/doctype/subscriber/subscriber.js deleted file mode 100644 index f5ea8047c6..0000000000 --- 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 3fb7fdb087..0000000000 --- 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 03eb0f5ebb..0000000000 --- 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 3120384c6a..0000000000 --- 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 1fd4a1e011..0000000000 --- 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 3e2fc07c7b..0000000000 --- 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 aa29907d06..c9305164f0 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 7fb6b7a096..2bb2c004af 100644 --- a/erpnext/accounts/doctype/subscription/subscription.py +++ b/erpnext/accounts/doctype/subscription/subscription.py @@ -239,7 +239,7 @@ class Subscription(Document): 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 @@ class Subscription(Document): 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 @@ class Subscription(Document): 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 0000000000..4e50c35cd2 --- /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 9b905f8512..bf01363bd6 100644 --- a/erpnext/selling/doctype/customer/customer_dashboard.py +++ b/erpnext/selling/doctype/customer/customer_dashboard.py @@ -25,6 +25,10 @@ def get_data(): { 'label': _('Pricing'), 'items': ['Pricing Rule'] + }, + { + 'label': _('Subscriptions'), + 'items': ['Subscription'] } ] } \ No newline at end of file