I previously developed a function in odoo 14 to select the saved draft for the new form record, but when I migrated it to odoo 16, these functions (updateControlPanel() and _setMode('edit')) could not be called. Can someone tell me how to refresh the field values on the form page in odoo 16? As you can see I've already created a handle for the record. Here's my code below:
patch(FormController.prototype, "BaseDraftController", {
async _createRecord(draft_id,form_json,initialState_context, parentID =undefined, additionalContext=undefined) {
const record = this.model.__bm__.get(this.model.root.__bm_handle__, { raw: true });
var context_ = record.getContext({ additionalContext: undefined});
var _context ={};
var __context ={};
_.forEach(context_, function(v, i) {
_context[i] = v;
__context[i] = v;
})
var _json = eval('('+form_json+')');
delete _json.message_main_attachment_id;
_json["base_draft_id"]= draft_id
_context["default__initialState_context"] = initialState_context;
_.forEach(_json, function(v, i) {
if(record.fields[i].type=='many2one' || record.fields[i].type=='one2many'){
if(typeof v == 'object' && v.length ==2){
if(v[0] !=null){
_context["default_"+i] = v[0];
}else{
delete _json[i];
}
}
} else {
_context["default_"+i] = v;
}
})
_context["default__all"] = _json;
const handle = await this.model.__bm__.load({
context: _context,
fields: record.fields,
fieldsInfo: record.fieldsInfo,
modelName: this.model_name,
parentID: parentID,
res_ids: record.res_ids,
type: 'record',
viewType: 'form',
});
this.model.__bm__.handle = handle;
// TypeError: this.updateControlPanel is not a function
this.updateControlPanel();
this._setMode('edit');
this.model.__bm__.localData[this.model.root.__bm_handle__].context=__context
},
)}
Thank you!