feat: mechanism to set default value in mapping instead of remote fieldname
This commit is contained in:
parent
f0b46b22c0
commit
d23b6b4e67
3 changed files with 29 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"actions": [],
|
||||
"creation": "2019-09-27 12:46:50.165135",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
|
|
@ -6,16 +7,19 @@
|
|||
"field_order": [
|
||||
"local_fieldname",
|
||||
"remote_fieldname",
|
||||
"has_default_value",
|
||||
"default_value",
|
||||
"column_break_5",
|
||||
"is_child_table",
|
||||
"child_table_mapping"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"depends_on": "eval:!doc.has_default_value;",
|
||||
"fieldname": "remote_fieldname",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Remote Fieldname",
|
||||
"reqd": 1
|
||||
"label": "Remote Fieldname"
|
||||
},
|
||||
{
|
||||
"fieldname": "local_fieldname",
|
||||
|
|
@ -36,10 +40,28 @@
|
|||
"fieldtype": "Link",
|
||||
"label": "Child Table Mapping",
|
||||
"options": "Document Type Mapping"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_5",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "Check this If the value of the field is a default value and not to be fetched from the remote DocType's field",
|
||||
"fieldname": "has_default_value",
|
||||
"fieldtype": "Check",
|
||||
"label": "Has Default Value"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.has_default_value;",
|
||||
"fieldname": "default_value",
|
||||
"fieldtype": "Data",
|
||||
"label": "Default Value"
|
||||
}
|
||||
],
|
||||
"istable": 1,
|
||||
"modified": "2019-10-09 08:26:06.457122",
|
||||
"links": [],
|
||||
"modified": "2020-03-16 13:42:41.104161",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Event Streaming",
|
||||
"name": "Document Type Field Mapping",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ class DocumentTypeMapping(Document):
|
|||
doc[mapping.local_fieldname] = doc[mapping.remote_fieldname]
|
||||
doc.pop(mapping.remote_fieldname, None)
|
||||
|
||||
elif mapping.has_default_value:
|
||||
doc[mapping.local_fieldname] = mapping.default_value
|
||||
|
||||
doc['doctype'] = self.local_doctype
|
||||
return frappe.as_json(doc)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class EventConsumer(Document):
|
|||
event_producer.producer_doctypes = []
|
||||
for entry in config:
|
||||
if entry.get('has_mapping'):
|
||||
ref_doctype = consumer_site.get_value('Document Type Mapping', entry.get('mapping'), 'remote_doctype')
|
||||
ref_doctype = consumer_site.get_value('Document Type Mapping', 'remote_doctype', entry.get('mapping')).get('remote_doctype')
|
||||
else:
|
||||
ref_doctype = entry.get('ref_doctype')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue