2014-10-26 17:56 GMT+01:00 Luis Daniel <[email protected]>: > Hi, Albert ... > I've never seen anything like what you tell me, where can I find > documentation to do it ?, in addition I tell you I do not need to save the > results of the view on any table in database.
As said, you just need to override the mentioned methods from ModelStorage: http://doc.tryton.org/3.4/trytond/doc/ref/models/models.html?highlight=modelstorage#trytond.model.ModelStorage Where it says "a list of values" in read() it means "list of dictionaries". The rest should look like any other model. More or less like this: newlist = [ {'field1': 'value1', 'field2': 1}, {'field2': 'value2', 'field2': 2}, ] class NewModel(ModelStorage, ModelView): field1 = fields.Char('Field 1') field2 = fields.Integer('Field 2') def search(cls, domain, offset=0, limit=None, order=None, count=False): return cls.browse(range(1, len(newlist)+1) def read(cls, ids, field_names=None): newlist = [x.copy() for x in newlist] res = [] count = 1 for x in newlist: if count not in ids: continue x['id'] = count res.append(x) count += 1 return res > > > El domingo, 26 de octubre de 2014 06:36:13 UTC-4, Albert Cervera Areny > escribió: >> >> 2014-10-26 2:15 GMT+01:00 Luis Daniel <[email protected]>: >> > Hi, I'm looking for a way to show in a Tree View some data stored in a >> > simple python list of tuples, but a only have found how to insert data >> > from >> > SQL queries or implementing the table_query method.... >> > so that, I don't know actually a way to insert my data in a tree view >> > (fields.One2Many) and to show that field in a view form. >> > >> > What can I do, to accomplish with this work? >> >> You should create a new class that inherits ModelStorage and overrides >> at least the following methods: >> >> - search() >> - read() >> >> You may also consider implementing: >> >> - create() >> - write() >> - delete() >> >> -- >> Albert Cervera i Areny >> Tel. 93 553 18 03 >> @albertnan >> www.NaN-tic.com -- Albert Cervera i Areny Tel. 93 553 18 03 @albertnan www.NaN-tic.com
