Union Mixin

103 views
Skip to first unread message

Cédric Krier

unread,
Mar 14, 2014, 2:11:26 PM3/14/14
to tryton-...@googlegroups.com
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...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Cédric Krier

unread,
Mar 17, 2014, 6:43:14 PM3/17/14
to tryton-...@googlegroups.com
Indeed I think it is a cleaner replacement for the multi-model patch:
http://codereview.tryton.org/664003/

Frédéric Langevin

unread,
May 6, 2014, 4:30:56 PM5/6/14
to tryton-...@googlegroups.com
Hi Cedric,

We are using this union mixin feature to display a specific menu link to a specific party. That help us to display information related to this party in a nice view with a quick access to all information. I attached a screenshot of the menu. 
I hope this functionality will be included in Tryton.  

Thanks

Frederic Langevin
Coopengo


party_synthese.png

Cédric Krier

unread,
May 9, 2014, 5:44:51 PM5/9/14
to tryton-...@googlegroups.com
I created an issue for official inclusion:

https://bugs.tryton.org/issue3906
http://codereview.tryton.org/8341002
Reply all
Reply to author
Forward
0 new messages