Il giorno Tue, 08/11/2011 alle 22.43 +0100, Cédric Krier ha scritto:
> On 08/11/11 20:39 +0100, leo venturini wrote:
> > > > def get_plan_companies(self, ids, name):
> > > > if not ids:
> > > > return []
> > > > res = {}
> > > > for Edition in self.browse(ids):
> > > > Project = Edition.Project
> > > > TrainingPlan = Project.TrainingPlan
> > > > Companies = TrainingPlan.Company
> > > > #for Company in Companies:
> > > > # res[Company.id] = Company.name
> > > res[Edition.id] = [c.id for x in TrainingPlan.Company]
> > > > print res
> > > > return res
> > > >
> >
> > perfect, now it works! The only 'weird' thing is that i *must* have the
> > PlanCompanies field into the Edition form, wich is quite useless but i
> > set invisible=1 into the xml so it's not really a problem.
>
> No you must set 'companies' in depends of the field Company.
PlanCompanies = fields.Function(
fields.One2Many('train.Company', None, 'Companies'),
'get_plan_companies')
CompanyOffice = fields.Many2One(
'train.CompanyOffice',
string='Company Office'
domain=[('Company','in',Eval('PlanCompanies'))],
depends=['PlanCompanies'])
And now it works even without the field in the form, problem solved.
Thanks again Cédric
leo
--
vuk di Leonardo Venturini
web developement
via Zandonai, 1 - 24129 Bergamo (BG)
Italy
P.IVA 03084840168
cell 339.6132096
http://vuk.bg.it
--
[email protected] mailing list