Browse Source

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.
pull/200/head
Cristian Salamea 10 years ago
parent
commit
0f3dbe6744
  1. 2
      web_action_conditionable/__init__.py
  2. 14
      web_action_conditionable/__openerp__.py
  3. 22
      web_action_conditionable/static/src/js/views.js
  4. 10
      web_action_conditionable/views/view.xml

2
web_action_conditionable/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-

14
web_action_conditionable/__openerp__.py

@ -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,
}

22
web_action_conditionable/static/src/js/views.js

@ -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;
}
}
});
}

10
web_action_conditionable/views/view.xml

@ -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…
Cancel
Save