Skip to Content
Menu
This question has been flagged
3029 Views

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)





Avatar
Discard
Related Posts Replies Views Activity
4
Sep 15
6179
1
Aug 16
9151
0
Apr 24
557
1
Dec 22
5255
0
Dec 19
3494