From 155c164e39bbc2444a0967c0e9a766cedddb10a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 16 Jun 2008 23:15:27 +0200 Subject: [PATCH] Remove pyxml dependency, use lxml instead --- account.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/account.py b/account.py index 527727caaa..13dc38d79d 100644 --- a/account.py +++ b/account.py @@ -3,8 +3,7 @@ from trytond.osv import fields, OSV from trytond.wizard import Wizard, WizardOSV from decimal import Decimal -from xml.dom import minidom -from xml import xpath +import copy class Account(OSV): @@ -236,27 +235,28 @@ class Account(OSV): or str(r[self._rec_name])) for r in self.read(cursor, user, ids, [self._rec_name, 'code'], context=context, load='_classic_write')] - def convert_view(self, cursor, user, node, context=None): - res = xpath.Evaluate('//field[@name=\'analytic_accounts\']', node) + def convert_view(self, cursor, user, tree, context=None): + res = tree.xpath('//field[@name=\'analytic_accounts\']') if not res: return - node_accounts = res[0] + element_accounts = res[0] root_account_ids = self.search(cursor, user, [ ('parent', '=', False), ], context=context) if not root_account_ids: - node_accounts.parentNode.parentNode.removeChild(node_accounts.parentNode) + element_accounts.getparent().getparent().remove( + element_accounts.getparent()) return for account_id in root_account_ids: - newnode = node_accounts.cloneNode(1) - newnode.tagName = 'label' - newnode.setAttribute('name', 'analytic_account_' + str(account_id)) - node_accounts.parentNode.insertBefore(newnode, node_accounts) - newnode = node_accounts.cloneNode(1) - newnode.setAttribute('name', 'analytic_account_' + str(account_id)) - node_accounts.parentNode.insertBefore(newnode, node_accounts) - node_accounts.parentNode.removeChild(node_accounts) + newelement = copy.copy(element_accounts) + newelement.tag = 'label' + newelement.set('name', 'analytic_account_' + str(account_id)) + element_accounts.getparent().addprevious(newelement) + newelement = copy.copy(element_accounts) + newelement.set('name', 'analytic_account_' + str(account_id)) + element_accounts.getparent().addprevious(newelement) + element_accounts.getparent().remove(element_accounts) def analytic_accounts_fields_get(self, cursor, user, field, fields_names=None, context=None):