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.

Another option is to unrelate the *Part *class completely from the assembly 
and just  relate the *AssemblySpec* to *Assembly* then create a *One2Many * 
relation between the *Part* and *AssemblySpec, *would this be appropriate?

thanks in advance for your patience and time.

Regards, Tristian.

 

-- 
[email protected] mailing list

Reply via email to