Add depends attribute to data tag

This is the counterpart of the Pool register of extras_depend modules for the
XML record creation. It allow to create records if some other modules are
installed.

review3041002
This commit is contained in:
Cédric Krier
2014-02-06 22:30:11 +01:00
parent 29358683cd
commit 5a73f91a6d
4 changed files with 17 additions and 3 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add depends attribute to data tag
* Add tree_invisible attribute to button in tree view
* Drop support of Python 2.6
* Deprecate on_change, on_change_with, selection_change_with and autocomplete
+6 -3
View File
@@ -110,9 +110,12 @@ Here is the list of the tags:
* ``tryton``: The main tag of the xml
* ``data``: Define a set of data inside the file. It can have the
attributes ``noupdate`` to prevent the framework to update the records,
``skiptest`` to prevent import of data when running tests and ``grouped``
to create records at the end with a grouped call.
attributes:
* ``noupdate`` to prevent the framework to update the records,
* ``skiptest`` to prevent import of data when running tests,
* ``depends`` to import data only if all modules in the comma separated
module list value are installed,
* ``grouped`` to create records at the end with a grouped call.
* ``record``: Create a record of the model defined by the attribute
``model`` in the database. The ``id`` attribute can be used to refer to
+9
View File
@@ -408,6 +408,10 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
self.grouped_write = defaultdict(list)
self.grouped_model_data = []
self.skip_data = False
Module = pool.get('ir.module.module')
self.installed_modules = [m.name for m in Module.search([
('state', 'in', ['installed', 'to upgrade']),
])]
# Tag handlders are used to delegate the processing
self.taghandlerlist = {
@@ -459,6 +463,11 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
self.skip_data = True
else:
self.skip_data = False
depends = attributes.get('depends', '').split(',')
depends = [m.strip() for m in depends if m]
if depends:
if not all((m in self.installed_modules for m in depends)):
self.skip_data = True
elif name == "tryton":
pass
+1
View File
@@ -7,6 +7,7 @@ attlist.data &=
[ a:defaultValue = "0" ] attribute noupdate { "0" | "1" }?
attlist.data &=
[ a:defaultValue = "0" ] attribute grouped { "0" | "1" }?
attlist.data &= attribute depends { text }
record = element record { attlist.record, field* }
attlist.record &= attribute model { text }
attlist.record &= attribute id { text }