El 14/03/14 13:03, grasbauer ha escrit:
Am 14.03.2014 12:14, schrieb Jean C:

2014-03-14 11:58 GMT+01:00 Cédric Krier:

    It makes no senses to have the getter method of Function field
    creating
    instances.


Well I think Sergi's use case is valid. He does not create instances, he just
wants to display computed data, which is precisely the point of Function
fields.
I think you can do it in read of the ModelView returning a list of dictionaries with key 'id' and values for all fields_names. Also I guess you need to implement search by your own. The getter of the function.field need to return a dictionary with the ids you want to compute.

An exampe what we did once (in 2.4):
Thanks for sharing your code, but i find it too complex. I solved the issue with overriding the __init__ function of the models to accept a dict as id parameter and returning a list of dicts in may fucntion field. That's the code of the modelview:
/
//class ExtraProductLine(ModelView): //
//'ExtraProductLine' //
//    __name__ = 'production.extra_product.line' //
////
//    description = fields.Char('Description') //
//    quantity = fields.Float('Quantity') ////
////
//    def __init__(self, id=None, **kargs): //
//        #Id is returned by function fields, //
//        if id and isinstance(id, dict): //
//kargs.update(id) //
//            id = None //
//        super(ExtraProductLine, self).__init__(id, **kargs) /

You need ActiveRecord (>2.6 I think) to get this code working.

As I think is not the best way to solve it. So I openend an issue :)

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Reply via email to