diff --git a/CHANGELOG b/CHANGELOG
index a6f8245815..020f4b3b73 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Add permission groups on export
* Retry cron job on DatabaseOperationalError
* Add visual context on tree view
* Add start value to PYSON Date and DateTime
diff --git a/trytond/ir/__init__.py b/trytond/ir/__init__.py
index 0178085a87..0995478513 100644
--- a/trytond/ir/__init__.py
+++ b/trytond/ir/__init__.py
@@ -13,7 +13,7 @@ from .attachment import *
from .note import *
from .cron import *
from .lang import *
-from .export import *
+from . import export
from .rule import *
from .module import *
from .cache import *
@@ -73,8 +73,8 @@ def register():
NoteRead,
Cron,
Lang,
- Export,
- ExportLine,
+ export.Export,
+ export.ExportLine,
RuleGroup,
Rule,
Module,
diff --git a/trytond/ir/export.py b/trytond/ir/export.py
index c30aa45f25..f3c17851fc 100644
--- a/trytond/ir/export.py
+++ b/trytond/ir/export.py
@@ -2,10 +2,8 @@
# this repository contains the full copyright notices and license terms.
"Exports"
from ..model import ModelView, ModelSQL, fields
-
-__all__ = [
- 'Export', 'ExportLine',
- ]
+from trytond.pool import Pool
+from trytond.rpc import RPC
class _ClearCache(ModelSQL):
@@ -33,6 +31,24 @@ class Export(_ClearCache, ModelSQL, ModelView):
export_fields = fields.One2Many('ir.export.line', 'export',
'Fields')
+ @classmethod
+ def __setup__(cls):
+ super().__setup__()
+ cls.__rpc__.update(
+ update=RPC(instantiate=0, readonly=False))
+
+ @classmethod
+ def update(cls, exports, fields):
+ pool = Pool()
+ Line = pool.get('ir.export.line')
+ to_delete = []
+ to_save = []
+ for export in exports:
+ to_delete.extend(export.export_fields)
+ to_save.extend(Line(export=export, name=f) for f in fields)
+ Line.delete(to_delete)
+ Line.save(to_save)
+
class ExportLine(_ClearCache, ModelSQL, ModelView):
"Export line"
diff --git a/trytond/ir/view/export_list.xml b/trytond/ir/view/export_list.xml
index b63b25217c..abfbad42dd 100644
--- a/trytond/ir/view/export_list.xml
+++ b/trytond/ir/view/export_list.xml
@@ -4,4 +4,5 @@ this repository contains the full copyright notices and license terms. -->
+
diff --git a/trytond/res/__init__.py b/trytond/res/__init__.py
index ca2700e012..08aa51bdbb 100644
--- a/trytond/res/__init__.py
+++ b/trytond/res/__init__.py
@@ -4,7 +4,7 @@ from ..pool import Pool
from .group import *
from .user import *
-from .ir import *
+from . import ir
from . import routes
__all__ = ['register', 'routes']
@@ -20,18 +20,21 @@ def register():
Warning_,
UserApplication,
UserConfigStart,
- UIMenuGroup,
- ActionGroup,
- ModelButtonGroup,
- ModelButtonRule,
- ModelButtonClick,
- RuleGroupGroup,
- Lang,
- SequenceType,
- SequenceTypeGroup,
- Sequence,
- SequenceStrict,
- ModuleConfigWizardItem,
+ ir.UIMenuGroup,
+ ir.ActionGroup,
+ ir.ModelButtonGroup,
+ ir.ModelButtonRule,
+ ir.ModelButtonClick,
+ ir.RuleGroupGroup,
+ ir.Lang,
+ ir.SequenceType,
+ ir.SequenceTypeGroup,
+ ir.Sequence,
+ ir.SequenceStrict,
+ ir.ModuleConfigWizardItem,
+ ir.Export,
+ ir.Export_Group,
+ ir.Export_Write_Group,
module='res', type_='model')
Pool.register(
UserConfig,
diff --git a/trytond/res/ir.py b/trytond/res/ir.py
index 02c6adcd63..381d35bc65 100644
--- a/trytond/res/ir.py
+++ b/trytond/res/ir.py
@@ -2,14 +2,7 @@
# this repository contains the full copyright notices and license terms.
from ..model import ModelSQL, DeactivableMixin, fields
from ..pool import Pool, PoolMeta
-
-__all__ = [
- 'UIMenuGroup', 'ActionGroup', 'ModelButtonGroup',
- 'ModelButtonRule', 'ModelButtonClick',
- 'RuleGroupGroup', 'Lang', 'SequenceType',
- 'SequenceTypeGroup', 'Sequence', 'SequenceStrict',
- 'ModuleConfigWizardItem',
- ]
+from trytond.pyson import Eval
class UIMenuGroup(ModelSQL):
@@ -244,3 +237,38 @@ class ModuleConfigWizardItem(metaclass=PoolMeta):
super(ModuleConfigWizardItem, cls).delete(items)
# Restart the cache for get_preferences
User._get_preferences_cache.clear()
+
+
+class Export(metaclass=PoolMeta):
+ __name__ = 'ir.export'
+
+ groups = fields.Many2Many(
+ 'ir.export-res.group', 'export', 'group', "Groups",
+ help="The user groups that can use the export.")
+ write_groups = fields.Many2Many(
+ 'ir.export-write-res.group', 'export', 'group',
+ "Modification Groups",
+ domain=[
+ ('id', 'in', Eval('groups', [])),
+ ],
+ states={
+ 'invisible': ~Eval('groups'),
+ },
+ depends=['groups'],
+ help="The user groups that can modify the export.")
+
+
+class Export_Group(ModelSQL):
+ "Export Group"
+ __name__ = 'ir.export-res.group'
+
+ export = fields.Many2One(
+ 'ir.export', "Export", required=True, select=True, ondelete='CASCADE')
+ group = fields.Many2One(
+ 'res.group', "Group", required=True, ondelete='CASCADE')
+
+
+class Export_Write_Group(Export_Group):
+ "Export Modification Group"
+ __name__ = 'ir.export-write-res.group'
+ _table = None # Needed to reset Export_Group._table
diff --git a/trytond/res/ir.xml b/trytond/res/ir.xml
index 97eb0236fb..af1cd9264f 100644
--- a/trytond/res/ir.xml
+++ b/trytond/res/ir.xml
@@ -904,5 +904,131 @@ this repository contains the full copyright notices and license terms. -->
+
+ ir.export
+
+ export_form
+
+
+
+ ir.export
+
+ export_list
+
+
+
+ User in groups
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ User in modification groups
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Any export
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ User in groups
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ User in modification groups
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Any export
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trytond/res/view/export_form.xml b/trytond/res/view/export_form.xml
new file mode 100644
index 0000000000..939fb723fa
--- /dev/null
+++ b/trytond/res/view/export_form.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
diff --git a/trytond/res/view/export_list.xml b/trytond/res/view/export_list.xml
new file mode 100644
index 0000000000..56648add03
--- /dev/null
+++ b/trytond/res/view/export_list.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+