On 08/01/10 15:25 +0100, Hartmut Goebel wrote:
> Hi,
> 
> I get stuck with defining a many2many view.
> 
> This is my model:
> 
> class PartyWorksForParty(ModelSQL):
>     'Party - Party'
>     _name = 'party-worksfor-party'
>     person = fields.Many2One('party.party', 'Person',
>                              select=1, required=True)
>     org = fields.Many2One('party.party', 'Organisation',
>                           select=1, required=True)
> PartyWorksForParty()
> 
> class Party(ModelSQL, ModelView):
>     _name = 'party.party'
>     works_for = fields.Many2Many('party-worksfor-party',
>                                  'person', 'org',
>                                  string='Works for')
> Party()
> 
> 
> If I define a view like this:
> 
>             <page string="Notes" id="notes">
>               <field name="works_for">
>               </field>
>             </page>
> 
> I'll get a many2many field displaying columns of parts.party (code,
> name, language, VAT-ID, etc.)
> 
> If I define a view like this:
> 
>             <page string="Notes" id="notes">
>               <field name="works_for">
>                 <tree string="Works for" fill="1">
> <field name="org"/>
>                 </tree>
>               </field>
>             </page>
> 
> tryton fails displaying the form: Keyerror: 'org'
> 
> Where is my mistake?
> 

The field works_for displays "party.party" and not "party-worksfor-party".
So the field org is not define on "party.party".
I think what you want is to have only the "rec_name" of the party.party:

    <page string="Notes" id="notes">
        <field name="works_for">
            <tree string="Works for" fill="1">
                <field name="rec_name"/>
            </tree>
        </field>
    </page>


PS: I think rec_name is better than name because it can be customized.

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email: [email protected]
Jabber: [email protected]
Website: http://www.b2ck.com/
twitter: http://twitter.com/cedrickrier
identi.ca: http://identi.ca/cedrickrier

Attachment: pgp2uSbVZqGTR.pgp
Description: PGP signature

Reply via email to