On 08/11/11 18:23 +0100, leo venturini wrote:
> class Edition(ModelSQL, ModelView):
> .....
> 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'))])
> .....
>
> 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
>
> .........................................................................
>
> the get_plan_companies() function in itself works but:
> - i'm not sure if the res dictionary is filled correctly
> - it seems to be called (i used some print to debug) ONLY if there is a
> PlanCompanies field into the Edition form (that is not needed and messes
> up the form). Otherwise the CompanyOffice selection list is empty. The result must be a dict with id as key and the value of a One2Many is a list of ids. -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email/Jabber: [email protected] Website: http://www.b2ck.com/
pgpGtIJEZriQF.pgp
Description: PGP signature
