[IMP] kpi_dashboard: Allow to set a context on the action
parent
bbff077e5f
commit
f6f6f7bc35
|
@ -187,15 +187,17 @@ class KpiKpiAction(models.Model):
|
|||
('ir.actions.client', 'ir.actions.client')],
|
||||
required=True,
|
||||
)
|
||||
context = fields.Char()
|
||||
|
||||
def read_dashboard(self):
|
||||
result = []
|
||||
result = {}
|
||||
for r in self:
|
||||
result.append({
|
||||
result[r.id] = {
|
||||
'id': r.action.id,
|
||||
'type': r.action._name,
|
||||
'name': r.action.name
|
||||
})
|
||||
'name': r.action.name,
|
||||
'context': safe_eval(r.context or '{}')
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -82,7 +82,10 @@ odoo.define('kpi_dashboard.AbstractWidget', function (require) {
|
|||
_onClickDirectAction: function(event) {
|
||||
event.preventDefault();
|
||||
var $data = $(event.currentTarget).closest('a');
|
||||
return this.do_action($($data).data('id'));
|
||||
var action = this.actions[$($data).data('id')];
|
||||
return this.do_action(action.id, {
|
||||
additional_context: action.context
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
</t>
|
||||
<t t-name="kpi_dashboard.ManagePanel">
|
||||
<t t-if="widget.actions" >
|
||||
<t t-foreach="widget.actions" t-as="action">
|
||||
<t t-foreach="widget.actions" t-as="action_id">
|
||||
<t t-set="action" t-value="widget.actions[action_id]"/>
|
||||
<div role="menuitem" class="">
|
||||
<a role="menuitem" href="#" class="direct_action" t-att-data-id="action.id" t-att-data-type="action.type">Go to <t t-esc="action.name"/></a>
|
||||
<a role="menuitem" href="#" class="direct_action" t-att-data-id="action_id" t-att-data-type="action.type">Go to <t t-esc="action.name"/></a>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
|
|
|
@ -104,6 +104,7 @@
|
|||
<field name="action_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="action"/>
|
||||
<field name="context"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
|
Loading…
Reference in New Issue