mirror of
https://github.com/frappe/books.git
synced 2024-12-25 04:06:04 +00:00
fix: Mandatory check
This commit is contained in:
parent
30f5ca1a2e
commit
827cad114a
@ -187,15 +187,17 @@ module.exports = class BaseDocument extends Observable {
|
||||
}
|
||||
|
||||
validateMandatory() {
|
||||
let missingMandatory = [getMissingMandatory(this)];
|
||||
let checkForMandatory = [this];
|
||||
let tableFields = this.meta.fields.filter(df => df.fieldtype === 'Table');
|
||||
tableFields.map(df => {
|
||||
let rows = this[df.fieldname];
|
||||
for (let row of rows) {
|
||||
missingMandatory = missingMandatory.concat(getMissingMandatory(row));
|
||||
}
|
||||
checkForMandatory = [...checkForMandatory, ...rows];
|
||||
});
|
||||
|
||||
let missingMandatory = checkForMandatory
|
||||
.map(doc => getMissingMandatory(doc))
|
||||
.filter(Boolean);
|
||||
|
||||
if (missingMandatory.length > 0) {
|
||||
let fields = missingMandatory.join('\n');
|
||||
let message = frappe._('Value missing for {0}', fields);
|
||||
@ -217,7 +219,7 @@ module.exports = class BaseDocument extends Observable {
|
||||
})
|
||||
.join(', ');
|
||||
|
||||
if (doc.meta.isChild) {
|
||||
if (message && doc.meta.isChild) {
|
||||
let parentfield = doc.parentdoc.meta.getField(doc.parentfield);
|
||||
message = `${parentfield.label} Row ${doc.idx + 1}: ${message}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user