fix: create auto_repeat field if docfield/custom field does not exist
This commit is contained in:
parent
7afb5b0b73
commit
044da8a575
2 changed files with 4 additions and 3 deletions
|
|
@ -570,7 +570,8 @@ class DocType(Document):
|
|||
def make_repeatable(self):
|
||||
"""If allow_auto_repeat is set, add auto_repeat custom field."""
|
||||
if self.allow_auto_repeat:
|
||||
if not frappe.db.exists('Custom Field', {'fieldname': 'auto_repeat', 'dt': self.name}):
|
||||
if not frappe.db.exists('Custom Field', {'fieldname': 'auto_repeat', 'dt': self.name}) and \
|
||||
not frappe.db.exists('DocField', {'fieldname': 'auto_repeat', 'parent': self.name}):
|
||||
insert_after = self.fields[len(self.fields) - 1].fieldname
|
||||
df = dict(fieldname='auto_repeat', label='Auto Repeat', fieldtype='Link', options='Auto Repeat', insert_after=insert_after, read_only=1, no_copy=1, print_hide=1)
|
||||
create_custom_field(self.name, df)
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ class CustomizeForm(Document):
|
|||
|
||||
def create_auto_repeat_custom_field_if_requried(self, meta):
|
||||
if self.allow_auto_repeat:
|
||||
if not frappe.db.exists('Custom Field', {'fieldname': 'auto_repeat',
|
||||
'dt': self.doc_type}):
|
||||
if not frappe.db.exists('Custom Field', {'fieldname': 'auto_repeat', 'dt': self.doc_type}) and \
|
||||
not frappe.db.exists('DocField', {'fieldname': 'auto_repeat', 'parent': self.name}):
|
||||
insert_after = self.fields[len(self.fields) - 1].fieldname
|
||||
df = dict(
|
||||
fieldname='auto_repeat',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue