2015-01-06 19:15 GMT+01:00 Mariano Ramon <[email protected]>:

>
>
> On Tuesday, January 6, 2015 12:55:03 PM UTC-3, Cédric Krier wrote:
>>
>> On 06 Jan 07:20, Mariano Ramon wrote:
>> > class CustomParty(ModelSQL, ModelView):
>> >     'Party'
>> >     __name__ = 'party.party'
>> >
>> >     @classmethod
>> >     def create(cls, vlist):
>> >         records = super(CustomParty, cls).create(vlist)
>> >         target = CustomPatient()
>> >         target.name = records[0]
>> >         target.save()
>>
>
I don't know if this is correct, but you can try with

target = CustomPatien(name=records[0])


>
>> You must return records
>>
>> > but this gives me
>> >
>> > assert self.name is not None
>> > AssertionError
>>
>> It looks like your CustomPatient is not registered in the Pool
>>
>
>
> I'm already using CustomPatient so it is on the pool
> the last line of the stack trace where I get the assertion error
>   File
> "/home/user/gnuhealth/tryton/server/trytond-3.2.4/trytond/model/fields/field.py",
> line 209, in __get__
>     assert self.name is not None
>
> I thought self.name was dynamically generated to test required fields but
> lookin field.py i can see it is the name of the actual field and not some
> attribute of it. for reference that fuction in field.py is:
>
>     def __get__(self, inst, cls):
>         if inst is None:
>             return self
>         assert self.name is not None
>         return inst.__getattr__(self.name)
>
>
>
>
>
>>
>> > printing records[0]
>> > gives me <class 'trytond.pool.party.party'>
>>
>> Yes that is the first record created and you can not assign a instance
>> to a Char field (which I guess name is).
>>
>
> name is a many2one field (is a 3rd party module we didn't name it like
> that) this is how is defined.
>
>
> class PatientData(ModelSQL, ModelView):
>     'Patient related information'
>     __name__ = 'gnuhealth.patient'
>
>     name = fields.Many2One(
>         'party.party', 'Patient', required=True,
>         domain=[
>             ('is_patient', '=', True),
>             ('is_person', '=', True),
>             ],
>         states={'readonly': Bool(Eval('name'))},
>         help="Person associated to this patient")
>
>
>
> this is our extension to that model
>
>
> class CustomPatient(ModelSQL, ModelView):
>     __name__ = 'gnuhealth.patient'
>
>
>     # Our added attributes are here and we need an instance of this or
> PatientData and attach the created party to it
>
>
>
>  hope this make it more clear. I don't know what to try..
> thanks
>



-- 

Jesús Martín

Zikzakmedia SL
C/ de Sant Jaume, 9, baixos, 2ª
08720 Vilafranca del Penedès
☏ 93 890 21 08

Reply via email to