Hi Giovanni
Thanks for the reply, and for example if I the would like to specify that
an assembly should have a specific quantity of a part how would that be
modeled?,
will I add another field field in the Assembly model or should I create a
new Model containing the part_id anf part_qty?,
Thanks for your help by the way.
On Friday, May 25, 2012 12:17:41 AM UTC-7, giovanni wrote:
>
> Hi Tristian,
>
> One2Many fields do not need any column in the origin table.
>
> comp_id = fields.One2Many('inventory.part', 'pid', 'comp_id', 'comp_id')
>
> means that you will use the 'pid' column of the 'inventory.part' model to
> find
> comp_ids.
>
> I think you should add something like this in 'inventory.part' :
>
> assembly = Many2One('inventory.assembly', 'Assembly')
>
> then in 'inventory.assembly' :
>
> comp_id = fields.One2Many('inventory.part', 'assembly', 'Comps')
>
> I do not know precisely the sue of the 'add_remove' parameter,
> but I never used it yet so unless you have a specific reason to use
> it, it is not necessary (and I think that's where your error comes from).
>
> One2One fields may be deceitful because they use an extra table
> to store the relation (as they inherit from the Many2Many field), which
> is not obvious at first glance.
>
> 'relation_name' is the name of the model that represent this extra
> table, which must have two Many2One fields :
> - The 'origin' field must go toward the master of the link
> ('inventory.assembly'
> in your case I think)
> - The 'relation' field toward the child.
>
> You should look for Many2Many uses in the existing code, as they
> work the same as One2One link.
>
> Good luck.
>
> Jean CAVALLO
>
--
[email protected] mailing list