Le Mon, 28 May 2012 08:58:11 -0700 (PDT),
Triztian <[email protected]> a écrit :
>
>
> On Friday, May 25, 2012 6:45:22 PM UTC-7, Cédric Krier wrote:
> >
> > On 25/05/12 18:01 -0700, Triztian wrote:
> > > So I infer that a parent cannot establish a relation to a child
> > > without
> > the
> > > child specifying a field that relates them to its parent?
> >
> > No, this is a basic design with relational database.
> >
> > --
> > Cédric Krier
> >
>
> Hi again, sorry to be a PITA, I've successfully created a many2many
> using these models
>
> Part( ModelSQL, ModelView ):
> _name = 'inventory.assembly'
> number = Char('part_number')
> assembly = Many2One('inventory.assembly', 'assembly', 'part',
> 'parts')
>
> AssemblySpec( ModelSQL ):
> _name = 'inventory.assembly_spec'
> assembly_number =
> Many2One('inventory.assembly','assembly_number') part_number =
> Many2One('inventory.part', 'part_number')
> # How to use this third field?
> quantity = Integer( 'part_quantity' )
>
>
> Assembly( ModelSQL, ModelView ):
> _name = 'inventory.assembly'
> number = Char( 'number' )
> parts = Many2Many( 'inventory.assembly_spec', 'assembly',
> 'part','parts' )
>
> My question is how would I include the 'quantity' field in the
> intersection table?, as when I'm creating a
> new assembly I only get the option to add an existing part, but I
> cannot specify the quantity for said part, I
> believe these is because 'AssemblySpec' does not inherit from
> 'ModelView' , but in the example in the wiki the
> many2many relation is defined like that.
Hi,
If you want to see the quantity field, you just need to use a one2many
instead of a many2many for the "parts" field of Assembly and add the
ModelView inheritance on the AssemblySpec model.
hth,
Bertrand
--
Bertrand Chenal
B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Email: [email protected]
Website: http://www.b2ck.com/
--
[email protected] mailing list