On a record's XML button click I'm returning a client action qweb wizard with javascript functions. After running some javascript functions I need to save the results in a specific record(The record from which this wizard was opened with a button click). All my functions work but I do not know how to fetch the ID of the record so I'm not able to save the data to that specific record. How to fetch the ID of the current record in Javascript?
The wizard is a QWEB Javascript Client Action type.
XML Button:
<button name="open_bio_window" string="Bio" type="object" class="oe_highlight"/>
Python method I use to call the wizard:
@api.multi
def open_bio_window(self):
return {
'res_model': 'bank.agent',
'type': 'ir.actions.client',
'tag': 'action_biometric_page',
'target': 'new'
}
Javascript Sample:
events: {
'click .discoverService': 'discoverService',
},
discoverService: function(ev){
// do something
var endPoint = "ENDPOINT";
// save endPoint to the record that called this method
},
How to save endPoint to field end_point in parent record?
Qweb Template Sample:
<t t-name="bank_model.BioCapture">
<h3>Bio Capture</h3>
<div>Please verify Device is connected! Press 'Start' after
verification.
</div>
<br/>
<img src="/bank_model/static/description/device_ready.png"/>
<br/>
<br/>
<div>
<button class="btn btn-info discoverService btnheight">Start</button>
</div>
</t>
I solved it by passing the ID as a parameter in python method call.
@api.multi
def open_bio_window(self):
for record in self:
return {
'res_model': 'bank.agent',
'type': 'ir.actions.client',
'tag': 'action_biometric_page',
'target': 'new',
'params': {'rec_id': record.id}
}
Then access that parameter in javascript.
init: function (parent, context) {
this._super(parent, context);
this.rec_id = context.params.rec_id;
this.dashboards_templates = ['bank_model.BioCapture'];
},