On 03 Oct 11:28, Mariano Ramon wrote:
>
>
> On Friday, October 3, 2014 2:41:58 PM UTC-3, Mariano Ramon wrote:
> >
> >
> > I have doctor and team and doctorteam, every doctor can belong to many
> > teams and teams can have many doctors
> >
> > They are defined like this (removed/edited things for brevity/clarity):
> >
> >
> > class Team(ModelSQL, ModelView):
> > 'Etc'
> > __name__ = 'team'
> >
> > doctors = fields.Many2Many('team_doctor', 'team', 'doctor', 'Doctors' )
> >
> >
> > class TeamDoctor(ModelSQL, ModelView):
> > 'etc'
> > __name__ = 'team_doctor'
> >
> > team = fields.Many2One('team','Team', required=True)
> > doctor = fields.Many2One('doctor', 'Doctor', required=True)
> >
> > def search(cls, name, clause):
> > pass
> >
> >
> > class Doctor(ModelSQL, ModelView):
> > 'etc'
> > __name__ = 'doctor'
> > teams = fields.One2Many('team_doctor', 'doctor', 'TEAMs')
> >
> >
> > this seems to work except when I try to access Doctor from any view I get
> > the error when search is not defined in TeamDoctor
> > AttributeError: type object 'doctor_doctorgroup' has no attribute 'search'
> >
> >
> >
> Correction: error says AttributeError: type object 'team_doctor' has no
> attribute 'search'
>
>
>
> > I dont know how to define that method search, I always get
> > unbound method search() must be called with doctor_doctorgroup instance as
> > first argument (got list instance instead()
> > no matter what
> >
> >
> Correction: error says unbound method search() must be called with
> team_doctor instance as first argument (got list instance instead()
>
>
>
> > What I'm doing wrong?
> >
> >
> >
>
> Ok I read about unbound functions and I was missing the decorator.. now
> when I define the search method like this:
>
> @classmethod
> def search(self, clause=[('id', '!=', None)], order=[('team', 'ASC')]):
> passWhy are you overriding search? > I get the error: > > File "............../trytond-3.2.2/trytond/model/fields/one2many.py", line > 98, in get > targets = list(chain(*targets)) > TypeError: 'NoneType' object is not iterable It is the wrong signature for search: http://doc.tryton.org/3.2/trytond/doc/ref/models/models.html?highlight=search#trytond.model.ModelStorage.search -- Cédric Krier - B2CK SPRL Email/Jabber: [email protected] Tel: +32 472 54 46 59 Website: http://www.b2ck.com/
pgpSLljkhpcSP.pgp
Description: PGP signature
