Il giorno Tue, 08/11/2011 alle 09.36 +0100, Cédric Krier ha scritto:
> On 07/11/11 22:05 -0800, vuk wrote:
> > hello everybody, i have this situation:
> >
> > the COMPANY model with a
> > one2many relation to the OFFICE model.
> >
> > the PLAN model with a
> > many2many relation to the COMPANY model and a
> > one2many relation to the PROJECT model, with a
> > one2many relation to the EDITION model with a
> > many2one relation to the OFFICE model.
> >
> > I would like the selection of offices for an edition to be limited to
> > the ones belonging to the companies associated to the 'grandfather'
> > plan of the edition, so i tried on the many2one Office field of the
> > edition model the domain:
> >
> > domain=[('Company','in','Project.Plan.Company')] and
> > domain=[('Company','in',Project.TrainingPlan.Company)]
> >
> > but with no luck. I tried to figure out how to set up the domain by
> > looking into modelsql.py but got lost among all the search() calls...
>
> You must do something like:
>
> [('Project.Plan.Company', '=', Eval('Company'))]
>
hi, thanks but i set this domain over the OFFICE field of the EDITION
model and this doesn't work because
'Field "Project" doesn\'t exist on "Office"').
If i'm not wrong, in case of a many2one field domain, the 'field
name' (first argument) of the domain must refer to a field of the
model_name. so
class Edition(ModelSQL, ModelView):
"Edition"
..........
Office = fields.Many2One('Office', string='Edition Venue',
domain=[('Project.Plan.Company','=',Eval('Company'))])
doesn't work because Office model doesn't have a Project field.
Office model has instead a Company field that logically should be
searched among the Plan - Company Many2Many relation. So into the
Edition model the domain should be something like
Edition.Office in Edition.Project.Plan.Company.
I hope I made myself clear, should i include the involved models python
code?
thanks again
leo venturini
--
[email protected] mailing list