Hi,
I have written following code to get/set Doctor Rounds

    roundings = fields.One2Many('gnuhealth.patient.rounding', 'name',
'Rounds by various doctors/nurses')
    roundings_doctor =
fields.Function(fields.One2Many('gnuhealth.patient.rounding',
'name', 'Rounds by various doctors'), 'get_roundings_doctor','set_
roundings_doctor')


    def get_roundings_doctor(self, name):
        for line in roundings:
            if line.health_professional.healthprof_type.id == 2:
                lines.add(line.id)
        return list(lines)

    @classmethod
    def set_roundings_doctor(cls, records, name, value):
            if not value:
            return
        cls.write(records, {
                'roundings': value,
                })

It works fine and I am able to view the rounds and also update them.

But, to meet another requirement, I overrided the write method in
gnuhealth.patient.rounding class as:

    @classmethod
    def write(cls, roundings, values):
        # TODO - confirm the record is being updated by the Doctor who
created it

        return super(PatientRounding, cls).write(appointments, values)

After this change I can still view the records but when I 'Save' after
changing a round, following error is displayed:

Traceback (most recent call last):
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/
trytond/protocols/dispatcher.py", line 162, in dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/
trytond/modules/health_inpatient_calendar/health_inpatient_calendar.py",
line 96, in write
    return super(InpatientRegistration, cls).write(registrations, values)
  File 
"/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/trytond/model/modelsql.py",
line 930, in write
    field.set(cls, fname, *fargs)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/
trytond/model/fields/function.py", line 109, in set
    setter(Model.browse(ids), name, value)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/
trytond/modules/health_inpatient/health_inpatient.py", line 481, in
set_roundings_doctor

  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/
trytond/modules/health_inpatient_calendar/health_inpatient_calendar.py",
line 96, in write
    return super(InpatientRegistration, cls).write(registrations, values)
  File 
"/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/trytond/model/modelsql.py",
line 930, in write
    field.set(cls, fname, *fargs)
  File "/home/gnuhealth/gnuhealth/tryton/server/trytond-3.8.8/
trytond/model/fields/one2many.py", line 205, in set
    Target.write(*to_write)
TypeError: write() takes exactly 3 arguments (5 given)


I am unable to understand what's wrong with the code. Thanking you in
anticipation!
-- 

Regards,
Khurram.

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/CAM3N3CwpZP-MoED7dZzyHz4qgDyqBXr0XnbVP83z_xCowK%2B-3Q%40mail.gmail.com.

Reply via email to