On 05 Jan 21:58, Sergi Almacellas Abellana wrote:
>
>
> On 5 de gener de 2015 21:18:45 CET, Mariano Ramon <[email protected]>
> wrote:
> >Which is the function that runs on creations of any model.
>
> The create function of a model is called every time you create some records
> of the model.
>
> The signature is the following:
>
> def create(cls, vlist)
>
> where vlist is a list of dictionaries, where each dictionary a key value for
> each field of the model. The key is the name of the field, and the value is
> the value used to create the record.
But this method should no more be recommended, the right one is: save()
on instance.
> And how can
> >I
> >instantiate and assign a different but related model to one of the
> >fields
> >of the first?
>
> Don't understand the question. Can you put clarify or put an example?
I guess he means putting a value of a Many2One field.
record = MyModel()
target = MyTarget()
target.save()
record.target = target
record.save()
--
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/