fix: Invalid reference doctypes for accounting dimensions (#19027)
* fix: Invalid reference doctypes for accounting dimensions * fix: Add server side validation for accounting doctypes * fix: set fieldname and label before insert
This commit is contained in:
parent
74fdfff5b5
commit
c2a9b14c96
@ -5,9 +5,13 @@ frappe.ui.form.on('Accounting Dimension', {
|
|||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
frm.set_query('document_type', () => {
|
frm.set_query('document_type', () => {
|
||||||
|
let invalid_doctypes = frappe.model.core_doctypes_list;
|
||||||
|
invalid_doctypes.push('Accounting Dimension', 'Project',
|
||||||
|
'Cost Center', 'Accounting Dimension Detail');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
name: ['not in', ['Accounting Dimension', 'Project', 'Cost Center', 'Accounting Dimension Detail']]
|
name: ['not in', invalid_doctypes]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -11,10 +11,20 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_field
|
|||||||
from frappe import scrub
|
from frappe import scrub
|
||||||
from frappe.utils import cstr
|
from frappe.utils import cstr
|
||||||
from frappe.utils.background_jobs import enqueue
|
from frappe.utils.background_jobs import enqueue
|
||||||
|
from frappe.model import core_doctypes_list
|
||||||
|
|
||||||
class AccountingDimension(Document):
|
class AccountingDimension(Document):
|
||||||
def before_insert(self):
|
def before_insert(self):
|
||||||
self.set_fieldname_and_label()
|
self.set_fieldname_and_label()
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
if self.document_type in core_doctypes_list + ('Accounting Dimension', 'Project',
|
||||||
|
'Cost Center', 'Accounting Dimension Detail') :
|
||||||
|
|
||||||
|
msg = _("Not allowed to create accounting dimension for {0}").format(self.document_type)
|
||||||
|
frappe.throw(msg)
|
||||||
|
|
||||||
|
def after_insert(self):
|
||||||
if frappe.flags.in_test:
|
if frappe.flags.in_test:
|
||||||
make_dimension_in_accounting_doctypes(doc=self)
|
make_dimension_in_accounting_doctypes(doc=self)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user