تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
8841 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
فبراير 25
3291
0
مايو 24
46
1
أبريل 24
3220
4
سبتمبر 23
4699
2
سبتمبر 23
6913