forked from Techsystech/web
Web addon
This module implements condition for actions in tree view. do allows: edit=“false” create=“false” delete=“false” This module allows too: delete=“state==‘draft’”, simple expression.9.0
parent
0f386c122a
commit
0f3dbe6744
|
@ -0,0 +1,2 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": 'web_action_conditionable',
|
||||||
|
"version": "0.1",
|
||||||
|
"depends": [
|
||||||
|
'base',
|
||||||
|
'web',
|
||||||
|
],
|
||||||
|
'data': ['views/view.xml'],
|
||||||
|
"author": "Cristian Salamea,Odoo Community Association (OCA)",
|
||||||
|
"installable": True,
|
||||||
|
"active": False,
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*global openerp, _, $ */
|
||||||
|
|
||||||
|
openerp.web_action_conditionable = function (instance) {
|
||||||
|
instance.web.View.include({
|
||||||
|
is_action_enabled: function(action) {
|
||||||
|
var attrs = this.fields_view.arch.attrs;
|
||||||
|
if (action in attrs) {
|
||||||
|
if ($.type(attrs[action]) == 'boolean') {
|
||||||
|
return JSON.parse(attrs[action])
|
||||||
|
} else {
|
||||||
|
var expr = attrs[action];
|
||||||
|
var expression = py.parse(py.tokenize(expr));
|
||||||
|
var cxt = this.dataset.get_context().__eval_context.__contexts[1];
|
||||||
|
var result = py.evaluate(expression, cxt).toJSON();
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<template id="assets_backend" name="action conditionable assets" inherit_id="web.assets_backend">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/web_action_conditionable/static/src/js/views.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue