On 08/11/11 11:47 +0100, leo venturini wrote:
> > 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

If the string is clear for the user then it should be also clear for the
developer.
It is a very *important* rule in Tryton design. The name of the field
must be linked to the string. And there is no reason for which it can be
break.

> > 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).

And how do you know that the field you are using is a Many2One or a
xxx2Many. Believe me, this is the worst choice you could do. In 1 month,
when you will need to fix something, you will be completly lost.

> I also use snippets on Gedit to speed up and automate code writing and
> this also drives me in the direction of name semplification.

This is really a wrong choice because you don't put semantic in your
field name. And this semantic is like a documentation of your code.
Believe me, the 20 following lines are really hard to read and understand.

> .....................................................................
> 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')

    companies = fields.Function(fields.One2Many('company.company', None, 
'Companies'))

>     Office = Many2One('Office',
> domain=[('Project.Plan.Company','=',Eval('Company'))])

domain=[('Company', 'in', Eval('companies', []))]

> ....................................................................
> 
> [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.

See above, your domain can not be define just like that.
You must create a function fields that gives you the companies liked to
the project and then you can use this fields to construct a domain.

-- 
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/

Attachment: pgphWGjiUU5X8.pgp
Description: PGP signature

Reply via email to