fix: Accounting Dimension custom fields should be admin owned (#19525)
* fix: Accounting Dimension custom fileds should be admin owned * fix: Update query * fix: Travis
This commit is contained in:
parent
a839510b33
commit
7aef9f3b43
@ -24,6 +24,11 @@ class AccountingDimension(Document):
|
||||
msg = _("Not allowed to create accounting dimension for {0}").format(self.document_type)
|
||||
frappe.throw(msg)
|
||||
|
||||
exists = frappe.db.get_value("Accounting Dimension", {'document_type': self.document_type}, ['name'])
|
||||
|
||||
if exists and self.is_new():
|
||||
frappe.throw("Document Type already used as a dimension")
|
||||
|
||||
def after_insert(self):
|
||||
if frappe.flags.in_test:
|
||||
make_dimension_in_accounting_doctypes(doc=self)
|
||||
@ -60,7 +65,8 @@ def make_dimension_in_accounting_doctypes(doc):
|
||||
"label": doc.label,
|
||||
"fieldtype": "Link",
|
||||
"options": doc.document_type,
|
||||
"insert_after": insert_after_field
|
||||
"insert_after": insert_after_field,
|
||||
"owner": "Administrator"
|
||||
}
|
||||
|
||||
if doctype == "Budget":
|
||||
|
@ -642,3 +642,4 @@ erpnext.patches.v12_0.generate_leave_ledger_entries
|
||||
erpnext.patches.v12_0.set_default_shopify_app_type
|
||||
erpnext.patches.v12_0.replace_accounting_with_accounts_in_home_settings
|
||||
erpnext.patches.v12_0.set_payment_entry_status
|
||||
erpnext.patches.v12_0.update_owner_fields_in_acc_dimension_custom_fields
|
||||
|
@ -0,0 +1,17 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_doctypes_with_dimensions
|
||||
|
||||
def execute():
|
||||
accounting_dimensions = frappe.db.sql("""select fieldname from
|
||||
`tabAccounting Dimension`""", as_dict=1)
|
||||
|
||||
doclist = get_doctypes_with_dimensions()
|
||||
|
||||
for dimension in accounting_dimensions:
|
||||
frappe.db.sql("""
|
||||
UPDATE `tabCustom Field`
|
||||
SET owner = 'Administrator'
|
||||
WHERE fieldname = %s
|
||||
AND dt IN (%s)""" % #nosec
|
||||
('%s', ', '.join(['%s']* len(doclist))), tuple([dimension.fieldname] + doclist))
|
Loading…
Reference in New Issue
Block a user