1
##############################################################################
3
# Copyright (c) 2008-2011 Alistek Ltd (http://www.alistek.com) All Rights Reserved.
4
# General contacts <info@alistek.com>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 3
16
# of the License, or (at your option) any later version.
18
# This module is GPLv3 or newer and incompatible
19
# with OpenERP SA "AGPL + Private Use License"!
21
# This program is distributed in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
# GNU General Public License for more details.
26
# You should have received a copy of the GNU General Public License
27
# along with this program; if not, write to the Free Software
28
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30
##############################################################################
32
from report import report_sxw
33
from lxml import etree
35
class Parser(report_sxw.rml_parse):
36
def __init__(self, cr, uid, name, context):
37
super(Parser, self).__init__(cr, uid, name, context)
38
model = self.pool.get(context['model'])
41
model_id = self.pool.get('ir.model').search(cr, uid, [('model','=',model._name)])
43
model_desc = self.pool.get('ir.model').browse(cr, uid, model_id[0], context).name
45
model_desc = model._description
47
result = model.fields_view_get(cr, uid, view_type='tree', context=context)
48
fields_type = dict(map(lambda name: (name, result['fields'][name]['type']), result['fields']))
49
fields_order = self._parse_string(result['arch'])
50
rows = model.read(cr, uid, ids, context=context)
52
self.localcontext.update({
53
'screen_fields': fields_order,
54
'screen_fields_type': fields_type,
56
'screen_model': context['model'],
57
'screen_title': model_desc,
61
def _parse_node(self, root_node):
63
for node in root_node:
64
if node.tag == 'field':
65
result.append(node.get('name'))
67
result.extend(self._parse_node(node))
70
def _parse_string(self, view):
72
dom = etree.XML(view.encode('utf-8'))
75
return self._parse_node(dom)