fix: Comment to docstring and minor changes
- added description for args with example - 'yield' might not be the best idea, barely any improvement, so changed back to 'return'
This commit is contained in:
parent
d110b744d9
commit
f61ae3fd1a
1 changed files with 8 additions and 5 deletions
|
|
@ -30,10 +30,13 @@ def make_mapped_doc(method, source_name, selected_children=None, args=None):
|
|||
return method(source_name)
|
||||
|
||||
@frappe.whitelist()
|
||||
def map_docs(method, source_names, target_doc, args:str=None):
|
||||
# args => "{ 'supplier': 100 }"
|
||||
'''Returns the mapped document calling the given mapper method
|
||||
with each of the given source docs on the target doc'''
|
||||
def map_docs(method, source_names, target_doc, args: str = None):
|
||||
''' Returns the mapped document calling the given mapper method
|
||||
with each of the given source docs on the target doc
|
||||
|
||||
:param args: Args to pass to the mapper method
|
||||
E.g. args: "{ 'supplier': 'XYZ' }" '''
|
||||
|
||||
method = frappe.get_attr(method)
|
||||
if method not in frappe.whitelisted:
|
||||
raise frappe.PermissionError
|
||||
|
|
@ -41,7 +44,7 @@ def map_docs(method, source_names, target_doc, args:str=None):
|
|||
for src in json.loads(source_names):
|
||||
_args = (src, target_doc, json.loads(args)) if args else (src, target_doc)
|
||||
target_doc = method(*_args)
|
||||
yield target_doc
|
||||
return target_doc
|
||||
|
||||
def get_mapped_doc(from_doctype, from_docname, table_maps, target_doc=None,
|
||||
postprocess=None, ignore_permissions=False, ignore_child_tables=False):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue