Odoo Help

1

How to propagate a field value from parent to child object ?

By
Oussama
on 8/8/14, 11:57 AM 1,193 views

I have a Patient view, in which I can create an evaluation for that patient, when i create a new item (evaluation) I want the Patient field to be filled automatically using context.

I don't find how to use context in order to fill that field when filling up the evaluation from the Patient view and not externally.

Here is a part of the code of the evaluation class :

class OeMedicalPatientEvaluation(osv.Model):
    _name='oemedical.patient.evaluation'
    _rec_name='patient_id'
    _columns={
        'patient_id':fields.many2one('oemedical.patient', 'Patient'),
        # many other attributes
    }
    _defaults={
        'patient_id' : lambda self, cr, uid, context : context['patient_id'] if context and 'patient_id' in context else None
    }

And this is a part of the evaluation view :

<form string="Evaluations">
    <field name="patient_id" />
    <!-- many other fields -->
</form>

What to add and how to do in order to fill automatically the patient_id field in the child (pop up) evaluation.

Thanks in advance.

0

Bole

--Bole--
Bole
2395
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 8/18/14, 8:47 AM

if you open a popup directy from main form... the value will be automaticly added on saving the record. just ignore entering it manualy, 
test it in dev environment and make the field invisible later... 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 8/8/14, 11:57 AM
Seen: 1193 times
Last updated: 3/16/15, 8:10 AM