addToLocals<T extends FrappeDocument> method

  1. @override
void addToLocals<T extends FrappeDocument>(
  1. T doc
)
override

Adds the documents to a static local variable locals.

{
"User":{
        "Admin":[User Instance]
       }
},
{
"Item":{
      "Item 1": [Item Instance]
       }
}

Implementation

@override
void addToLocals<T extends FrappeDocument>(T doc) {
  EmptyDoctypeError.verify(doc.doctype);

  if (!locals.containsKey(doc.doctype)) {
    locals[doc.doctype!] = <String, dynamic>{};
  }
  if (doc.name == null) {
    doc.name = getNewName(doc.doctype!);
    doc.docStatus = FrappeDocStatus.Draft; // treat as a new doc
    doc.isLocal = true;
    doc.unsaved = true;
  }
  locals[doc.doctype]![doc.name!] = doc;
}