diff --git a/base_view_inheritance_extension/README.rst b/base_view_inheritance_extension/README.rst
index f5eaa8ba6..af1675b65 100644
--- a/base_view_inheritance_extension/README.rst
+++ b/base_view_inheritance_extension/README.rst
@@ -6,7 +6,8 @@
Extended view inheritance
=========================
-This module was written to make it simple to add custom operators for view inheritance.
+This module was written to make it simple to add custom operators for view
+inheritance.
Usage
=====
@@ -24,7 +25,8 @@ Change a python dictionary (context for example)
$new_value
-Note that views are subject to evaluation of xmlids anyways, so if you need to refer to some xmlid, say ``%(xmlid)s``.
+Note that views are subject to evaluation of xmlids anyways, so if you need
+to refer to some xmlid, say ``%(xmlid)s``.
Move an element in the view
---------------------------
@@ -33,13 +35,30 @@ Move an element in the view
-This can also be used to wrap some element into another, create the target element first, then move the node youwant to wrap there.
+This can also be used to wrap some element into another, create the target
+element first, then move the node youwant to wrap there.
+
+Add to values in a list (states for example)
+--------------------------------------------
+
+.. code-block:: xml
+
+
+ $new_value(s)
+
+
+Remove values from a list (states for example)
+----------------------------------------------
+
+.. code-block:: xml
+
+
+ $remove_value(s)
+
Known issues / Roadmap
======================
-* add ``$value``
-* add ``$index``
* add ``$value``
* support ````
* support an ``eval`` attribute for our new node types
@@ -58,14 +77,21 @@ Credits
Images
------
-* Odoo Community Association: `Icon `_.
+* Odoo Community Association:
+ `Icon `_.
Contributors
------------
* Holger Brunn
+* Ronald Portier
-Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues.
+Do not contact contributors directly about help with questions or problems
+concerning this addon, but use the
+`community mailing list `_ or the
+`appropriate specialized mailinglist `_
+for help, and the bug tracker linked in `Bug Tracker`_ above for
+technical issues.
Maintainer
----------
diff --git a/base_view_inheritance_extension/__openerp__.py b/base_view_inheritance_extension/__openerp__.py
index d4304a540..a9e251017 100644
--- a/base_view_inheritance_extension/__openerp__.py
+++ b/base_view_inheritance_extension/__openerp__.py
@@ -3,7 +3,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Extended view inheritance",
- "version": "9.0.1.0.0",
+ "version": "9.0.1.1.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "LGPL-3",
"category": "Hidden/Dependency",
diff --git a/base_view_inheritance_extension/i18n/ca.po b/base_view_inheritance_extension/i18n/ca.po
new file mode 100644
index 000000000..1e6d67e2b
--- /dev/null
+++ b/base_view_inheritance_extension/i18n/ca.po
@@ -0,0 +1,34 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * base_view_inheritance_extension
+#
+# Translators:
+# Marc Tormo i Bochaca , 2017
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 9.0c\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-04-19 17:59+0000\n"
+"PO-Revision-Date: 2017-04-19 17:59+0000\n"
+"Last-Translator: Marc Tormo i Bochaca , 2017\n"
+"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: ca\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: base_view_inheritance_extension
+#: model:ir.ui.view,arch_db:base_view_inheritance_extension.view_partner_form
+msgid "A new page"
+msgstr "Una nova pĂ gina "
+
+#. module: base_view_inheritance_extension
+#: model:ir.ui.view,arch_db:base_view_inheritance_extension.view_partner_form
+msgid "Partner form"
+msgstr "Empresa de "
+
+#. module: base_view_inheritance_extension
+#: model:ir.model,name:base_view_inheritance_extension.model_ir_ui_view
+msgid "ir.ui.view"
+msgstr "ir.ui.view"
diff --git a/base_view_inheritance_extension/i18n/de.po b/base_view_inheritance_extension/i18n/de.po
index c9e0e1ffa..1e8b83970 100644
--- a/base_view_inheritance_extension/i18n/de.po
+++ b/base_view_inheritance_extension/i18n/de.po
@@ -3,13 +3,14 @@
# * base_view_inheritance_extension
#
# Translators:
+# OCA Transbot , 2017
# Rudolf Schnapka , 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-03-04 07:39+0000\n"
-"PO-Revision-Date: 2017-03-04 07:39+0000\n"
+"POT-Creation-Date: 2017-04-19 17:59+0000\n"
+"PO-Revision-Date: 2017-04-19 17:59+0000\n"
"Last-Translator: Rudolf Schnapka , 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"MIME-Version: 1.0\n"
@@ -31,4 +32,4 @@ msgstr "Partner-Formular"
#. module: base_view_inheritance_extension
#: model:ir.model,name:base_view_inheritance_extension.model_ir_ui_view
msgid "ir.ui.view"
-msgstr ""
+msgstr "ir.ui.view"
diff --git a/base_view_inheritance_extension/i18n/it.po b/base_view_inheritance_extension/i18n/it.po
new file mode 100644
index 000000000..dea907836
--- /dev/null
+++ b/base_view_inheritance_extension/i18n/it.po
@@ -0,0 +1,34 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * base_view_inheritance_extension
+#
+# Translators:
+# Paolo Valier , 2017
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 9.0c\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-04-19 17:59+0000\n"
+"PO-Revision-Date: 2017-04-19 17:59+0000\n"
+"Last-Translator: Paolo Valier , 2017\n"
+"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: it\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: base_view_inheritance_extension
+#: model:ir.ui.view,arch_db:base_view_inheritance_extension.view_partner_form
+msgid "A new page"
+msgstr "Una nuova pagina"
+
+#. module: base_view_inheritance_extension
+#: model:ir.ui.view,arch_db:base_view_inheritance_extension.view_partner_form
+msgid "Partner form"
+msgstr ""
+
+#. module: base_view_inheritance_extension
+#: model:ir.model,name:base_view_inheritance_extension.model_ir_ui_view
+msgid "ir.ui.view"
+msgstr ""
diff --git a/base_view_inheritance_extension/models/ir_ui_view.py b/base_view_inheritance_extension/models/ir_ui_view.py
index 752220079..a32baee9d 100644
--- a/base_view_inheritance_extension/models/ir_ui_view.py
+++ b/base_view_inheritance_extension/models/ir_ui_view.py
@@ -122,3 +122,40 @@ class IrUiView(models.Model):
)
target_node.append(node)
return source
+
+ @api.model
+ def inheritance_handler_attributes_list_add(
+ self, source, specs, inherit_id
+ ):
+ """Implement
+ <$node position="attributes">
+
+ $new_value
+
+ $node>"""
+ node = self.locate_node(source, specs)
+ for attribute_node in specs:
+ attribute_name = attribute_node.get('name')
+ old_value = node.get(attribute_name) or ''
+ new_value = old_value + ',' + attribute_node.text
+ node.attrib[attribute_name] = new_value
+ return source
+
+ @api.model
+ def inheritance_handler_attributes_list_remove(
+ self, source, specs, inherit_id
+ ):
+ """Implement
+ <$node position="attributes">
+
+ $value_to_remove
+
+ $node>"""
+ node = self.locate_node(source, specs)
+ for attribute_node in specs:
+ attribute_name = attribute_node.get('name')
+ old_values = (node.get(attribute_name) or '').split(',')
+ remove_values = attribute_node.text.split(',')
+ new_values = [x for x in old_values if x not in remove_values]
+ node.attrib[attribute_name] = ','.join(filter(None, new_values))
+ return source
diff --git a/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py b/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py
index 2429b4f6f..af1e2c6ba 100644
--- a/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py
+++ b/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py
@@ -6,6 +6,7 @@ from openerp.tests.common import TransactionCase
class TestBaseViewInheritanceExtension(TransactionCase):
+
def test_base_view_inheritance_extension(self):
view_id = self.env.ref('base.view_partner_form').id
fields_view_get = self.env['res.partner'].fields_view_get(
@@ -28,3 +29,85 @@ class TestBaseViewInheritanceExtension(TransactionCase):
view.xpath('//field[@name="child_ids"]')[0].getparent(),
view.xpath('//page[@name="my_new_page"]')[0]
)
+
+ def test_list_add(self):
+ view_model = self.env['ir.ui.view']
+ inherit_id = self.env.ref('base.view_partner_form').id
+ source = etree.fromstring(
+ """\
+
+ """
+ )
+ # extend with single value
+ specs = etree.fromstring(
+ """\
+
+ """
+ )
+ modified_source = \
+ view_model.inheritance_handler_attributes_list_add(
+ source, specs, inherit_id
+ )
+ button_node = modified_source.xpath('//button[@name="test"]')[0]
+ self.assertEqual(
+ button_node.attrib['states'],
+ 'draft,open,valid'
+ )
+ # extend with list of values
+ specs = etree.fromstring(
+ """\
+
+ """
+ )
+ modified_source = \
+ view_model.inheritance_handler_attributes_list_add(
+ source, specs, inherit_id
+ )
+ button_node = modified_source.xpath('//button[@name="test"]')[0]
+ self.assertEqual(
+ button_node.attrib['states'],
+ 'draft,open,valid,payable,paid'
+ )
+
+ def test_list_remove(self):
+ view_model = self.env['ir.ui.view']
+ inherit_id = self.env.ref('base.view_partner_form').id
+ source = etree.fromstring(
+ """\
+
+ """
+ )
+ # remove list of values
+ specs = etree.fromstring(
+ """\
+
+ """
+ )
+ modified_source = \
+ view_model.inheritance_handler_attributes_list_remove(
+ source, specs, inherit_id
+ )
+ button_node = modified_source.xpath('//button[@name="test"]')[0]
+ self.assertEqual(
+ button_node.attrib['states'],
+ 'draft,valid,paid'
+ )