Browse Source
[IMP] kpi_dashboard: Allow to set a context on the action
12.0
Enric Tobella
4 years ago
No known key found for this signature in database
GPG Key ID: D76663C0B4023597
4 changed files with
14 additions and
7 deletions
-
kpi_dashboard/models/kpi_kpi.py
-
kpi_dashboard/static/src/js/widget/abstract_widget.js
-
kpi_dashboard/static/src/xml/dashboard.xml
-
kpi_dashboard/views/kpi_kpi.xml
|
|
@ -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> |
|
|
|