Map (frappe.model.mapper.get_mapped_doc) doctype with other’s doctype child table?

Hi

For example, get_mapped_doc maps ’Sales Order’ with ‘Material Request’ and ’Sales Order Item’ with ‘Material Request Item’.

Is it possible to map ’Sales Order’ with ‘Material Request Item’?

Thanks

Do you have some to share for testing ?

Sorry, I haven’t yet created normal app, but I copied below code snippets.

I want to create ‘Timesheet’ record from ‘Task’. ‘Timesheet Detail’ has to contain information from ‘Task’.

For now I found some workaround solution:
*) use ‘get_mapped_doc’ default behaviour (map doctype with doctype and childtable with childtable);
*) create some hidden section in ‘Timesheet’, for example, containing fields that I want to get from ‘Task’
*) in JS of ‘Timesheet’ (on refreshing) check does section ‘Information from task’ has data; if has data then create new record in Timesheet Detail (time_logs) and copy there data, and delete data from section ‘Information from task’;

=================
Py file:

def make_timesheet(source_name, target_doc = None):
doc = get_mapped_doc(“Task”, source_name, {“Task”: {“doctype”: “Timesheet”,},“Task”:{“doctype”:“Timesheet Detail”,“field_map”:{“name”:“task”, “expected_time”:“hours”},},}, target_doc)

JS:

frappe.ui.form.on(“Task”, {
refresh: function(cur_frm) {
cur_frm.add_custom_button(__(‘Make Timesheet’),
function() {
frappe.model.open_mapped_doc({
method: “path.to.py.file.make_timesheet”,
frm:cur_frm
})
}, __(“Make”));
},
});

=================
Global idea (for some manufacturing company):

  1. Add to ‘Item’ childtable ‘Item Operations’ (defining default operations for item in manufacturing process);
  2. When creating ‘BOM’ then ‘Item Operations’ (for BOM’s raw materials) are read in ‘BOM Operations’;
  3. When creating ‘Production Order’ from ‘BOM’, then from ‘BOM Operations’ automatically are generated ‘Tasks’ (for each “Raw Material"x"Operation"x"qty no”). We could use default workflow- ‘Timesheets’ generated from ‘Production Order Operations’, but, unfortunately, it is not possible to link employees to ‘Timesheets’ with ‘Production Order’; and it is not possible to link multiple employees to one operation; and it is not possible to normally track how much operations are done for each raw material).
  4. From ‘Task’ make ‘Timesheet’ (one or many) containing ‘Task’ information.
    =================

Hello @Bench_stop,

I have need to implement the same thing.
I would like to map the one doctype field to other doctype’s child table field.