This question has been flagged
1 Reply
7454 Views

Hi,

I have 3 models ; I want to use context to get default values when passing from view to other . How can I do that ? Any help please ?

When creating patient , I will choose or create an appointment. I would to get value "patient_id"  of the model 'hospital.rdv' by default .

Also I have a button action to create an operation from 'hospital.patient' model, so , fields 'date' , 'patient_name ' must be by default.


class Hospital(models.Model):
     _name = 'hospital.patient'
    patient_id = fields.Many2one(hospital.rdv)


class Rendez-vous(models.Model):
     _name = 'hospital.rdv'
    hospital_rdv_id = fields.Many2one(training.patient_id)
    Date = fields.Date(string="Date")
    patient_name = fields.Char(string="Name")


class Operation(models.Model):
    _name = 'hospital.operation'
    patient_id = fields.Many2one(hospital.rdv)
    Date = fields.Date(string="Date")
    patient_name = fields.Char(string="Name")



Thanks.

Avatar
Discard
Best Answer

Check below link  3rd points context pass in manytoone fields.

https://www.cybrosys.com/blog/how-to-use-context-and-domain-in-odoo-13

Check below context pass in parent to child table one2many fields, hope it also work in version 13.

https://www.surekhatech.com/blog/working-with-context-and-domain-in-odoo-v9

Avatar
Discard