fix: Pass Meta instance to updatedb
- Check if Property Setter exists
This commit is contained in:
parent
d495e9c3d4
commit
4c8d209c4c
2 changed files with 13 additions and 11 deletions
|
|
@ -24,6 +24,7 @@ from frappe.modules import make_boilerplate, get_doc_path
|
|||
from frappe.database.schema import validate_column_name, validate_column_length
|
||||
from frappe.model.docfield import supports_translation
|
||||
from frappe.modules.import_file import get_file_path
|
||||
from frappe.model.meta import Meta
|
||||
|
||||
|
||||
class InvalidFieldNameError(frappe.ValidationError): pass
|
||||
|
|
@ -275,7 +276,7 @@ class DocType(Document):
|
|||
"""Update database schema, make controller templates if `custom` is not set and clear cache."""
|
||||
self.delete_duplicate_custom_fields()
|
||||
try:
|
||||
frappe.db.updatedb(self.name)
|
||||
frappe.db.updatedb(self.name, Meta(self))
|
||||
except Exception as e:
|
||||
print("\n\nThere was an issue while migrating the DocType: {}\n".format(self.name))
|
||||
raise e
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class Meta(Document):
|
|||
|
||||
def get_valid_columns(self):
|
||||
if not hasattr(self, "_valid_columns"):
|
||||
if self.name in ("DocType", "DocField", "DocPerm", 'DocType Action', 'DocType Link', "Property Setter"):
|
||||
if self.name in ("DocType", "DocField", "DocPerm", 'DocType Action', 'DocType Link'):
|
||||
self._valid_columns = get_table_columns(self.name)
|
||||
else:
|
||||
self._valid_columns = self.default_fields + \
|
||||
|
|
@ -290,17 +290,17 @@ class Meta(Document):
|
|||
return get_workflow_name(self.name)
|
||||
|
||||
def add_custom_fields(self):
|
||||
try:
|
||||
self.extend("fields", frappe.db.sql("""SELECT * FROM `tabCustom Field`
|
||||
WHERE dt = %s AND docstatus < 2""", (self.name,), as_dict=1,
|
||||
update={"is_custom_field": 1}))
|
||||
except Exception as e:
|
||||
if frappe.db.is_table_missing(e):
|
||||
return
|
||||
else:
|
||||
raise
|
||||
if not frappe.db.table_exists('Custom Field'):
|
||||
return
|
||||
|
||||
self.extend("fields", frappe.db.sql("""SELECT * FROM `tabCustom Field`
|
||||
WHERE dt = %s AND docstatus < 2""", (self.name,), as_dict=1,
|
||||
update={"is_custom_field": 1}))
|
||||
|
||||
def apply_property_setters(self):
|
||||
if not frappe.db.table_exists('Property Setter'):
|
||||
return
|
||||
|
||||
property_setters = frappe.db.sql("""select * from `tabProperty Setter` where
|
||||
doc_type=%s""", (self.name,), as_dict=1)
|
||||
|
||||
|
|
@ -371,6 +371,7 @@ class Meta(Document):
|
|||
if frappe.flags.in_patch or frappe.flags.in_install:
|
||||
return
|
||||
|
||||
|
||||
if not self.istable and self.name not in ('DocType', 'DocField', 'DocPerm',
|
||||
'Custom DocPerm'):
|
||||
custom_perms = frappe.get_all('Custom DocPerm', fields='*',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue