diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index ffd09ff5753..303842c91d7 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -128,6 +128,32 @@ def transfer_modifiers_to_node(modifiers, node): simplify_modifiers(modifiers) node.set('modifiers', simplejson.dumps(modifiers)) +def setup_modifiers(node, field=None, context=None, in_tree_view=False): + """ Processes node attributes and field descriptors to generate + the ``modifiers`` node attribute and set it on the provided node. + + Alters its first argument in-place. + + :param node: ``field`` node from an OpenERP view + :type node: lxml.etree._Element + :param dict field: field descriptor corresponding to the provided node + :param dict context: execution context used to evaluate node attributes + :param bool in_tree_view: triggers the ``tree_invisible`` code + path (separate from ``invisible``): in + tree view there are two levels of + invisibility, cell content (a column is + present but the cell itself is not + displayed) with ``invisible`` and column + invisibility (the whole column is + hidden) with ``tree_invisible``. + :returns: nothing + """ + modifiers = {} + if field is not None: + transfer_field_to_modifiers(field, modifiers) + transfer_node_to_modifiers( + node, modifiers, context=context, in_tree_view=in_tree_view) + transfer_modifiers_to_node(modifiers, node) def test_modifiers(what, expected): modifiers = {}