Hi,
I create some fields with many to one type and can't access the value on create method.
Here is the model
from odoo import models, fields, api, _ from odoo.exceptions import ValidationError
class Admission(models.Model):
_name = 'hm.admission'
patient_id = fields.Many2one('hm.patient', 'Patient', required=True, index=True)
visit_id = fields.Integer('Visit No', required=True)
card_no = fields.Char(related='patient_id.card_no', store=False, index=True)
medical_no = fields.Char(related='patient_id.medical_no', store=False, index=True)
age = fields.Char(related='patient_id.age', store=False, index=True)
department_id = fields.Many2one('hr.department', 'Department')
employee_id = fields.Many2one('hr.employee', 'Medic', domain="[('department_id', '=', department_id)]")
admissionType = fields.Selection(
[('outpatient', 'Outpatient'), ('inpatient', 'Inpatient'), ('newborn', 'New Born'), ('emergency', 'Emergency')],
'Admission Type', required=True)
state = fields.Selection([('admitted', 'Admitted'),
('waiting', 'Waiting'),
('ready', 'Ready'),
('intreatment', 'Intreatment'),
('waitingresult', 'Awaiting Result(s)'),
('unsummarized', 'Unsummarized'),
('inpatient', 'Inpatient'),
('discharged', 'Discharged'),
('closed', 'Closed')], 'Admission Status', default='admitted')
visit_type = fields.Many2one('hm.visit.type', 'Visit Type', required=True)
create_date = fields.Date('Admission Date', readonly=True)