On 25/05/12 17:05 -0700, Triztian wrote: > This is the classes that id like to model(in pure python) , how would the > be in tryton? > > Part(): > p_id = 0 > > Assembly(): > a_id = 0 > parts = [ > ( pid, p_qty ) > ] > > > On Thursday, May 24, 2012 11:42:39 AM UTC-7, Triztian wrote: > > > > I'm trying to model a One2One and a one2many relationship for two tables, > > they have self reference. > > > > The tables are like this > > > > part(pk_id, name) , assembly(fk_part_id, fk_part_id_component, > > comp_quantity) > > > > I have two classes part.py and assembly.py, they inherit from ModelSQL and > > ModelView > > > > Part(): > > pid = 'Integer field' > > name = 'string' Field > > > > Assembly(): > > part_id= fields.One2One( 'inventory.part', 'pid', 'part_id', > > 'part_number') > > comp_id = fields.One2Many(inventory.part', 'pid', 'comp_id', > > 'comp_id')
It must be:
class Assembly(ModelSQL, ModelView):
_name = 'assembly'
name = fields.Char('Name', required=True)
parts = fields.One2Many('part', 'assembly', 'Part')
Assembly()
class Part(ModelSQL, ModelView):
_name = 'part'
name = fields.Char('Name', required=True)
assembly = fields.Many2One('assembly', 'Assembly')
Part()
PS: Please don't top-post on this mailing list. For more information see
http://groups.tryton.org/netiquette
--
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/
pgpSi8bdcXhyo.pgp
Description: PGP signature
