On 20 Oct 09:19, Mariano Ramon wrote:
> 
> 
> On Wednesday, October 15, 2014 9:29:58 AM UTC-3, Cédric Krier wrote:
> >
> > On 10 Oct 13:32, Mariano Ramon wrote: 
> > > I apologize in advance for the vagueness of this request but I'm pretty 
> > > lost. 
> > > 
> > > I have these entities 
> > > 
> > > FamilyMembers / Patient / Person ( this three are in hiearchy of the 
> > Party 
> > > Entity ) 
> >
> > I don't understand. 
> >
> 
> Please disregard, is not relevant to the question. For clarity I only use 
> FamiliyMember from now on.
>  
> 
> >
> > > Family (which has FamilyMembers) 
> > > FamilyGroup (which has many Families) 
> >
> > Please provide standard Model definition. 
> >
> 
> 
> 
> class FamilyMember(ModelSQL, ModelView):
>     'Family Member'
>     __name__ = 'custom.family_member'
> 
>     name = fields.Many2One(
>         'custom.family', 'Family', required=True, readonly=True,
>         help='Family code')
> 
> 
> 
> 
> class Family(ModelSQL, ModelView):
>     'Family'
>     __name__ = 'custom.family'
> 
>     familygroup = fields.Many2One('custom.familygroup', 'FAMILYGROUP')
>     name = fields.Char('Family', required=True, help='Family code')
> 
>     members = fields.One2Many(
>         'custom.family_member', 'name', 'Family Members')
> 
> 
> 
> 
> class FamilyGroup(ModelSQL, ModelView):
>     'Family Group'
>     __name__ = 'custom.familygroup'
> 
>     descripcion =  fields.Char('Descripcion del FAMILYGROUP',
>         help='Descripcion del FAMILYGROUP')
>     familias = fields.One2Many('custom.family', 'familygroup', 'Familias', 
> add_remove=[('familygroup', '=', None)])
> 
> 
> 
>  
> I removed non related fields and methods
> 
> I need to show in the FamilyMember view the description field of the 
> FamilyGroup it belongs... only if this familymember belongs to a family and 
> only if this family belongs to a familygroup.

You must define a Function fields with a getter like:

    def getter(self, name):
        if self.name and self.name.familygroup:
            return self.name.familygroup.description

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Attachment: pgpZI0qRfWXZ_.pgp
Description: PGP signature

Reply via email to