fixed conflict
This commit is contained in:
commit
7b596d8d88
@ -109,7 +109,7 @@ class DocType:
|
|||||||
msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
|
msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
|
||||||
Only Accounts Manager can do transaction against this account"), raise_exception=1)
|
Only Accounts Manager can do transaction against this account"), raise_exception=1)
|
||||||
|
|
||||||
if ret and ret[0]["company"] != self.doc.company:
|
if self.doc.is_cancelled in ("No", None) and ret and ret[0]["company"] != self.doc.company:
|
||||||
msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
|
msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
|
||||||
+ ": " + self.doc.company, raise_exception=1)
|
+ ": " + self.doc.company, raise_exception=1)
|
||||||
|
|
||||||
@ -124,9 +124,10 @@ class DocType:
|
|||||||
|
|
||||||
return self.cost_center_company[self.doc.cost_center]
|
return self.cost_center_company[self.doc.cost_center]
|
||||||
|
|
||||||
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
|
if self.doc.is_cancelled in ("No", None) and \
|
||||||
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
|
self.doc.cost_center and _get_cost_center_company() != self.doc.company:
|
||||||
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
|
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
|
||||||
|
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
|
||||||
|
|
||||||
def check_freezing_date(self, adv_adj):
|
def check_freezing_date(self, adv_adj):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -5,29 +5,37 @@ def execute():
|
|||||||
webnotes.reload_doc("core", "doctype", "file_data")
|
webnotes.reload_doc("core", "doctype", "file_data")
|
||||||
webnotes.reset_perms("File Data")
|
webnotes.reset_perms("File Data")
|
||||||
|
|
||||||
singles = webnotes.conn.sql_list("""select name from tabDocType
|
singles = get_single_doctypes()
|
||||||
where ifnull(issingle,0)=1""")
|
|
||||||
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
|
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
|
||||||
fieldname='file_list' and fieldtype='Text'"""):
|
fieldname='file_list' and fieldtype='Text'"""):
|
||||||
if doctype in singles:
|
update_file_list(doctype, singles)
|
||||||
doc = webnotes.doc(doctype, doctype)
|
|
||||||
if doc.file_list:
|
|
||||||
update_for_doc(doctype, doc)
|
|
||||||
webnotes.conn.set_value(doctype, None, "file_list", None)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
for doc in webnotes.conn.sql("""select name, file_list from `tab%s` where
|
|
||||||
ifnull(file_list, '')!=''""" % doctype, as_dict=True):
|
|
||||||
update_for_doc(doctype, doc)
|
|
||||||
webnotes.conn.commit()
|
|
||||||
webnotes.conn.sql("""alter table `tab%s` drop column file_list""" % doctype)
|
|
||||||
except Exception, e:
|
|
||||||
if e.args[0]!=1054: raise e
|
|
||||||
|
|
||||||
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
|
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
|
||||||
and parent=%s""", doctype)
|
and parent=%s""", doctype)
|
||||||
|
|
||||||
# export_to_files([["DocType", doctype]])
|
# export_to_files([["DocType", doctype]])
|
||||||
|
|
||||||
|
def get_single_doctypes():
|
||||||
|
return webnotes.conn.sql_list("""select name from tabDocType
|
||||||
|
where ifnull(issingle,0)=1""")
|
||||||
|
|
||||||
|
def update_file_list(doctype, singles):
|
||||||
|
if doctype in singles:
|
||||||
|
doc = webnotes.doc(doctype, doctype)
|
||||||
|
if doc.file_list:
|
||||||
|
update_for_doc(doctype, doc)
|
||||||
|
webnotes.conn.set_value(doctype, None, "file_list", None)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
for doc in webnotes.conn.sql("""select name, file_list from `tab%s` where
|
||||||
|
ifnull(file_list, '')!=''""" % doctype, as_dict=True):
|
||||||
|
update_for_doc(doctype, doc)
|
||||||
|
webnotes.conn.commit()
|
||||||
|
webnotes.conn.sql("""alter table `tab%s` drop column file_list""" % doctype)
|
||||||
|
except Exception, e:
|
||||||
|
if e.args[0]!=1054: raise e
|
||||||
|
|
||||||
def update_for_doc(doctype, doc):
|
def update_for_doc(doctype, doc):
|
||||||
for filedata in doc.file_list.split("\n"):
|
for filedata in doc.file_list.split("\n"):
|
||||||
if not filedata:
|
if not filedata:
|
||||||
@ -45,10 +53,17 @@ def update_for_doc(doctype, doc):
|
|||||||
exists = False
|
exists = False
|
||||||
|
|
||||||
if exists:
|
if exists:
|
||||||
webnotes.conn.sql("""update `tabFile Data`
|
if webnotes.conn.exists("File Data", fileid):
|
||||||
set attached_to_doctype=%s, attached_to_name=%s
|
fd = webnotes.bean("File Data", fileid)
|
||||||
where name=%s""", (doctype, doc.name, fileid))
|
if not (fd.doc.attached_to_doctype and fd.doc.attached_to_name):
|
||||||
|
fd.doc.attached_to_doctype = doctype
|
||||||
|
fd.doc.attached_to_name = doc.name
|
||||||
|
fd.save()
|
||||||
|
else:
|
||||||
|
fd = webnotes.bean("File Data", copy=fd.doclist)
|
||||||
|
fd.doc.attached_to_doctype = doctype
|
||||||
|
fd.doc.attached_to_name = doc.name
|
||||||
|
fd.insert()
|
||||||
else:
|
else:
|
||||||
webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
|
webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
|
||||||
fileid)
|
fileid)
|
||||||
11
patches/april_2013/p07_update_file_data_custom_field.py
Normal file
11
patches/april_2013/p07_update_file_data_custom_field.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import webnotes
|
||||||
|
def execute():
|
||||||
|
from patches.april_2013.p05_update_file_data import update_file_list, get_single_doctypes
|
||||||
|
singles = get_single_doctypes()
|
||||||
|
for doctype in webnotes.conn.sql("""select parent from `tabCustom Field` where
|
||||||
|
fieldname='file_list' and fieldtype='Text'"""):
|
||||||
|
update_file_list(doctype, singles)
|
||||||
|
|
||||||
|
webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list'
|
||||||
|
and parent=%s""", doctype)
|
||||||
|
|
||||||
@ -247,5 +247,6 @@ patch_list = [
|
|||||||
"execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
|
"execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
|
||||||
"patches.april_2013.p06_default_cost_center",
|
"patches.april_2013.p06_default_cost_center",
|
||||||
"execute:webnotes.reset_perms('File Data')",
|
"execute:webnotes.reset_perms('File Data')",
|
||||||
|
"patches.april_2013.p07_update_file_data_custom_field",
|
||||||
"patches.april_2013.rebuild_sales_browser",
|
"patches.april_2013.rebuild_sales_browser",
|
||||||
]
|
]
|
||||||
@ -34,7 +34,8 @@ def upload(select_doctype=None, rows=None):
|
|||||||
|
|
||||||
rename_log = []
|
rename_log = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
if len(row) > 2:
|
# if row has some content
|
||||||
|
if len(row) > 1 and row[0] and row[1]:
|
||||||
try:
|
try:
|
||||||
if rename_doc(select_doctype, row[0], row[1]):
|
if rename_doc(select_doctype, row[0], row[1]):
|
||||||
rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
|
rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user