I have made a popup form for sale order liner using the following structure:
<field name="order_line" mode="tree,kanban">
<form string="Sale Order Line">
</form>
</field>
The form by default has Save & New, Save & Close, Remove, and Discard. I was looking to add an extra option of "Save & Duplicate". In order to do this I attempted to overwrite the footer using xml however the normal write functions within a model doesn't work for order_lines due to the sale order not being saved yet (but still does not work if it is saved).
So next i tried to add it through JavaScript since that's how odoo inserts the button.
I have tried the duplicateRecord method, but it doesn't pass the order_line to python, next I added the values to context in JavaScript:
var data = record.data
var getcontext = record.getContext()
for (var attname in date) {getcontext[attname] = data[attname]}
return model.load({
fields: record.fields,
fieldsInfo: record.fieldsInfo,
modelName: form.modelName,
parentID: self.parentID,
res_ids: record.res_ids,
context: getcontext,
type: 'record',
viewType: 'form',
}) .then(function (handle) {
form.handle = handle;
form._updateEnv();
return form._setMode('edit');
})
However this method never populated the next form.
Not sure if ive done something wroing or if this just isn;t the way to approach it?