Hi,

I just wanted to share with you a Mixin I just created to define a Model
which is an union of many.

http://codereview.appspot.com/76190043

For example to show party and address in the same tree view:


    class Example(UnionMixin, ModelSQL, ModelView):
        'Union Example'
        __name__ = 'party.union'
        name = fields.Char('Name', readonly=True)
        parent = fields.Many2One('party.union' 'Parent')
        childs = fields.One2Many('party.union', 'parent', 'Childs')

        @staticmethod
        def union_models():
            return ['party.party', 'party.address']

        @classmethod
        def union_field(cls, name, Model):
            union_field = super(Example, cls).union_field(name, Model)
            if Model.__name__ == 'party.address' and name == 'parent':
                return Model._fields['party']
            return union_field

I think it could be usefull to display aggregated trees like those
created by hebi. It could also be possible to allow create/write/delete
on such model.
Also I don't know if we should propose it to be included in Tryton or
not.

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Attachment: pgppQaZ9N1NKb.pgp
Description: PGP signature

Reply via email to