openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #23778
[Bug 1132894] Re: Move elements in view architecture instead of delete and reinsert them
** Changed in: openobject-server
Importance: Undecided => Wishlist
** Changed in: openobject-server
Status: New => Confirmed
** Changed in: openobject-server
Assignee: (unassigned) => OpenERP's Framework R&D (openerp-dev-framework)
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1132894
Title:
Move elements in view architecture instead of delete and reinsert them
Status in OpenERP Server:
Confirmed
Bug description:
Sometimes we need to move an element to another position in the view.
Other installed modules may have touched them and added or changes
some attributes. If we first delete the field or group or whatever and
then reinsert at the new position (with copy and paste from the
"original" xml definition) we may loose those modifications.
There should be a way to simply move the element to the new position
and keeping its attributes and content.
<xpath expr="//field[@name='function']" position="move" before="//label[@for='street']"/>
<xpath expr="//field[@name='title']" position="move" after="//field[@name='function']"/>
I figured out a way with small changes to
osv/orm.py/BaseModel::fields_view_get()::apply_inheritance_specs()
elif pos == 'attributes':
for child in spec.getiterator('attribute'):
attribute = (child.get('name'), child.text and child.text.encode('utf8') or None)
if attribute[1]:
node.set(attribute[0], attribute[1])
else:
del(node.attrib[attribute[0]])
+ elif pos == 'move':
+ expr2 = spec.get('before')
+ if expr2:
+ move_after = False
+ else:
+ move_after = True
+ expr2 = spec.get('after')
+ if expr2 is None:
+ raise_view_error("New position to move to is missing.", inherit_id)
+ node2 = source.xpath(expr2)
+ node2 = node2[0] if node2 else None
+ if node2 is None:
+ raise_view_error("Invalid position to move to.", inherit_id)
+ parent2 = node2.getparent()
+ node2_index = parent2.index(node2)
+ parent2.insert(node2_index + (1 if move_after else 0), node)
else:
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1132894/+subscriptions
References