Duplicate dependencies when project is duplicated
- fix frappe/erpnext#8274
This commit is contained in:
parent
019501e4a0
commit
695327a513
@ -386,4 +386,5 @@ execute:frappe.delete_doc('DocType', 'Purchase Common')
|
||||
erpnext.patches.v8_0.update_stock_qty_value_in_purchase_invoice
|
||||
erpnext.patches.v8_0.update_supplier_address_in_stock_entry
|
||||
erpnext.patches.v8_0.rename_is_sample_item_to_allow_zero_valuation_rate
|
||||
erpnext.patches.v8_0.set_null_to_serial_nos_for_disabled_sales_invoices
|
||||
erpnext.patches.v8_0.set_null_to_serial_nos_for_disabled_sales_invoices
|
||||
erpnext.patches.v8_0.set_project_copied_from
|
9
erpnext/patches/v8_0/set_project_copied_from.py
Normal file
9
erpnext/patches/v8_0/set_project_copied_from.py
Normal file
@ -0,0 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.db.sql('''
|
||||
UPDATE `tabProject`
|
||||
SET copied_from=name
|
||||
WHERE copied_from is NULL
|
||||
''')
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:project_name",
|
||||
@ -553,6 +554,35 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "copied_from",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Copied From",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"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,
|
||||
@ -1052,7 +1082,7 @@
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -1174,19 +1204,19 @@
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"icon": "fa fa-puzzle-piece",
|
||||
"idx": 29,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 4,
|
||||
"modified": "2017-02-17 17:24:04.146872",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2017-04-19 13:16:32.462005",
|
||||
"modified_by": "faris@erpnext.com",
|
||||
"module": "Projects",
|
||||
"name": "Project",
|
||||
"owner": "Administrator",
|
||||
@ -1261,4 +1291,4 @@
|
||||
"timeline_field": "customer",
|
||||
"track_changes": 0,
|
||||
"track_seen": 1
|
||||
}
|
||||
}
|
@ -205,6 +205,32 @@ class Project(Document):
|
||||
def on_update(self):
|
||||
self.load_tasks()
|
||||
self.sync_tasks()
|
||||
self.update_dependencies_on_duplicated_project()
|
||||
|
||||
def update_dependencies_on_duplicated_project(self):
|
||||
if self.flags.dont_sync_tasks: return
|
||||
if not self.copied_from:
|
||||
self.copied_from = self.name
|
||||
|
||||
if self.name != self.copied_from and self.get('__unsaved'):
|
||||
# duplicated project
|
||||
dependency_map = {}
|
||||
for task in self.tasks:
|
||||
name, depends_on_tasks = frappe.db.get_value(
|
||||
'Task', { "subject": task.title, "project": self.copied_from }, ['name', 'depends_on_tasks']
|
||||
)
|
||||
depends_on_tasks = [x for x in depends_on_tasks.split(',') if x]
|
||||
dependency_map[task.title] = [ x['subject'] for x in frappe.get_list(
|
||||
'Task Depends On', {"parent": name}, ['subject'])]
|
||||
|
||||
for key, value in dependency_map.iteritems():
|
||||
task_name = frappe.db.get_value('Task', {"subject": key, "project": self.name })
|
||||
task_doc = frappe.get_doc('Task', task_name)
|
||||
|
||||
for dt in value:
|
||||
dt_name = frappe.db.get_value('Task', {"subject": dt, "project": self.name })
|
||||
task_doc.append('depends_on', {"task": dt_name})
|
||||
task_doc.save()
|
||||
|
||||
def get_timeline_data(doctype, name):
|
||||
'''Return timeline for attendance'''
|
||||
|
@ -53,9 +53,9 @@ class Task(Document):
|
||||
frappe.throw(_("Progress % for a task cannot be more than 100."))
|
||||
|
||||
def update_depends_on(self):
|
||||
depends_on_tasks = ""
|
||||
depends_on_tasks = self.depends_on_tasks or ""
|
||||
for d in self.depends_on:
|
||||
if d.task:
|
||||
if d.task and not d.task in depends_on_tasks:
|
||||
depends_on_tasks += d.task + ","
|
||||
self.depends_on_tasks = depends_on_tasks
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user