Il giorno Tue, 08/11/2011 alle 10.41 +0100, Cédric Krier ha scritto:
> > 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?
> 
> It is realy unclear. You should give the right name to your fields
> otherwise it is confusing.
I get your point but there is a (questionable...) logic behind my name
convention choices. Keep in mind that i'm developing for a customer that
projects and runs training courses for companies employees:
>  In your example, you get a field name
> 'Office' but the string is 'Edition Venue', this kind of mismatching
> create a lot of confusion. 
- Edition Venue is the place where the course (= Edition of a Project)
is held. This venue IS a Company Office but I must provide a string
that's clearest as possible for the application operator
> Also if the field is a Many2Many you must
> use the plurial for the name of the field.
True! And that was my first choice too but in the attempt to reduce the need 
to go and check fields names between files I decided to use always the singular 
model name when referring to a certain model, even if it should logically be 
plural 
(like in many2many fields case).
I also use snippets on Gedit to speed up and automate code writing and
this also drives me in the direction of name semplification.

I tried to adhere to tryton modules name convention as often as possible
(ie: ModelSql instead of model_sql as I used to) but, as I said, name
convention is a field of eternal debate.

Anyway, in the effort to explain my problem more clearly, here is my
models structure, stripped of everything but the relation fields:

.....................................................................
class Company():
    Office = One2Many('Office')
    
class Office():
    Company = Many2One('Company')
    
class Plan():
    Company = Many2Many('Plan_Company', 'Plan', 'Company')
    Project = One2Many('Project')
    
class Plan_Company():
    Plan = Many2One('Plan')
    Company = Many2One('Company')
    
class Project():
    Plan = Many2One('Plan')

class Edition():
    Project = Many2One('Project')
    Office = Many2One('Office',
domain=[('Project.Plan.Company','=',Eval('Company'))])
....................................................................

[the domain above is the last one tried after Cédric suggestion.]

In the Edition form, when opening the Office selection field, I would
like in the Offices list ONLY the Offices belonging to Companies related
to the right Plan to appear.
For example, Companies ACME and STARK are involved into Plan X. Into
Plan X a Project 'Basic English' has been engineered and real Courses
(=Editions) will be held. Each of this Edition could be held in a
different Office of ACME or STARK. So the choice of the Office for each
Edition should be limited to the ACME and STARK ones.

thanks again for your time
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

Reply via email to