committed by
Jairo Llopis
5 changed files with 53 additions and 56 deletions
-
40web_action_conditionable/README.rst
-
1web_action_conditionable/__init__.py
-
8web_action_conditionable/__manifest__.py
-
44web_action_conditionable/static/src/js/views.js
-
16web_action_conditionable/views/view.xml
@ -1 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
@ -1,13 +1,13 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
{ |
{ |
||||
"name": 'web_action_conditionable', |
"name": 'web_action_conditionable', |
||||
"version": "8.0.0.1.0", |
|
||||
|
"version": "11.0.1.0.0", |
||||
"depends": [ |
"depends": [ |
||||
'base', |
'base', |
||||
'web', |
'web', |
||||
], |
], |
||||
'data': ['views/view.xml'], |
'data': ['views/view.xml'], |
||||
"author": "Cristian Salamea,Odoo Community Association (OCA)", |
"author": "Cristian Salamea,Odoo Community Association (OCA)", |
||||
'installable': False, |
|
||||
|
"website": "https://github.com/OCA/web", |
||||
|
"license": "AGPL-3", |
||||
|
'installable': True, |
||||
} |
} |
@ -1,22 +1,24 @@ |
|||||
/*global openerp, _, $ */ |
|
||||
|
odoo.define('web.web_action_conditionable', function (require) { |
||||
|
"use strict"; |
||||
|
|
||||
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) { |
|
||||
try { |
|
||||
return this._super(action); |
|
||||
} catch(error) { |
|
||||
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; |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
|
var View = require('web.View'); |
||||
|
|
||||
|
View.include({ |
||||
|
is_action_enabled: function(action) { |
||||
|
var attrs = this.fields_view.arch.attrs; |
||||
|
if (action in attrs) { |
||||
|
try { |
||||
|
return this._super(action); |
||||
|
} catch(error) { |
||||
|
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; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}); |
@ -1,10 +1,8 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?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> |
|
||||
|
<odoo> |
||||
|
<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> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue