Reputation: 1264
In Odoo/openerp docs and it says 'client actions' are entirely implemented client side that's it. they do not provide any example detailed documentation about it for Odoo v10.
Does anybody have precise idea of how to implement client action and full potential of it. (possibilities that we can implement with client actions.)
Upvotes: 6
Views: 6410
Reputation: 331
Client actions are basically menu-items defined in xml and the corresponding actions are mapped to a widget.
Following is the implementation of client actions:
Your XML file will contain the following code:
<record id="some-report-client-action" model="ir.actions.client">
<field name="name">Report Page</field>
<field name="tag">report.report_page</field>
</record>
<menuitem id="some-report-menuitem" name="Some" parent="pdf_report"
action="some-report-client-action"/>
Create a js file for creating a widget. It will contain the following code:
openerp.guard_payments = function(instance, local) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
local.HomePage = instance.Widget.extend({
template: 'MyQWebTemplate',
init: function(parent, options){
this._super.apply(this, arguments);
this.name=parent.name;
},
start: function() {
this._super.apply(this, arguments);
console.log('Widget Start')
},
});
//Following code will attach the above widget to the defined client action
instance.web.client_actions.add('report.report_page', 'instance.guard_payments.HomePage');
}
So as you can see we can create a fully custom QWeb template and add any functionality to it.
Basically this the best part provided by Odoo
Upvotes: 5