Fix user permisions

This commit is contained in:
?ngel ?lvarez 2014-07-30 11:06:29 +02:00
parent 17d4f1aae7
commit bc34483595
10 changed files with 151 additions and 24 deletions

9
CHANGELOG Normal file
View File

@ -0,0 +1,9 @@
* Fix user permisions
Version 3.2.0 - 2014-05-22
* Allow to execute reports in background through celery
Version 3.0.0 - 2013-10-30
Version 2.9.0 - 2013-09-08
* Initial release

43
babi.py
View File

@ -18,7 +18,7 @@ from trytond.wizard import Wizard, StateView, StateAction, StateTransition, \
Button
from trytond.model import ModelSQL, ModelView, fields
from trytond.model.fields import depends
from trytond.pyson import Eval, Bool, PYSONEncoder, In, Not, PYSONDecoder
from trytond.pyson import Eval, Bool, PYSONEncoder, Id, In, Not, PYSONDecoder
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.tools import safe_eval
@ -379,7 +379,11 @@ class Filter(ModelSQL, ModelView):
'result is True the record will be included, it will be discarded '
'otherwise.')
parameters = fields.One2Many('babi.filter.parameter', 'filter',
'Parameters')
'Parameters',
states={
'invisible': Not(Eval('context', {}).get('groups', []).contains(
Id('babi', 'group_babi_admin'))),
})
fields = fields.Function(fields.Many2Many('ir.model.field', None, None,
'Model Fields', depends=['model']),
'on_change_with_fields')
@ -537,7 +541,10 @@ class Report(ModelSQL, ModelView):
domain=[('babi_enabled', '=', True)], help='Model for data extraction')
model_name = fields.Function(fields.Char('Model Name'),
'on_change_with_model_name')
internal_name = fields.Function(fields.Char('Internal Name'),
internal_name = fields.Function(fields.Char('Internal Name', states={
'invisible': Not(Eval('context', {}).get('groups', []
).contains(Id('babi', 'group_babi_admin'))),
}),
'get_internal_name')
filter = fields.Many2One('babi.filter', 'Filter',
domain=[('model', '=', Eval('model'))], depends=['model'])
@ -554,16 +561,32 @@ class Report(ModelSQL, ModelView):
parent_menu = fields.Many2One('ir.ui.menu', 'Parent Menu',
required=True)
menus = fields.One2Many('ir.ui.menu', 'babi_report', 'Menus',
readonly=True)
readonly=True,
states={
'invisible': Not(Eval('context', {}).get('groups', []).contains(
Id('babi', 'group_babi_admin'))),
})
actions = fields.One2Many('ir.action.act_window', 'babi_report',
'Actions', readonly=True)
'Actions', readonly=True,
states={
'invisible': Not(Eval('context', {}).get('groups', []).contains(
Id('babi', 'group_babi_admin'))),
})
keywords = fields.One2Many('ir.action.keyword', 'babi_report', 'Keywords',
readonly=True)
readonly=True,
states={
'invisible': Not(Eval('context', {}).get('groups', []).contains(
Id('babi', 'group_babi_admin'))),
})
timeout = fields.Integer('Timeout', required=True, help='If report '
'calculation should take more than the specified timeout (in seconds) '
'the process will be stopped automatically.')
executions = fields.One2Many('babi.report.execution', 'report',
'Executions', readonly=True, order=[('date', 'DESC')])
'Executions', readonly=True, order=[('date', 'DESC')],
states={
'invisible': Not(Eval('context', {}).get('groups', []).contains(
Id('babi', 'group_babi_admin'))),
})
last_execution = fields.Function(fields.Many2One('babi.report.execution',
'Last Executions', readonly=True), 'get_last_execution')
crons = fields.One2Many('ir.cron', 'babi_report', 'Schedulers',
@ -1030,12 +1053,14 @@ class ReportExecution(ModelSQL, ModelView):
@classmethod
def calculate(cls, executions):
transaction = Transaction()
for execution in executions:
execution.save_state(execution.id, 'in_progress')
date = execution.create_date
with Transaction().set_context(_datetime=date):
with transaction.set_context(_datetime=date):
execution.validate_model()
execution.create_keywords()
with transaction.set_user(0):
execution.create_keywords()
try:
execution.create_data()
except TimeoutException:

View File

@ -60,6 +60,14 @@ contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_babi_dimension_babi">
<field name="model" search="[('model', '=', 'babi.dimension')]"/>
<field name="group" ref="group_babi"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_babi_dimension_admin">
<field name="model" search="[('model', '=', 'babi.dimension')]"/>
<field name="group" ref="group_babi_admin"/>
@ -102,6 +110,14 @@ contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_babi_dimension_column_babi">
<field name="model" search="[('model', '=', 'babi.dimension.column')]"/>
<field name="group" ref="group_babi"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_babi_dimension_column_admin">
<field name="model" search="[('model', '=', 'babi.dimension.column')]"/>
<field name="group" ref="group_babi_admin"/>
@ -186,6 +202,14 @@ contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_babi_filter_babi">
<field name="model" search="[('model', '=', 'babi.filter')]"/>
<field name="group" ref="group_babi"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_babi_filter_admin">
<field name="model" search="[('model', '=', 'babi.filter')]"/>
<field name="group" ref="group_babi_admin"/>
@ -266,8 +290,8 @@ contains the full copyright notices and license terms. -->
<record model="ir.model.access" id="access_babi_internal_measure">
<field name="model" search="[('model', '=', 'babi.internal.measure')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_babi_internal_measure_admin">
@ -312,6 +336,14 @@ contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_babi_measure_babi">
<field name="model" search="[('model', '=', 'babi.measure')]"/>
<field name="group" ref="group_babi"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_babi_measure_admin">
<field name="model" search="[('model', '=', 'babi.measure')]"/>
<field name="group" ref="group_babi_admin"/>
@ -354,6 +386,14 @@ contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_babi_order_babi">
<field name="model" search="[('model', '=', 'babi.order')]"/>
<field name="group" ref="group_babi"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_babi_order_admin">
<field name="model" search="[('model', '=', 'babi.order')]"/>
<field name="group" ref="group_babi_admin"/>
@ -390,6 +430,11 @@ contains the full copyright notices and license terms. -->
<field name="model">babi.report,-1</field>
<field name="action" ref="act_babi_report_execution_form"/>
</record>
<record model="ir.action-res.group"
id="act_babi_report_execution_form-group_babi_admin">
<field name="action" ref="act_babi_report_execution_form"/>
<field name="group" ref="group_babi_admin"/>
</record>
<record model="ir.action.act_window.view" id="act_babi_report_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="babi_report_tree_view"/>
@ -407,6 +452,14 @@ contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_babi_report_babi">
<field name="model" search="[('model', '=', 'babi.report')]"/>
<field name="group" ref="group_babi"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_babi_report_admin">
<field name="model" search="[('model', '=', 'babi.report')]"/>
<field name="group" ref="group_babi_admin"/>
@ -433,7 +486,7 @@ contains the full copyright notices and license terms. -->
<record model="ir.model.access" id="access_babi_execution">
<field name="model" search="[('model', '=', 'babi.report.execution')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="False"/>
</record>
@ -469,7 +522,7 @@ contains the full copyright notices and license terms. -->
<field name="name">open_execution_select_form</field>
</record>
<record model="ir.action.wizard" id="open_execution_wizard">
<field name="name">Bussiness Inteligence Report</field>
<field name="name">Business Inteligence Report</field>
<field name="wiz_name">babi.report.execution.open</field>
</record>
@ -505,7 +558,23 @@ contains the full copyright notices and license terms. -->
parent="menu_configuration" sequence="20" name="Filters"/>
<menuitem action="act_babi_report" id="menu_babi_report"
parent="menu_babi" sequence="20" name="Reports"/>
<record model="ir.ui.menu-res.group"
id="menu_report_group_babi">
<field name="menu" ref="menu_babi_report"/>
<field name="group" ref="group_babi"/>
</record>
<record model="ir.ui.menu-res.group"
id="menu_report_group_babi_admin">
<field name="menu" ref="menu_babi_report"/>
<field name="group" ref="group_babi_admin"/>
</record>
<menuitem action="act_babi_execution" id="menu_babi_execution"
parent="menu_babi_report" sequence="10" name="Executions"/>
<record model="ir.ui.menu-res.group"
id="menu_execution_group_babi_admin">
<field name="menu" ref="menu_babi_execution"/>
<field name="group" ref="group_babi_admin"/>
</record>
</data>
</tryton>

23
cron.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--The COPYRIGHT file at the top level of this repository
contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.model.access" id="access_babi_cron">
<field name="model" search="[('model', '=', 'ir.cron')]"/>
<field name="group" ref="group_babi"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_babi_cron_admin">
<field name="model" search="[('model', '=', 'ir.cron')]"/>
<field name="group" ref="group_babi_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
</data>
</tryton>

View File

@ -1066,8 +1066,8 @@ msgid "open chart"
msgstr "Obre gràfica"
msgctxt "model:ir.action,name:open_execution_wizard"
msgid "Bussiness Inteligence Report"
msgstr "Informe de Bussiness Inteligence"
msgid "Business Inteligence Report"
msgstr "Informe de Business Inteligence"
msgctxt "model:ir.ui.menu,name:menu_babi"
msgid "Business Intelligence"
@ -1111,7 +1111,7 @@ msgstr "Business Intelligence"
msgctxt "model:res.group,name:group_babi_admin"
msgid "Business Intelligence Administration"
msgstr "Administració Bussiness Intelligence"
msgstr "Administració Business Intelligence"
msgctxt "selection:babi.expression,ttype:"
msgid "Boolean"

View File

@ -1096,7 +1096,7 @@ msgid "open chart"
msgstr "Diagramm öffnen"
msgctxt "model:ir.action,name:open_execution_wizard"
msgid "Bussiness Inteligence Report"
msgid "Business Inteligence Report"
msgstr "Business Intelligence Bericht"
msgctxt "model:ir.ui.menu,name:menu_babi"

View File

@ -1070,12 +1070,12 @@ msgid "open chart"
msgstr "Abrir gráfico"
msgctxt "model:ir.action,name:open_execution_wizard"
msgid "Bussiness Inteligence Report"
msgstr "Informe de Bussiness Inteligence"
msgid "Business Inteligence Report"
msgstr "Informe de Business Inteligence"
msgctxt "model:ir.ui.menu,name:menu_babi"
msgid "Business Intelligence"
msgstr "Bussiness Intelligence"
msgstr "Business Intelligence"
msgctxt "model:ir.ui.menu,name:menu_babi_configuration"
msgid "Business Intelligence Configuration"
@ -1111,11 +1111,11 @@ msgstr "Actualitzar información"
msgctxt "model:res.group,name:group_babi"
msgid "Business Intelligence"
msgstr "Bussiness Intelligence"
msgstr "Business Intelligence"
msgctxt "model:res.group,name:group_babi_admin"
msgid "Business Intelligence Administration"
msgstr "Administración Bussiness Intelligence"
msgstr "Administración Business Intelligence"
msgctxt "selection:babi.expression,ttype:"
msgid "Boolean"

View File

@ -39,7 +39,7 @@ tests_require = ['proteus >= %s.%s, < %s.%s' %
setup(name='%s_%s' % (PREFIX, MODULE),
version=info.get('version', '0.0.1'),
description='Bussiness Inteligence module for tryton',
description='Business Inteligence module for tryton',
long_description=read('README'),
author='NaN·tic',
url='http://www.nan-tic.com/',

View File

@ -6,3 +6,4 @@ depends:
xml:
babi.xml
configuration.xml
cron.xml

View File

@ -27,7 +27,7 @@ contains the full copyright notices and license terms. -->
<button name="remove_menus" string="Remove Menus"/>
</group>
</page>
<page id="executions" string="Executions">
<page name="executions" string="Executions">
<field name="executions" colspan="4" />
</page>
<page id="extra" string="Extra Information">