how inherited with odoo I want to modify the type of consultation as on this code but I don't want to touch the source file

58 Views Asked by At

here is the code I want to change the type of consultation to: -new consultation -followed by consultation

class OeHealthPhysician (osv.osv):
    """New class the oeh.medical.physician"""
    _name = "oeh.medical.physician"
    _description = "Information about the doctor"
    _inherits={
        'hr.employee': 'employee_id',
    }

    CONSULTATION_TYPE = [
        ('Residential', 'Residential'),
        ('Visiting', 'Visiting'),
        ('Other', 'Other'),
        ]

this is what i have try to do and it doest work

class OeHealthPhysician (osv.osv):
    """New class the oeh.medical.physician"""
    _name = "oeh.medical.physician"
    _description = "Information about the doctor"
    _inherits={
        'hr.employee': 'employee_id',
    }

    CONSULTATION_TYPE = [
        ('New consultation', 'New consultationl'),
        ('Followed by consultation', 'Followed by consultation'),
        ]
2

There are 2 best solutions below

0
holydragon On

You would need to inherit the model and overwrite the selection field with your new selections.

Class OeHealthPhysicianInherit(models.Model):

_inherit  = 'oeh.medical.physician'

consultation_type = fields.Selection([
  ('New consultation', 'New consultation'),
  ('Followed by consultation', 'Followed by consultation')
])
0
Kenly On

To override the consultation field and add new selection values, use the selection_add parameter:

selection_add -- provides an extension of the selection in the case of an overridden field. It is a list of pairs (value, string).