1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """
23 Reads data from Open Object model.
24
25 Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>)
26 GNU General Public License
27 """
28
29 from etl.component import component
30
32 """
33 This is an ETL Component that use to read data from open object model.
34 Type : Data Component.
35 Computing Performance : Streamline.
36 Input Flows : 0.
37 * .* : Nothing.
38 Output Flows : 0-x.
39 * .* : Returns the main flow with data from open object model
40 """
41
42 - def __init__(self, openobject_connector, model, domain=[], fields=[], context={}, name='component.input.openerp_in', transformer=None, row_limit=0):
43 """
44 Required Parameters
45 openobject_connector : Object of Openobject connector.
46 model : Name of Open Object model.
47 domain : Domain List to put domain.
48 fields : Fields List.
49 context : Context Values.
50
51 Extra Parameters
52 row_limit : Row Limit.If row limit is 0,all records are fetched.
53 name : Name of Component.
54 transformer : Transformer object to transform string data into particular type.
55 """
56 super(openobject_in, self).__init__(name=name, connector=openobject_connector, transformer=transformer,row_limit=row_limit)
57 self._type = 'component.input.openerp_in'
58 self.model = model
59 self.domain = domain
60 self.context = context
61 self.fields = fields
62
66
68 import socket
69 import xmlrpclib
70 import datetime
71 rows = []
72 connector = self.connector.open()
73 ids = self.connector.execute(connector, 'execute', self.model, 'search', self.domain, 0, self.row_limit, False, self.context, False)
74 rows = self.connector.execute(connector, 'execute', self.model, 'read', ids, self.fields, self.context)
75 self.connector.close(connector)
76 for row in rows:
77 if row:
78 yield row, 'main'
79
81 from etl_test import etl_test
82 import etl
83 file_conn = etl.connector.openobject_connector('http://localhost:8069', 'trunk', 'admin', 'admin', con_type='xmlrpc')
84 test = etl_test.etl_component_test(openobject_in(file_conn, 'res.country',[('name', '=', 'Algeria')]))
85
86 test.check_output([{'name': 'Algeria', 'code': 'DZ', 'id': 61}], 'main')
87 res = test.output()
88 print res
89 if __name__ == '__main__':
90 test()
91